Skip to content

Commit 37e5c65

Browse files
committed
Make configurable the timing. Set 100ms for MacOs and 75ms for Linux on CircleCI.
1 parent 7585187 commit 37e5c65

File tree

9 files changed

+45
-66
lines changed

9 files changed

+45
-66
lines changed

circle.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ build_steps: &build_steps
4343
- run:
4444
name: Build
4545
command: |
46-
echo "using $TOOLSET : : $COMPILER : <cxxflags>-std=$CXXSTD ;" > ~/user-config.jam
46+
echo "using $TOOLSET : : $COMPILER : <cxxflags>-std=$CXXSTD <cxxflags>=$DEFINES ;" > ~/user-config.jam
4747
cd ../boost-root
4848
./b2 -j10 libs/thread/test toolset=$TOOLSET
4949
@@ -66,90 +66,103 @@ jobs:
6666
- TOOLSET: "gcc"
6767
- COMPILER: "g++"
6868
- CXXSTD: "c++11"
69+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
6970

7071
linux-g++-7-c++98:
7172
<<: *linux_build
7273
environment:
7374
- TOOLSET: "gcc"
7475
- COMPILER: "g++-7"
7576
- CXXSTD: "c++98"
77+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
7678

7779
linux-g++-7-c++11:
7880
<<: *linux_build
7981
environment:
8082
- TOOLSET: "gcc"
8183
- COMPILER: "g++-7"
8284
- CXXSTD: "c++11"
85+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
8386

8487
linux-g++-7-c++14:
8588
<<: *linux_build
8689
environment:
8790
- TOOLSET: "gcc"
8891
- COMPILER: "g++-7"
8992
- CXXSTD: "c++14"
93+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
9094

9195
linux-g++-7-c++1z:
9296
<<: *linux_build
9397
environment:
9498
- TOOLSET: "gcc"
9599
- COMPILER: "g++-7"
96100
- CXXSTD: "c++1z"
101+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
97102

98103
linux-clang++-4.0-c++98:
99104
<<: *linux_build
100105
environment:
101106
- TOOLSET: "clang"
102107
- COMPILER: "clang++-4.0"
103108
- CXXSTD: "c++98"
109+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
104110

105111
linux-clang++-4.0-c++11:
106112
<<: *linux_build
107113
environment:
108114
- TOOLSET: "clang"
109115
- COMPILER: "clang++-4.0"
110116
- CXXSTD: "c++11"
117+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
111118

112119
linux-clang++-4.0-c++14:
113120
<<: *linux_build
114121
environment:
115122
- TOOLSET: "clang"
116123
- COMPILER: "clang++-4.0"
117124
- CXXSTD: "c++14"
125+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
118126

119127
linux-clang++-4.0-c++1z:
120128
<<: *linux_build
121129
environment:
122130
- TOOLSET: "clang"
123131
- COMPILER: "clang++-4.0"
124132
- CXXSTD: "c++1z"
133+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
125134

126135
mac-clang++-c++98:
127136
<<: *mac_build
128137
environment:
129138
- TOOLSET: "clang"
130139
- COMPILER: "clang++"
131140
- CXXSTD: "c++98"
141+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=100"
132142

133143
mac-clang++-c++11:
134144
<<: *mac_build
135145
environment:
136146
- TOOLSET: "clang"
137147
- COMPILER: "clang++"
138148
- CXXSTD: "c++11"
149+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=100"
139150

140151
mac-clang++-c++14:
141152
<<: *mac_build
142153
environment:
143154
- TOOLSET: "clang"
144155
- COMPILER: "clang++"
145156
- CXXSTD: "c++14"
157+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=100"
146158

147159
mac-clang++-c++1z:
148160
<<: *mac_build
149161
environment:
150162
- TOOLSET: "clang"
151163
- COMPILER: "clang++"
152164
- CXXSTD: "c++1z"
165+
- DEFINES: "-DBOOST_THREAD_TEST_TIME_MS=75"
153166

154167
workflows:
155168
version: 2

test/sync/mutual_exclusion/locks/shared_lock/cons/try_to_lock_pass.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <boost/thread/shared_mutex.hpp>
2424
#include <boost/thread/thread.hpp>
2525
#include <boost/detail/lightweight_test.hpp>
26+
#include "../../../../../timming.hpp"
2627

2728
boost::shared_mutex m;
2829

@@ -35,11 +36,8 @@ typedef boost::chrono::nanoseconds ns;
3536
#else
3637
#endif
3738

38-
#ifdef BOOST_THREAD_PLATFORM_WIN32
39-
const ms max_diff(250);
40-
#else
41-
const ms max_diff(75);
42-
#endif
39+
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
40+
4341

4442
void f()
4543
{
@@ -64,9 +62,7 @@ void f()
6462
}
6563
time_point t1 = Clock::now();
6664
ns d = t1 - t0 - ms(250);
67-
std::cout << "delta= " << d.count() << std::endl;
68-
std::cout << "max= " << max_diff.count() << std::endl;
69-
BOOST_TEST(d < max_diff);
65+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
7066
#else
7167
// time_point t0 = Clock::now();
7268
// {

test/sync/mutual_exclusion/locks/upgrade_lock/cons/duration_pass.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <boost/thread/thread.hpp>
2727
#include <boost/detail/lightweight_test.hpp>
2828
#include <boost/chrono/chrono_io.hpp>
29+
#include "../../../../../timming.hpp"
2930

3031
boost::shared_mutex m;
3132

@@ -35,11 +36,7 @@ typedef Clock::duration duration;
3536
typedef boost::chrono::milliseconds ms;
3637
typedef boost::chrono::nanoseconds ns;
3738

38-
#ifdef BOOST_THREAD_PLATFORM_WIN32
39-
const ms max_diff(250);
40-
#else
41-
const ms max_diff(75);
42-
#endif
39+
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
4340

4441
void f1()
4542
{
@@ -48,9 +45,7 @@ void f1()
4845
BOOST_TEST(lk.owns_lock() == true);
4946
time_point t1 = Clock::now();
5047
ns d = t1 - t0 - ms(250);
51-
std::cout << "delta= " << d.count() << std::endl;
52-
std::cout << "max= " << max_diff.count() << std::endl;
53-
BOOST_TEST(d < max_diff);
48+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
5449
}
5550

5651
void f2()
@@ -60,7 +55,7 @@ void f2()
6055
BOOST_TEST(lk.owns_lock() == false);
6156
time_point t1 = Clock::now();
6257
ns d = t1 - t0 - ms(250);
63-
BOOST_TEST(d < max_diff);
58+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
6459
}
6560

6661
int main()

test/sync/mutual_exclusion/mutex/try_lock_pass.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <boost/thread/mutex.hpp>
2222
#include <boost/thread/thread.hpp>
2323
#include <boost/detail/lightweight_test.hpp>
24+
#include "../../../timming.hpp"
2425

2526

2627
boost::mutex m;
@@ -33,11 +34,8 @@ typedef boost::chrono::milliseconds ms;
3334
typedef boost::chrono::nanoseconds ns;
3435
#endif
3536

36-
#ifdef BOOST_THREAD_PLATFORM_WIN32
37-
const ms max_diff(250);
38-
#else
39-
const ms max_diff(75);
40-
#endif
37+
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
38+
4139

4240
void f()
4341
{
@@ -51,9 +49,7 @@ void f()
5149
time_point t1 = Clock::now();
5250
m.unlock();
5351
ns d = t1 - t0 - ms(250);
54-
std::cout << "delta= " << d.count() << std::endl;
55-
std::cout << "max= " << max_diff.count() << std::endl;
56-
BOOST_TEST(d < max_diff);
52+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
5753
#else
5854
//time_point t0 = Clock::now();
5955
//BOOST_TEST(!m.try_lock());

test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_for_pass.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <boost/thread/recursive_mutex.hpp>
2323
#include <boost/thread/thread.hpp>
2424
#include <boost/detail/lightweight_test.hpp>
25+
#include "../../../timming.hpp"
2526

2627
#if defined BOOST_THREAD_USES_CHRONO
2728

@@ -34,11 +35,8 @@ typedef Clock::duration duration;
3435
typedef boost::chrono::milliseconds ms;
3536
typedef boost::chrono::nanoseconds ns;
3637

37-
#ifdef BOOST_THREAD_PLATFORM_WIN32
38-
const ms max_diff(250);
39-
#else
40-
const ms max_diff(75);
41-
#endif
38+
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
39+
4240

4341
void f1()
4442
{
@@ -49,7 +47,7 @@ void f1()
4947
m.unlock();
5048
m.unlock();
5149
ns d = t1 - t0 - ms(250);
52-
BOOST_TEST(d < max_diff);
50+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
5351
}
5452

5553
void f2()
@@ -58,7 +56,7 @@ void f2()
5856
BOOST_TEST(m.try_lock_for(ms(250)) == false);
5957
time_point t1 = Clock::now();
6058
ns d = t1 - t0 - ms(250);
61-
BOOST_TEST(d < max_diff);
59+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
6260
}
6361

6462
int main()

test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_pass.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <boost/thread/recursive_mutex.hpp>
2222
#include <boost/thread/thread.hpp>
2323
#include <boost/detail/lightweight_test.hpp>
24+
#include "../../../timming.hpp"
2425

2526

2627

@@ -35,11 +36,8 @@ typedef boost::chrono::nanoseconds ns;
3536
#else
3637
#endif
3738

38-
#ifdef BOOST_THREAD_PLATFORM_WIN32
39-
const ms max_diff(250);
40-
#else
41-
const ms max_diff(75);
42-
#endif
39+
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
40+
4341

4442
void f()
4543
{
@@ -55,9 +53,7 @@ void f()
5553
m.unlock();
5654
m.unlock();
5755
ns d = t1 - t0 - ms(250);
58-
std::cout << "delta= " << d.count() << std::endl;
59-
std::cout << "max= " << max_diff.count() << std::endl;
60-
BOOST_TEST(d < max_diff);
56+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
6157
#else
6258
//time_point t0 = Clock::now();
6359
//BOOST_TEST(!m.try_lock());

test/sync/mutual_exclusion/shared_mutex/try_lock_pass.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <boost/thread/shared_mutex.hpp>
2222
#include <boost/thread/thread.hpp>
2323
#include <boost/detail/lightweight_test.hpp>
24+
#include "../../../timming.hpp"
2425

2526
boost::shared_mutex m;
2627

@@ -33,11 +34,7 @@ typedef boost::chrono::nanoseconds ns;
3334
#else
3435
#endif
3536

36-
#ifdef BOOST_THREAD_PLATFORM_WIN32
37-
const ms max_diff(250);
38-
#else
39-
const ms max_diff(75);
40-
#endif
37+
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
4138

4239
void f()
4340
{
@@ -51,9 +48,7 @@ void f()
5148
time_point t1 = Clock::now();
5249
m.unlock();
5350
ns d = t1 - t0 - ms(250);
54-
std::cout << "delta= " << d.count() << std::endl;
55-
std::cout << "max= " << max_diff.count() << std::endl;
56-
BOOST_TEST(d < max_diff);
51+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
5752
#else
5853
//time_point t0 = Clock::now();
5954
//BOOST_TEST(!m.try_lock());

test/sync/mutual_exclusion/timed_mutex/lock_pass.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <boost/thread/mutex.hpp>
2222
#include <boost/thread/thread.hpp>
2323
#include <boost/detail/lightweight_test.hpp>
24+
#include "../../../timming.hpp"
2425

2526
boost::timed_mutex m;
2627

@@ -33,11 +34,7 @@ typedef boost::chrono::nanoseconds ns;
3334
#else
3435
#endif
3536

36-
#ifdef BOOST_THREAD_PLATFORM_WIN32
37-
const ms max_diff(250);
38-
#else
39-
const ms max_diff(75);
40-
#endif
37+
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
4138

4239
void f()
4340
{
@@ -47,9 +44,7 @@ void f()
4744
time_point t1 = Clock::now();
4845
m.unlock();
4946
ns d = t1 - t0 - ms(250);
50-
std::cout << "delta= " << d.count() << std::endl;
51-
std::cout << "max= " << max_diff.count() << std::endl;
52-
BOOST_TEST(d < max_diff);
47+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
5348
#else
5449
//time_point t0 = Clock::now();
5550
m.lock();

test/sync/mutual_exclusion/timed_mutex/try_lock_for_pass.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <boost/thread/mutex.hpp>
2323
#include <boost/thread/thread.hpp>
2424
#include <boost/detail/lightweight_test.hpp>
25+
#include "../../../timming.hpp"
2526

2627
#if defined BOOST_THREAD_USES_CHRONO
2728

@@ -33,11 +34,7 @@ typedef Clock::duration duration;
3334
typedef boost::chrono::milliseconds ms;
3435
typedef boost::chrono::nanoseconds ns;
3536

36-
#ifdef BOOST_THREAD_PLATFORM_WIN32
37-
const ms max_diff(250);
38-
#else
39-
const ms max_diff(75);
40-
#endif
37+
const ms max_diff(BOOST_THREAD_TEST_TIME_MS);
4138

4239
void f1()
4340
{
@@ -46,9 +43,7 @@ void f1()
4643
time_point t1 = Clock::now();
4744
m.unlock();
4845
ns d = t1 - t0 - ms(250);
49-
std::cout << "delta= " << d.count() << std::endl;
50-
std::cout << "max= " << max_diff.count() << std::endl;
51-
BOOST_TEST(d < max_diff);
46+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
5247
}
5348

5449
void f2()
@@ -57,7 +52,7 @@ void f2()
5752
BOOST_TEST(m.try_lock_for(ms(250)) == false);
5853
time_point t1 = Clock::now();
5954
ns d = t1 - t0 - ms(250);
60-
BOOST_TEST(d < max_diff);
55+
BOOST_THREAD_TEST_IT(d, ns(max_diff));
6156
}
6257

6358
int main()

0 commit comments

Comments
 (0)