7 changes: 2 additions & 5 deletions libc/test/src/signal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ add_libc_unittest(
kill_test.cpp
DEPENDS
libc.include.signal
libc.include.errno
libc.src.errno.errno
libc.src.signal.kill
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
Expand Down Expand Up @@ -48,7 +46,6 @@ add_libc_unittest(
SRCS
sigprocmask_test.cpp
DEPENDS
libc.include.errno
libc.src.errno.errno
libc.src.signal.raise
libc.src.signal.sigaddset
Expand Down Expand Up @@ -77,7 +74,6 @@ add_libc_unittest(
SRCS
signal_test.cpp
DEPENDS
libc.include.errno
libc.include.signal
libc.src.errno.errno
libc.src.signal.raise
Expand Down Expand Up @@ -123,9 +119,10 @@ add_libc_unittest(
SRCS
sigaltstack_test.cpp
DEPENDS
libc.include.errno
libc.include.signal
libc.src.errno.errno
libc.src.signal.raise
libc.src.signal.sigaltstack
libc.src.signal.sigaction
libc.test.errno_setter_matcher
)
1 change: 0 additions & 1 deletion libc/test/src/signal/kill_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "test/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

#include <errno.h>
#include <signal.h>

using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/signal/sigaddset_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
//
//===----------------------------------------------------------------------===//

#include "include/errno.h"
#include "include/signal.h"
#include "src/signal/sigaddset.h"

#include "test/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

#include <errno.h>

// This tests invalid inputs and ensures errno is properly set.
TEST(LlvmLibcSignalTest, SigaddsetInvalid) {
using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
Expand Down
4 changes: 2 additions & 2 deletions libc/test/src/signal/sigaltstack_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
#include "src/signal/raise.h"
#include "src/signal/sigaction.h"
Expand All @@ -15,7 +16,6 @@
#include "test/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

#include <errno.h>
#include <signal.h>
#include <stdint.h>
#include <sys/syscall.h>
Expand Down Expand Up @@ -47,7 +47,7 @@ static void handler(int) {

TEST(LlvmLibcSignalTest, SigaltstackRunOnAltStack) {
struct sigaction action;
errno = 0;
libc_errno = 0;
ASSERT_THAT(__llvm_libc::sigaction(SIGUSR1, nullptr, &action), Succeeds(0));
action.sa_handler = handler;
// Indicate that the signal should be delivered on an alternate stack.
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/signal/sigdelset_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "include/errno.h"
#include "include/signal.h"
#include "src/signal/raise.h"
#include "src/signal/sigdelset.h"
Expand All @@ -16,6 +15,8 @@
#include "test/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

#include <errno.h>

TEST(LlvmLibcSigdelset, Invalid) {
using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
// Invalid set.
Expand Down
3 changes: 2 additions & 1 deletion libc/test/src/signal/sigfillset_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "include/errno.h"
#include "include/signal.h"
#include "src/signal/raise.h"
#include "src/signal/sigfillset.h"
Expand All @@ -15,6 +14,8 @@
#include "test/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

#include <errno.h>

TEST(LlvmLibcSigfillset, Invalid) {
using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
EXPECT_THAT(__llvm_libc::sigfillset(nullptr), Fails(EINVAL));
Expand Down
5 changes: 2 additions & 3 deletions libc/test/src/signal/signal_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//

#include "include/errno.h"
#include "include/signal.h"
#include "src/errno/llvmlibc_errno.h"
#include "src/errno/libc_errno.h"
#include "src/signal/raise.h"
#include "src/signal/signal.h"

Expand All @@ -19,7 +18,7 @@ using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;

TEST(LlvmLibcSignal, Invalid) {
llvmlibc_errno = 0;
libc_errno = 0;
__llvm_libc::sighandler_t valid = +[](int) {};
EXPECT_THAT((void *)__llvm_libc::signal(0, valid),
Fails(EINVAL, (void *)SIG_ERR));
Expand Down
5 changes: 2 additions & 3 deletions libc/test/src/signal/sigprocmask_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//

#include "include/errno.h"
#include "include/signal.h"
#include "src/errno/llvmlibc_errno.h"
#include "src/errno/libc_errno.h"
#include "src/signal/raise.h"
#include "src/signal/sigaddset.h"
#include "src/signal/sigemptyset.h"
Expand All @@ -33,7 +32,7 @@ using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;

// This tests for invalid input.
TEST_F(LlvmLibcSignalTest, SigprocmaskInvalid) {
llvmlibc_errno = 0;
libc_errno = 0;

sigset_t valid;
// 17 and -4 are out of the range for sigprocmask's how paramater.
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/termios/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ add_libc_unittest(
SRCS
termios_test.cpp
DEPENDS
libc.include.errno
libc.include.termios
libc.src.errno.errno
libc.src.fcntl.open
libc.src.termios.cfgetispeed
libc.src.termios.cfgetospeed
Expand Down
16 changes: 8 additions & 8 deletions libc/test/src/termios/termios_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "src/errno/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/termios/cfgetispeed.h"
#include "src/termios/cfgetospeed.h"
Expand All @@ -18,7 +19,6 @@
#include "test/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

#include <errno.h>
#include <termios.h>

using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
Expand All @@ -30,35 +30,35 @@ using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;

TEST(LlvmLibcTermiosTest, SpeedSmokeTest) {
struct termios t;
errno = 0;
libc_errno = 0;
ASSERT_THAT(__llvm_libc::cfsetispeed(&t, B50), Succeeds(0));
ASSERT_EQ(__llvm_libc::cfgetispeed(&t), speed_t(B50));
ASSERT_THAT(__llvm_libc::cfsetospeed(&t, B75), Succeeds(0));
ASSERT_EQ(__llvm_libc::cfgetospeed(&t), speed_t(B75));

errno = 0;
libc_errno = 0;
ASSERT_THAT(__llvm_libc::cfsetispeed(&t, ~CBAUD), Fails(EINVAL));
errno = 0;
libc_errno = 0;
ASSERT_THAT(__llvm_libc::cfsetospeed(&t, ~CBAUD), Fails(EINVAL));
}

TEST(LlvmLibcTermiosTest, GetAttrSmokeTest) {
struct termios t;
errno = 0;
libc_errno = 0;
int fd = __llvm_libc::open("/dev/tty", O_RDONLY);
if (fd < 0)
return; // When /dev/tty is not available, no point continuing.
ASSERT_EQ(errno, 0);
ASSERT_EQ(libc_errno, 0);
ASSERT_THAT(__llvm_libc::tcgetattr(fd, &t), Succeeds(0));
ASSERT_EQ(__llvm_libc::close(fd), 0);
}

TEST(LlvmLibcTermiosTest, TcGetSidSmokeTest) {
errno = 0;
libc_errno = 0;
int fd = __llvm_libc::open("/dev/tty", O_RDONLY);
if (fd < 0)
return; // When /dev/tty is not available, no point continuing.
ASSERT_EQ(errno, 0);
ASSERT_EQ(libc_errno, 0);
ASSERT_GT(__llvm_libc::tcgetsid(fd), pid_t(0));
ASSERT_EQ(__llvm_libc::close(fd), 0);
}