Attempt to prevent flaky thread.mutex tests by once again increasing timing tolerances

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248993 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier 2015-10-01 08:34:37 +00:00
parent 9698ac5a68
commit d95ca09be4
13 changed files with 37 additions and 28 deletions

View File

@ -35,10 +35,10 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif
std::shared_timed_mutex m; std::shared_timed_mutex m;

View File

@ -38,10 +38,10 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif

View File

@ -38,13 +38,12 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif
void f1() void f1()
{ {
time_point t0 = Clock::now(); time_point t0 = Clock::now();

View File

@ -37,10 +37,10 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(25); ms Tolerance = ms(25);
#else #else
ms Tolerance = ms(75); ms Tolerance = ms(25 * 5);
#endif #endif

View File

@ -36,10 +36,10 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif
void f() void f()

View File

@ -37,10 +37,10 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif
void f() void f()

View File

@ -38,10 +38,10 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif

View File

@ -38,13 +38,12 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif
void f1() void f1()
{ {
time_point t0 = Clock::now(); time_point t0 = Clock::now();

View File

@ -22,6 +22,8 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
#include "test_macros.h"
std::shared_timed_mutex m; std::shared_timed_mutex m;
typedef std::chrono::system_clock Clock; typedef std::chrono::system_clock Clock;
@ -30,6 +32,13 @@ typedef Clock::duration duration;
typedef std::chrono::milliseconds ms; typedef std::chrono::milliseconds ms;
typedef std::chrono::nanoseconds ns; typedef std::chrono::nanoseconds ns;
#if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(200);
#else
ms Tolerance = ms(200 * 5);
#endif
void f() void f()
{ {
time_point t0 = Clock::now(); time_point t0 = Clock::now();
@ -41,7 +50,7 @@ void f()
time_point t1 = Clock::now(); time_point t1 = Clock::now();
m.unlock_shared(); m.unlock_shared();
ns d = t1 - t0 - ms(250); ns d = t1 - t0 - ms(250);
assert(d < ms(200)); // within 200ms assert(d < Tolerance); // within tolerance
} }
int main() int main()

View File

@ -38,13 +38,12 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif
void f1() void f1()
{ {
time_point t0 = Clock::now(); time_point t0 = Clock::now();

View File

@ -38,13 +38,12 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif
void f1() void f1()
{ {
time_point t0 = Clock::now(); time_point t0 = Clock::now();

View File

@ -38,13 +38,12 @@ ms WaitTime = ms(250);
// Thread sanitizer causes more overhead and will sometimes cause this test // 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 // to fail. To prevent this we give Thread sanitizer more time to complete the
// test. // test.
#if !TEST_HAS_FEATURE(thread_sanitizer) #if !defined(TEST_HAS_SANITIZERS)
ms Tolerance = ms(50); ms Tolerance = ms(50);
#else #else
ms Tolerance = ms(100); ms Tolerance = ms(50 * 5);
#endif #endif
void f1() void f1()
{ {
time_point t0 = Clock::now(); time_point t0 = Clock::now();

View File

@ -96,4 +96,9 @@ template <unsigned> struct static_assert_check {};
#define TEST_HAS_NO_EXCEPTIONS #define TEST_HAS_NO_EXCEPTIONS
#endif #endif
#if TEST_HAS_FEATURE(address_sanitizer) || TEST_HAS_FEATURE(memory_sanitizer) || \
TEST_HAS_FEATURE(thread_sanitizer)
#define TEST_HAS_SANITIZERS
#endif
#endif // SUPPORT_TEST_MACROS_HPP #endif // SUPPORT_TEST_MACROS_HPP