This patch overhalls the libc++ test format/configuration in order to fully support modules. By "fully support" I mean get almost all of the tests passing. The main hurdle for doing this is handling tests that `#define _LIBCPP_FOO` macros to test a different configuration. This patch deals with these tests in the following ways: 1. For tests that define single `_LIBCPP_ABI_FOO` macros have been annotated with `// MODULES_DEFINES: _LIBCPP_ABI_FOO`. This allows the test suite to define the macro on the command line so it uses a different set of modules. 2. Tests for libc++'s debug mode (which define custom `_LIBCPP_ASSERT`) are automatically detected by the test suite and are compiled and run with modules disabled. This patch also cleans up how the `CXXCompiler` helper class handles enabling/disabling language features. NOTE: This patch uses `LIT` features which were only committed to LLVM today. If this patch breaks running the libc++ tests you probably need to update LLVM. llvm-svn: 288728
67 lines
1.4 KiB
C++
67 lines
1.4 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// UNSUPPORTED: libcpp-has-no-threads
|
|
// UNSUPPORTED: c++03, c++98, c++11
|
|
|
|
// FLAKY_TEST.
|
|
|
|
// <shared_mutex>
|
|
|
|
// class shared_timed_mutex;
|
|
|
|
// void lock();
|
|
|
|
#include <shared_mutex>
|
|
#include <thread>
|
|
#include <cstdlib>
|
|
#include <cassert>
|
|
|
|
#include "test_macros.h"
|
|
|
|
std::shared_timed_mutex m;
|
|
|
|
typedef std::chrono::system_clock Clock;
|
|
typedef Clock::time_point time_point;
|
|
typedef Clock::duration duration;
|
|
typedef std::chrono::milliseconds ms;
|
|
typedef std::chrono::nanoseconds ns;
|
|
|
|
|
|
ms WaitTime = ms(250);
|
|
|
|
// Thread sanitizer causes more overhead and will sometimes cause this test
|
|
// to fail. To prevent this we give Thread sanitizer more time to complete the
|
|
// test.
|
|
#if !TEST_HAS_FEATURE(thread_sanitizer)
|
|
ms Tolerance = ms(50);
|
|
#else
|
|
ms Tolerance = ms(100);
|
|
#endif
|
|
|
|
|
|
void f()
|
|
{
|
|
time_point t0 = Clock::now();
|
|
m.lock();
|
|
time_point t1 = Clock::now();
|
|
m.unlock();
|
|
ns d = t1 - t0 - ms(250);
|
|
assert(d < ms(50)); // within 50ms
|
|
}
|
|
|
|
int main()
|
|
{
|
|
m.lock();
|
|
std::thread t(f);
|
|
std::this_thread::sleep_for(ms(250));
|
|
m.unlock();
|
|
t.join();
|
|
}
|