[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.
This commit is contained in:
Siva Chandra Reddy 2022-07-11 06:37:36 +00:00
parent fea52ac541
commit 9b9ff63b03
5 changed files with 18 additions and 6 deletions

View File

@ -1,3 +1,4 @@
add_subdirectory(__support)
add_subdirectory(pthread)
add_subdirectory(stdlib)
add_subdirectory(threads)

View File

@ -0,0 +1 @@
add_subdirectory(threads)

View File

@ -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

View File

@ -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;
}

View File

@ -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)