Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc/test/src/__support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ add_libc_test(
str_to_float_test.cpp
str_to_double_test.cpp
str_to_long_double_test.cpp
HDRS
str_to_fp_test.h
DEPENDS
libc.src.__support.integer_literals
libc.src.__support.str_to_float
Expand Down
1 change: 0 additions & 1 deletion libc/test/src/__support/str_to_fp_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include "src/__support/str_to_float.h"
#include "src/__support/uint128.h"
Expand Down
1 change: 0 additions & 1 deletion libc/test/src/__support/str_to_integer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/libc_errno.h"
#include "src/__support/str_to_integer.h"
#include <stddef.h>

Expand Down
1 change: 0 additions & 1 deletion libc/test/src/__support/wcs_to_integer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/libc_errno.h"
#include "src/__support/wcs_to_integer.h"
#include <stddef.h>

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/poll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ add_libc_unittest(
libc.hdr.limits_macros
libc.src.errno.errno
libc.src.poll.poll
libc.test.UnitTest.ErrnoSetterMatcher
libc.test.UnitTest.ErrnoCheckingTest
)
11 changes: 6 additions & 5 deletions libc/test/src/poll/poll_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
//===----------------------------------------------------------------------===//

#include "hdr/limits_macros.h" // UINT_MAX
#include "src/__support/libc_errno.h"
#include "src/poll/poll.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/Test.h"

TEST(LlvmLibcPollTest, SmokeTest) {
libc_errno = 0;
using LlvmLibcPollTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;

TEST_F(LlvmLibcPollTest, SmokeTest) {
int ret = LIBC_NAMESPACE::poll(nullptr, 0, 0);
ASSERT_ERRNO_SUCCESS();
ASSERT_EQ(0, ret);
}
TEST(LlvmLibcPollTest, SmokeFailureTest) {
libc_errno = 0;

TEST_F(LlvmLibcPollTest, SmokeFailureTest) {
int ret = LIBC_NAMESPACE::poll(nullptr, UINT_MAX, 0);
ASSERT_ERRNO_EQ(EINVAL);
ASSERT_EQ(-1, ret);
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/spawn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_libc_unittest(
SRCS
posix_spawn_file_actions_test.cpp
DEPENDS
libc.hdr.errno_macros
libc.hdr.stdint_proxy
libc.include.spawn
libc.src.spawn.file_actions
Expand All @@ -15,5 +16,4 @@ add_libc_unittest(
libc.src.spawn.posix_spawn_file_actions_addopen
libc.src.spawn.posix_spawn_file_actions_destroy
libc.src.spawn.posix_spawn_file_actions_init
libc.src.errno.errno
)
2 changes: 1 addition & 1 deletion libc/test/src/spawn/posix_spawn_file_actions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#include "hdr/errno_macros.h"
#include "hdr/stdint_proxy.h"
#include "src/__support/libc_errno.h"
#include "src/spawn/file_actions.h"
#include "src/spawn/posix_spawn_file_actions_addclose.h"
#include "src/spawn/posix_spawn_file_actions_adddup2.h"
Expand Down
2 changes: 2 additions & 0 deletions libc/test/src/sys/ioctl/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ add_libc_unittest(
libc.src.unistd.close
libc.src.unistd.read
libc.src.unistd.write
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)

8 changes: 3 additions & 5 deletions libc/test/src/sys/ioctl/linux/ioctl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/sys/ioctl/ioctl.h"
#include "src/unistd/close.h"
#include "src/unistd/read.h"
#include "src/unistd/write.h"

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

#include "hdr/sys_stat_macros.h"

#include "hdr/sys_ioctl_macros.h"

using LlvmLibcSysIoctlTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;

TEST(LlvmLibcSysIoctlTest, InvalidCommandAndFIONREAD) {
LIBC_NAMESPACE::libc_errno = 0;

TEST_F(LlvmLibcSysIoctlTest, InvalidCommandAndFIONREAD) {
// Setup the test file
constexpr const char *TEST_FILE_NAME = "ioctl.test";
constexpr const char TEST_MSG[] = "ioctl test";
Expand Down
1 change: 1 addition & 0 deletions libc/test/src/termios/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ add_libc_unittest(
libc.src.termios.tcgetsid
libc.src.termios.tcsetattr
libc.src.unistd.close
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
14 changes: 5 additions & 9 deletions libc/test/src/termios/termios_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/libc_errno.h"
#include "src/fcntl/open.h"
#include "src/termios/cfgetispeed.h"
#include "src/termios/cfgetospeed.h"
Expand All @@ -16,35 +15,33 @@
#include "src/termios/tcgetsid.h"
#include "src/termios/tcsetattr.h"
#include "src/unistd/close.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"

#include <termios.h>

using LlvmLibcTermiosTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;

// We just list a bunch of smoke tests here as it is not possible to
// test functionality at the least because we want to run the tests
// from ninja/make which change the terminal behavior.

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

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

TEST(LlvmLibcTermiosTest, GetAttrSmokeTest) {
TEST_F(LlvmLibcTermiosTest, GetAttrSmokeTest) {
struct termios t;
libc_errno = 0;
int fd = LIBC_NAMESPACE::open("/dev/tty", O_RDONLY);
if (fd < 0)
return; // When /dev/tty is not available, no point continuing.
Expand All @@ -53,8 +50,7 @@ TEST(LlvmLibcTermiosTest, GetAttrSmokeTest) {
ASSERT_EQ(LIBC_NAMESPACE::close(fd), 0);
}

TEST(LlvmLibcTermiosTest, TcGetSidSmokeTest) {
libc_errno = 0;
TEST_F(LlvmLibcTermiosTest, TcGetSidSmokeTest) {
int fd = LIBC_NAMESPACE::open("/dev/tty", O_RDONLY);
if (fd < 0)
return; // When /dev/tty is not available, no point continuing.
Expand Down
Loading