diff --git a/libc/test/config/linux/x86_64/syscall_test.cpp b/libc/test/config/linux/x86_64/syscall_test.cpp --- a/libc/test/config/linux/x86_64/syscall_test.cpp +++ b/libc/test/config/linux/x86_64/syscall_test.cpp @@ -11,6 +11,8 @@ #include "utils/CPP/Functional.h" +namespace __llvm_libc { + TEST(X86_64_SyscallTest, APITest) { // We only do a signature test here. Actual functionality tests are // done by the unit tests of the syscall wrappers like mmap. @@ -42,3 +44,5 @@ function notLongType( [](long n, void *a1) { return __llvm_libc::syscall(n, a1); }); } + +} // namespace __llvm_libc diff --git a/libc/test/loader/linux/args_test.cpp b/libc/test/loader/linux/args_test.cpp --- a/libc/test/loader/linux/args_test.cpp +++ b/libc/test/loader/linux/args_test.cpp @@ -9,6 +9,8 @@ #undef NDEBUG #include "src/assert/assert.h" +namespace __llvm_libc { + static bool my_streq(const char *lhs, const char *rhs) { const char *l, *r; for (l = lhs, r = rhs; *l != '\0' && *r != '\0'; ++l, ++r) @@ -38,3 +40,5 @@ return 0; } + +} // namespace __llvm_libc diff --git a/libc/test/src/assert/assert_test.cpp b/libc/test/src/assert/assert_test.cpp --- a/libc/test/src/assert/assert_test.cpp +++ b/libc/test/src/assert/assert_test.cpp @@ -12,6 +12,8 @@ extern "C" int close(int); +namespace __llvm_libc { + TEST(Assert, Enabled) { // -1 matches against any signal, which is necessary for now until // __llvm_libc::abort() unblocks SIGABRT. Close standard error for the @@ -30,3 +32,5 @@ TEST(Assert, Disabled) { EXPECT_EXITS([] { assert(0); }, 0); } + +} // namespace __llvm_libc diff --git a/libc/test/src/errno/errno_test.cpp b/libc/test/src/errno/errno_test.cpp --- a/libc/test/src/errno/errno_test.cpp +++ b/libc/test/src/errno/errno_test.cpp @@ -9,8 +9,12 @@ #include "src/errno/llvmlibc_errno.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(ErrnoTest, Basic) { int test_val = 123; llvmlibc_errno = test_val; ASSERT_EQ(test_val, llvmlibc_errno); } + +} // namespace __llvm_libc diff --git a/libc/test/src/signal/raise_test.cpp b/libc/test/src/signal/raise_test.cpp --- a/libc/test/src/signal/raise_test.cpp +++ b/libc/test/src/signal/raise_test.cpp @@ -11,6 +11,8 @@ #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(SignalTest, Raise) { // SIGCONT is ingored unless stopped, so we can use it to check the return // value of raise without needing to block. @@ -20,3 +22,5 @@ // for example and incorrectly report test failure. EXPECT_DEATH([] { __llvm_libc::raise(SIGKILL); }, SIGKILL); } + +} // namespace __llvm_libc diff --git a/libc/test/src/signal/sigaction_test.cpp b/libc/test/src/signal/sigaction_test.cpp --- a/libc/test/src/signal/sigaction_test.cpp +++ b/libc/test/src/signal/sigaction_test.cpp @@ -18,6 +18,8 @@ using __llvm_libc::testing::ErrnoSetterMatcher::Fails; using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; +namespace __llvm_libc { + TEST(Sigaction, Invalid) { // -1 is a much larger signal that NSIG, so this should fail. EXPECT_THAT(__llvm_libc::sigaction(-1, nullptr, nullptr), Fails(EINVAL)); @@ -64,3 +66,5 @@ EXPECT_EXITS([] { __llvm_libc::raise(SIGUSR1); }, 0); } + +} // namespace __llvm_libc diff --git a/libc/test/src/signal/sigaddset_test.cpp b/libc/test/src/signal/sigaddset_test.cpp --- a/libc/test/src/signal/sigaddset_test.cpp +++ b/libc/test/src/signal/sigaddset_test.cpp @@ -13,6 +13,8 @@ #include "utils/UnitTest/ErrnoSetterMatcher.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + // This tests invalid inputs and ensures errno is properly set. TEST(SignalTest, SigaddsetInvalid) { using __llvm_libc::testing::ErrnoSetterMatcher::Fails; @@ -31,3 +33,5 @@ EXPECT_THAT(__llvm_libc::sigaddset(&sigset, 0), Fails(EINVAL)); EXPECT_THAT(__llvm_libc::sigaddset(&sigset, bitsInSigsetT), Succeeds()); } + +} // namespace __llvm_libc diff --git a/libc/test/src/signal/sigdelset_test.cpp b/libc/test/src/signal/sigdelset_test.cpp --- a/libc/test/src/signal/sigdelset_test.cpp +++ b/libc/test/src/signal/sigdelset_test.cpp @@ -16,6 +16,8 @@ #include "utils/UnitTest/ErrnoSetterMatcher.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(Sigdelset, Invalid) { using __llvm_libc::testing::ErrnoSetterMatcher::Fails; // Invalid set. @@ -34,3 +36,5 @@ EXPECT_THAT(__llvm_libc::sigprocmask(SIG_SETMASK, &set, nullptr), Succeeds()); EXPECT_DEATH([] { __llvm_libc::raise(SIGUSR1); }, SIGUSR1); } + +} // namespace __llvm_libc diff --git a/libc/test/src/signal/sigfillset_test.cpp b/libc/test/src/signal/sigfillset_test.cpp --- a/libc/test/src/signal/sigfillset_test.cpp +++ b/libc/test/src/signal/sigfillset_test.cpp @@ -15,6 +15,8 @@ #include "utils/UnitTest/ErrnoSetterMatcher.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(Sigfillset, Invalid) { using __llvm_libc::testing::ErrnoSetterMatcher::Fails; EXPECT_THAT(__llvm_libc::sigfillset(nullptr), Fails(EINVAL)); @@ -27,3 +29,5 @@ EXPECT_THAT(__llvm_libc::sigprocmask(SIG_SETMASK, &set, nullptr), Succeeds()); EXPECT_EXITS([] { __llvm_libc::raise(SIGUSR1); }, 0); } + +} // namespace __llvm_libc diff --git a/libc/test/src/signal/signal_test.cpp b/libc/test/src/signal/signal_test.cpp --- a/libc/test/src/signal/signal_test.cpp +++ b/libc/test/src/signal/signal_test.cpp @@ -18,6 +18,8 @@ using __llvm_libc::testing::ErrnoSetterMatcher::Fails; using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; +namespace __llvm_libc { + TEST(Signal, Invalid) { llvmlibc_errno = 0; __llvm_libc::sighandler_t valid = +[](int) {}; @@ -39,3 +41,5 @@ ASSERT_THAT(__llvm_libc::raise(SIGUSR1), Succeeds()); EXPECT_EQ(sum, 11); } + +} // namespace __llvm_libc diff --git a/libc/test/src/signal/sigprocmask_test.cpp b/libc/test/src/signal/sigprocmask_test.cpp --- a/libc/test/src/signal/sigprocmask_test.cpp +++ b/libc/test/src/signal/sigprocmask_test.cpp @@ -17,6 +17,8 @@ #include "utils/UnitTest/ErrnoSetterMatcher.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + class SignalTest : public __llvm_libc::testing::Test { sigset_t oldSet; @@ -58,3 +60,5 @@ EXPECT_EQ(__llvm_libc::sigprocmask(SIG_SETMASK, &sigset, nullptr), 0); EXPECT_EXITS([] { __llvm_libc::raise(SIGUSR1); }, 0); } + +} // namespace __llvm_libc diff --git a/libc/test/src/stdio/fwrite_test.cpp b/libc/test/src/stdio/fwrite_test.cpp --- a/libc/test/src/stdio/fwrite_test.cpp +++ b/libc/test/src/stdio/fwrite_test.cpp @@ -11,6 +11,8 @@ #include "utils/CPP/Array.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(Stdio, FWriteBasic) { struct StrcpyFile : __llvm_libc::FILE { char *buf; @@ -26,3 +28,5 @@ EXPECT_EQ(fwrite("hello", 1, 6, &f), 6UL); EXPECT_STREQ(array, "hello"); } + +} // namespace __llvm_libc diff --git a/libc/test/src/stdlib/_Exit_test.cpp b/libc/test/src/stdlib/_Exit_test.cpp --- a/libc/test/src/stdlib/_Exit_test.cpp +++ b/libc/test/src/stdlib/_Exit_test.cpp @@ -10,7 +10,11 @@ #include "src/stdlib/_Exit.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(Stdlib, _Exit) { EXPECT_EXITS([] { __llvm_libc::_Exit(1); }, 1); EXPECT_EXITS([] { __llvm_libc::_Exit(65); }, 65); } + +} // namespace __llvm_libc diff --git a/libc/test/src/stdlib/abort_test.cpp b/libc/test/src/stdlib/abort_test.cpp --- a/libc/test/src/stdlib/abort_test.cpp +++ b/libc/test/src/stdlib/abort_test.cpp @@ -11,8 +11,12 @@ #include "src/stdlib/abort.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(Stdlib, abort) { // -1 matches against any signal, which is necessary for now until // __llvm_libc::abort() unblocks SIGABRT. EXPECT_DEATH([] { __llvm_libc::abort(); }, -1); } + +} // namespace __llvm_libc diff --git a/libc/test/src/string/memcpy_test.cpp b/libc/test/src/string/memcpy_test.cpp --- a/libc/test/src/string/memcpy_test.cpp +++ b/libc/test/src/string/memcpy_test.cpp @@ -15,6 +15,8 @@ using __llvm_libc::cpp::MutableArrayRef; using Data = Array; +namespace __llvm_libc { + static const ArrayRef kNumbers("0123456789", 10); static const ArrayRef kDeadcode("DEADC0DE", 8); @@ -51,3 +53,5 @@ // FIXME: Add tests with reads and writes on the boundary of a read/write // protected page to check we're not reading nor writing prior/past the allowed // regions. + +} // namespace __llvm_libc diff --git a/libc/test/src/string/strcat_test.cpp b/libc/test/src/string/strcat_test.cpp --- a/libc/test/src/string/strcat_test.cpp +++ b/libc/test/src/string/strcat_test.cpp @@ -9,6 +9,8 @@ #include "src/string/strcat.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(StrCatTest, EmptyDest) { const char *abc = "abc"; char dest[4]; @@ -35,3 +37,5 @@ ASSERT_STREQ(dest, result); ASSERT_STREQ(dest, "xyzabc"); } + +} // namespace __llvm_libc diff --git a/libc/test/src/string/strcpy_test.cpp b/libc/test/src/string/strcpy_test.cpp --- a/libc/test/src/string/strcpy_test.cpp +++ b/libc/test/src/string/strcpy_test.cpp @@ -9,6 +9,8 @@ #include "src/string/strcpy.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(StrCpyTest, EmptyDest) { const char *abc = "abc"; char dest[4]; @@ -32,3 +34,5 @@ ASSERT_STREQ(dest + 3, result); ASSERT_STREQ(dest, "xyzabc"); } + +} // namespace __llvm_libc diff --git a/libc/test/src/string/strlen_test.cpp b/libc/test/src/string/strlen_test.cpp --- a/libc/test/src/string/strlen_test.cpp +++ b/libc/test/src/string/strlen_test.cpp @@ -9,6 +9,8 @@ #include "src/string/strlen.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + TEST(StrLenTest, EmptyString) { const char *empty = ""; @@ -22,3 +24,5 @@ size_t result = __llvm_libc::strlen(any); ASSERT_EQ((size_t)12, result); } + +} // namespace __llvm_libc diff --git a/libc/test/src/sys/mman/linux/mmap_test.cpp b/libc/test/src/sys/mman/linux/mmap_test.cpp --- a/libc/test/src/sys/mman/linux/mmap_test.cpp +++ b/libc/test/src/sys/mman/linux/mmap_test.cpp @@ -17,6 +17,8 @@ using __llvm_libc::testing::ErrnoSetterMatcher::Fails; using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; +namespace __llvm_libc { + TEST(MMapTest, NoError) { size_t alloc_size = 128; llvmlibc_errno = 0; @@ -41,3 +43,5 @@ EXPECT_THAT(__llvm_libc::munmap(0, 0), Fails(EINVAL)); } + +} // namespace __llvm_libc diff --git a/libc/test/src/threads/mtx_test.cpp b/libc/test/src/threads/mtx_test.cpp --- a/libc/test/src/threads/mtx_test.cpp +++ b/libc/test/src/threads/mtx_test.cpp @@ -14,6 +14,8 @@ #include "src/threads/thrd_join.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + constexpr int START = 0; constexpr int MAX = 10000; @@ -114,3 +116,5 @@ __llvm_libc::thrd_join(&thread, &retval); ASSERT_EQ(retval, 0); } + +} // namespace __llvm_libc diff --git a/libc/test/src/threads/thrd_test.cpp b/libc/test/src/threads/thrd_test.cpp --- a/libc/test/src/threads/thrd_test.cpp +++ b/libc/test/src/threads/thrd_test.cpp @@ -11,6 +11,8 @@ #include "src/threads/thrd_join.h" #include "utils/UnitTest/Test.h" +namespace __llvm_libc { + static constexpr int thread_count = 1000; static int counter = 0; static int thread_func(void *) { @@ -50,3 +52,5 @@ ASSERT_EQ(retval, i); } } + +} // namespace __llvm_libc diff --git a/libc/test/src/unistd/write_test.cpp b/libc/test/src/unistd/write_test.cpp --- a/libc/test/src/unistd/write_test.cpp +++ b/libc/test/src/unistd/write_test.cpp @@ -12,6 +12,8 @@ #include "utils/UnitTest/Test.h" #include "utils/testutils/FDReader.h" +namespace __llvm_libc { + TEST(UniStd, WriteBasic) { using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; constexpr const char *hello = "hello"; @@ -27,3 +29,5 @@ EXPECT_THAT(__llvm_libc::write(1, reinterpret_cast(-1), 1), Fails(EFAULT)); } + +} // namespace __llvm_libc