summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-11-24 22:42:03 +0000
committerEric Fiselier <eric@efcs.ca>2014-11-24 22:42:03 +0000
commitd872a693db85819dc16fca2a7db75c03c7d17f15 (patch)
tree81e988c76434fc2c3a738f530203616f892cca9f /test
parent30ad829825ee45cab4bc132e5145b2cb7eef4c45 (diff)
[libcxxabi] Refactor building and testing libc++abi without threads
Summary: This patch adds CMake support for building and testing libc++abi without threads. 1. Add `LIBCXXABI_ENABLE_THREADS` option to CMake. 2. Propagate `LIBCXXABI_ENABLE_THREADS` to lit via lit.site.cfg.in 3. Configure tests for `LIBCXXABI_ENABLE_THREADS=OFF Currently the test suite does not work when libc++abi is built without threads because that information does not propagate to the test suite. Reviewers: danalbert, mclow.lists, jroelofs Reviewed By: jroelofs Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6393 git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@222702 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/lit.cfg12
-rw-r--r--test/lit.site.cfg.in1
-rw-r--r--test/test_exception_storage.cpp5
-rw-r--r--test/test_guard.cpp8
5 files changed, 25 insertions, 2 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1383cd7..57468dc 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -10,6 +10,7 @@ set(LIBCXXABI_COMPILER ${CMAKE_CXX_COMPILER})
set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
set(LIBCXXABI_BINARY_DIR ${CMAKE_BINARY_DIR})
pythonize_bool(LIBCXXABI_ENABLE_SHARED)
+pythonize_bool(LIBCXXABI_ENABLE_THREADS)
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")
diff --git a/test/lit.cfg b/test/lit.cfg
index 2d7c403..20d5822 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -199,6 +199,12 @@ if enable_shared is None:
if enable_shared is None:
lit_config.fatal("enable_shared must be defined")
+enable_threads = lit_config.params.get('enable_threads', None)
+if enable_threads is None:
+ enable_threads = getattr(config, 'enable_threads', None)
+ if enable_threads is None:
+ lit_config.fatal('enable_threads must be defined')
+
llvm_unwinder = getattr(config, 'llvm_unwinder', None)
if llvm_unwinder is None:
lit_config.fatal("llvm_unwinder must be defined")
@@ -223,7 +229,9 @@ if link_flags_str is None:
elif sys.platform.startswith('linux'):
if not llvm_unwinder:
link_flags += ['-lgcc_eh']
- link_flags += ['-lc', '-lm', '-lpthread']
+ link_flags += ['-lc', '-lm']
+ if enable_threads:
+ link_flags += ['-lpthread']
if llvm_unwinder:
link_flags += ['-lunwind', '-ldl']
else:
@@ -236,6 +244,8 @@ if link_flags_str is not None:
link_flags += shlex.split(link_flags_str)
# Configure extra compiler flags.
+if not enable_threads:
+ compile_flags += ['-DLIBCXXABI_HAS_NO_THREADS=1']
# Always disable timed test when using LIT since the output gets lost and since
# using the timer requires <chrono> as a dependancy.
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index bb62387..9753e1d 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -6,6 +6,7 @@ config.python_executable = "@PYTHON_EXECUTABLE@"
config.enable_shared = @LIBCXXABI_ENABLE_SHARED@
config.libcxx_includes = "@LIBCXXABI_LIBCXX_INCLUDES@"
config.llvm_unwinder = @LIBCXXABI_USE_LLVM_UNWINDER@
+config.enable_threads = @LIBCXXABI_ENABLE_THREADS@
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
# Let the main config do the real work.
diff --git a/test/test_exception_storage.cpp b/test/test_exception_storage.cpp
index f1e2fb5..0d5deaa 100644
--- a/test/test_exception_storage.cpp
+++ b/test/test_exception_storage.cpp
@@ -56,7 +56,10 @@ int main ( int argc, char *argv [] ) {
#if LIBCXXABI_HAS_NO_THREADS
size_t thread_globals;
- retVal = thread_code(&thread_globals) != 0;
+ // Check that __cxa_get_globals() is not NULL.
+ if (thread_code(&thread_globals) == 0) {
+ retVal = 1;
+ }
#else
// Make the threads, let them run, and wait for them to finish
for ( int i = 0; i < NUMTHREADS; ++i )
diff --git a/test/test_guard.cpp b/test/test_guard.cpp
index 96af56a..41ff794 100644
--- a/test/test_guard.cpp
+++ b/test/test_guard.cpp
@@ -7,10 +7,14 @@
//
//===----------------------------------------------------------------------===//
+#include "../src/config.h"
#include "cxxabi.h"
#include <cassert>
+
+#if !LIBCXXABI_HAS_NO_THREADS
#include <thread>
+#endif
// Ensure that we initialize each variable once and only once.
namespace test1 {
@@ -72,6 +76,7 @@ namespace test3 {
}
}
+#if !LIBCXXABI_HAS_NO_THREADS
// A simple thread test of two threads racing to initialize a variable. This
// isn't guaranteed to catch any particular threading problems.
namespace test4 {
@@ -123,12 +128,15 @@ namespace test5 {
assert(run_count == 1);
}
}
+#endif /* LIBCXXABI_HAS_NO_THREADS */
int main()
{
test1::test();
test2::test();
test3::test();
+#if !LIBCXXABI_HAS_NO_THREADS
test4::test();
test5::test();
+#endif
}