[compiler-rt] r223480 - [LSan] Rewrite the test from r223419 to not use C++11.
Sergey Matveev
earthdok at google.com
Fri Dec 5 09:21:43 PST 2014
Author: smatveev
Date: Fri Dec 5 11:21:43 2014
New Revision: 223480
URL: http://llvm.org/viewvc/llvm-project?rev=223480&view=rev
Log:
[LSan] Rewrite the test from r223419 to not use C++11.
This was causing build failures on llvm-clang-lld-x86_64-centos-6.5 for some
reason. Anyway, the new way is better because we no longer rely on std::thread
implementation details.
Modified:
compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc
Modified: compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc?rev=223480&r1=223479&r2=223480&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc Fri Dec 5 11:21:43 2014
@@ -1,15 +1,32 @@
// Regression test for http://llvm.org/bugs/show_bug.cgi?id=21621
// This test relies on timing between threads, so any failures will be flaky.
// RUN: LSAN_BASE="use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -std=c++11 -o %t
+// RUN: %clangxx_lsan %s -o %t
// RUN: %run %t
-#include <thread>
-#include <chrono>
+#include <assert.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <unistd.h>
-void func() {
- std::this_thread::sleep_for(std::chrono::milliseconds(500));
+void *func(void *arg) {
+ sleep(1);
+ free(arg);
+ return 0;
+}
+
+void create_detached_thread() {
+ pthread_t thread_id;
+ pthread_attr_t attr;
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ void *arg = malloc(1337);
+ assert(arg);
+ int res = pthread_create(&thread_id, &attr, func, arg);
+ assert(res == 0);
}
int main() {
- std::thread(func).detach();
+ create_detached_thread();
}
More information about the llvm-commits
mailing list