[libc-commits] [libc] 9b9ff63 - [libc][NFC] Make thread_detach_test an integration test.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Sun Jul 10 23:49:51 PDT 2022


Author: Siva Chandra Reddy
Date: 2022-07-11T06:48:54Z
New Revision: 9b9ff63b03eae1027aa75d9c2b37b98b10a49c66

URL: https://github.com/llvm/llvm-project/commit/9b9ff63b03eae1027aa75d9c2b37b98b10a49c66
DIFF: https://github.com/llvm/llvm-project/commit/9b9ff63b03eae1027aa75d9c2b37b98b10a49c66.diff

LOG: [libc][NFC] Make thread_detach_test an integration test.

This is simple switch from a unittest to an integration test. It is
being done as a preparatory step to adding TLS support to thread
creation. TLS setup and initialization is tightly coupled with the
loader and hence all thread related tests should be integration tests.

Added: 
    libc/test/integration/src/__support/CMakeLists.txt
    libc/test/integration/src/__support/threads/CMakeLists.txt
    libc/test/integration/src/__support/threads/thread_detach_test.cpp

Modified: 
    libc/test/integration/src/CMakeLists.txt
    libc/test/src/__support/CMakeLists.txt

Removed: 
    libc/test/src/__support/threads/CMakeLists.txt
    libc/test/src/__support/threads/thread_detach_test.cpp


################################################################################
diff  --git a/libc/test/integration/src/CMakeLists.txt b/libc/test/integration/src/CMakeLists.txt
index f175dc4f23bcd..ca63cf24d6c51 100644
--- a/libc/test/integration/src/CMakeLists.txt
+++ b/libc/test/integration/src/CMakeLists.txt
@@ -1,3 +1,4 @@
+add_subdirectory(__support)
 add_subdirectory(pthread)
 add_subdirectory(stdlib)
 add_subdirectory(threads)

diff  --git a/libc/test/integration/src/__support/CMakeLists.txt b/libc/test/integration/src/__support/CMakeLists.txt
new file mode 100644
index 0000000000000..7c853ff10259f
--- /dev/null
+++ b/libc/test/integration/src/__support/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(threads)

diff  --git a/libc/test/src/__support/threads/CMakeLists.txt b/libc/test/integration/src/__support/threads/CMakeLists.txt
similarity index 61%
rename from libc/test/src/__support/threads/CMakeLists.txt
rename to libc/test/integration/src/__support/threads/CMakeLists.txt
index 528e9269b2abe..cbf117b7ef40e 100644
--- a/libc/test/src/__support/threads/CMakeLists.txt
+++ b/libc/test/integration/src/__support/threads/CMakeLists.txt
@@ -3,11 +3,16 @@ if(NOT (TARGET libc.src.__support.threads.thread AND
   return()
 endif()
 
-add_libc_unittest(
+add_libc_integration_test_suite(libc-support-threads-integration-tests)
+
+add_integration_test(
   thread_detach_test
   SUITE
+    libc-support-threads-integration-tests
   SRCS
     thread_detach_test.cpp
+  LOADER
+    libc.loader.linux.crt1
   DEPENDS
     libc.src.__support.threads.mutex
     libc.src.__support.threads.thread

diff  --git a/libc/test/src/__support/threads/thread_detach_test.cpp b/libc/test/integration/src/__support/threads/thread_detach_test.cpp
similarity index 85%
rename from libc/test/src/__support/threads/thread_detach_test.cpp
rename to libc/test/integration/src/__support/threads/thread_detach_test.cpp
index 186cb8fedaf25..8358998b4ef03 100644
--- a/libc/test/src/__support/threads/thread_detach_test.cpp
+++ b/libc/test/integration/src/__support/threads/thread_detach_test.cpp
@@ -1,4 +1,4 @@
-//===-- Unittests for thrd_t ----------------------------------------------===//
+//===-- Tests for thread detach functionality -----------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
 
 #include "src/__support/threads/mutex.h"
 #include "src/__support/threads/thread.h"
-#include "utils/UnitTest/Test.h"
+#include "utils/IntegrationTest/test.h"
 
 __llvm_libc::Mutex mutex(false, false, false);
 
@@ -18,7 +18,7 @@ int func(void *) {
   return 0;
 }
 
-TEST(LlvmLibcTestThreadTest, DetachSimpleTest) {
+void detach_simple_test() {
   mutex.lock();
   __llvm_libc::Thread th;
   th.run(func, nullptr, nullptr, 0);
@@ -32,7 +32,7 @@ TEST(LlvmLibcTestThreadTest, DetachSimpleTest) {
   mutex.unlock();
 }
 
-TEST(LlvmLibcTestThreadTest, DetachCleanupTest) {
+void detach_cleanup_test() {
   mutex.lock();
   __llvm_libc::Thread th;
   ASSERT_EQ(0, th.run(func, nullptr, nullptr, 0));
@@ -49,3 +49,9 @@ TEST(LlvmLibcTestThreadTest, DetachCleanupTest) {
   // resources.
   ASSERT_EQ(th.detach(), int(__llvm_libc::DetachType::CLEANUP));
 }
+
+int main() {
+  detach_simple_test();
+  detach_cleanup_test();
+  return 0;
+}

diff  --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 97ae33dd13b83..3e25b3303ea31 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -79,4 +79,3 @@ add_custom_command(TARGET libc_str_to_float_comparison_test
 add_subdirectory(CPP)
 add_subdirectory(File)
 add_subdirectory(OSUtil)
-add_subdirectory(threads)


        


More information about the libc-commits mailing list