+add_subdirectory(pthread)
add_subdirectory(stdlib)
add_subdirectory(threads)
--- /dev/null
+add_libc_integration_test_suite(libc-pthread-integration-tests)
+
+add_integration_test(
+ pthread_mutex_test
+ SUITE
+ libc-pthread-integration-tests
+ SRCS
+ pthread_mutex_test.cpp
+ LOADER
+ libc.loader.linux.crt1
+ DEPENDS
+ libc.include.pthread
+ libc.src.errno.errno
+ libc.src.pthread.pthread_mutex_destroy
+ libc.src.pthread.pthread_mutex_init
+ libc.src.pthread.pthread_mutex_lock
+ libc.src.pthread.pthread_mutex_unlock
+ libc.src.pthread.pthread_create
+ libc.src.pthread.pthread_join
+)
+
+add_integration_test(
+ pthread_test
+ SUITE
+ libc-pthread-integration-tests
+ SRCS
+ pthread_test.cpp
+ LOADER
+ libc.loader.linux.crt1
+ DEPENDS
+ libc.include.pthread
+ libc.src.pthread.pthread_create
+ libc.src.pthread.pthread_join
+)
-//===-- Unittests for pthread_mutex_t -------------------------------------===//
+//===-- Tests for pthread_mutex_t -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
#include "src/pthread/pthread_create.h"
#include "src/pthread/pthread_join.h"
-#include "utils/UnitTest/Test.h"
+#include "utils/IntegrationTest/test.h"
#include <pthread.h>
return nullptr;
}
-TEST(LlvmLibcMutexTest, RelayCounter) {
+void relay_counter() {
ASSERT_EQ(__llvm_libc::pthread_mutex_init(&mutex, nullptr), 0);
// The idea of this test is that two competing threads will update
return nullptr;
}
-TEST(LlvmLibcMutexTest, WaitAndStep) {
+void wait_and_step() {
ASSERT_EQ(__llvm_libc::pthread_mutex_init(&start_lock, nullptr), 0);
ASSERT_EQ(__llvm_libc::pthread_mutex_init(&step_lock, nullptr), 0);
return nullptr;
}
-TEST(LlvmLibcMutexTest, MultipleWaiters) {
+void multiple_waiters() {
__llvm_libc::pthread_mutex_init(&multiple_waiter_lock, nullptr);
__llvm_libc::pthread_mutex_init(&counter_lock, nullptr);
__llvm_libc::pthread_mutex_destroy(&multiple_waiter_lock);
__llvm_libc::pthread_mutex_destroy(&counter_lock);
}
+
+int main() {
+ relay_counter();
+ wait_and_step();
+ multiple_waiters();
+ return 0;
+}
-//===-- Unittests for pthread_t -------------------------------------------===//
+//===-- Tests for pthread_t -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
#include "src/pthread/pthread_create.h"
#include "src/pthread/pthread_join.h"
-#include "utils/UnitTest/Test.h"
+#include "utils/IntegrationTest/test.h"
#include <pthread.h>
return nullptr;
}
-TEST(LlvmLibcThreadTest, CreateAndJoin) {
+void create_and_join() {
for (counter = 0; counter <= thread_count;) {
pthread_t thread;
int old_counter_val = counter;
static void *return_arg(void *arg) { return arg; }
-TEST(LlvmLibcThreadTest, SpawnAndJoin) {
+void spawn_and_join() {
pthread_t thread_list[thread_count];
int args[thread_count];
ASSERT_EQ(*reinterpret_cast<int *>(retval), i);
}
}
+
+int main() {
+ create_and_join();
+ spawn_and_join();
+ return 0;
+}
libc.src.pthread.pthread_mutexattr_setrobust
libc.src.pthread.pthread_mutexattr_settype
)
-
-add_libc_unittest(
- pthread_mutex_test
- SUITE
- libc_pthread_unittests
- SRCS
- pthread_mutex_test.cpp
- DEPENDS
- libc.include.pthread
- libc.src.errno.errno
- libc.src.pthread.pthread_mutex_destroy
- libc.src.pthread.pthread_mutex_init
- libc.src.pthread.pthread_mutex_lock
- libc.src.pthread.pthread_mutex_unlock
- libc.src.pthread.pthread_create
- libc.src.pthread.pthread_join
-)
-
-add_libc_unittest(
- pthread_test
- SUITE
- libc_pthread_unittests
- SRCS
- pthread_test.cpp
- DEPENDS
- libc.include.pthread
- libc.src.pthread.pthread_create
- libc.src.pthread.pthread_join
-)