File tree Expand file tree Collapse file tree 5 files changed +42
-5
lines changed Expand file tree Collapse file tree 5 files changed +42
-5
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ endif
172
172
done
173
173
174
174
valgrind : $(TEST_PROGS )
175
- $(LIBTOOL ) --mode=execute valgrind --leak-check=full --suppressions=$(srcdir ) /valgrind.suppressions ./test-libmongoc $(TEST_ARGS )
175
+ MONGOC_TEST_VALGRIND=on $(LIBTOOL ) --mode=execute valgrind --leak-check=full --suppressions=$(srcdir ) /valgrind.suppressions ./test-libmongoc $(TEST_ARGS )
176
176
177
177
if OS_LINUX
178
178
abicheck :
Original file line number Diff line number Diff line change 51
51
#include "TestSuite.h"
52
52
53
53
54
+ static int test_flags ;
55
+
56
+
54
57
#define TEST_VERBOSE (1 << 0)
55
58
#define TEST_NOFORK (1 << 1)
56
59
#define TEST_HELPONLY (1 << 2)
57
60
#define TEST_NOTHREADS (1 << 3)
58
61
#define TEST_DEBUGOUTPUT (1 << 4)
59
62
#define TEST_TRACE (1 << 5)
63
+ #define TEST_VALGRIND (1 << 6)
60
64
61
65
62
66
#define NANOSEC_PER_SEC 1000000000UL
@@ -296,6 +300,13 @@ TestSuite_Init (TestSuite *suite,
296
300
suite -> testname = strdup (argv [++ i ]);
297
301
}
298
302
}
303
+
304
+ if (test_framework_getenv_bool ("MONGOC_TEST_VALGRIND" )) {
305
+ suite -> flags |= TEST_VALGRIND ;
306
+ }
307
+
308
+ /* HACK: copy flags to global var */
309
+ test_flags = suite -> flags ;
299
310
}
300
311
301
312
@@ -853,3 +864,17 @@ TestSuite_Destroy (TestSuite *suite)
853
864
free (suite -> prgname );
854
865
free (suite -> testname );
855
866
}
867
+
868
+
869
+ int
870
+ test_suite_debug_output (void )
871
+ {
872
+ return 0 != (test_flags & TEST_DEBUGOUTPUT );
873
+ }
874
+
875
+
876
+ int
877
+ test_suite_valgrind (void )
878
+ {
879
+ return 0 != (test_flags & TEST_VALGRIND );
880
+ }
Original file line number Diff line number Diff line change @@ -182,6 +182,15 @@ extern "C" {
182
182
} \
183
183
} while (0)
184
184
185
+ /* don't check durations when testing with valgrind */
186
+ #define ASSERT_CMPTIME (actual , maxduration ) \
187
+ do { \
188
+ if (!test_suite_valgrind ()) { \
189
+ ASSERT_CMPINT (actual, <, maxduration); \
190
+ }\
191
+ } while (0)
192
+
193
+
185
194
#define MAX_TEST_NAME_LENGTH 500
186
195
187
196
@@ -237,6 +246,9 @@ void TestSuite_AddFull (TestSuite *suite,
237
246
int TestSuite_Run (TestSuite * suite );
238
247
void TestSuite_Destroy (TestSuite * suite );
239
248
249
+ int test_suite_debug_output (void );
250
+ int test_suite_valgrind (void );
251
+
240
252
#ifdef __cplusplus
241
253
}
242
254
#endif
Original file line number Diff line number Diff line change @@ -635,7 +635,7 @@ test_seed_list (bool rs,
635
635
636
636
/* discovery should be quick despite down servers, say < 100ms */
637
637
duration_usec = bson_get_monotonic_time () - start ;
638
- ASSERT_CMPINT ((int ) (duration_usec / 1000 ), < , 100 );
638
+ ASSERT_CMPTIME ((int ) (duration_usec / 1000 ), 100 );
639
639
640
640
bson_destroy (& reply );
641
641
@@ -672,8 +672,8 @@ test_seed_list (bool rs,
672
672
/* client waited for min heartbeat to pass before reconnecting, then
673
673
* reconnected quickly despite down servers, say < 100ms later */
674
674
duration_usec = bson_get_monotonic_time () - start ;
675
- ASSERT_CMPINT ((int ) (duration_usec / 1000 ), < ,
676
- MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS + 100 );
675
+ ASSERT_CMPTIME ((int ) (duration_usec / 1000 ),
676
+ MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS + 100 );
677
677
678
678
bson_destroy (& reply );
679
679
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ test_mongoc_usleep_basic (void)
12
12
_mongoc_usleep (50 * 1000 ); /* 50 ms */
13
13
duration = bson_get_monotonic_time () - start ;
14
14
ASSERT_CMPINT ((int ) duration , > , 0 );
15
- ASSERT_CMPINT ((int ) duration , < , 200 * 1000 );
15
+ ASSERT_CMPTIME ((int ) duration , 200 * 1000 );
16
16
}
17
17
18
18
void
You can’t perform that action at this time.
0 commit comments