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
172172 done
173173
174174valgrind : $(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 )
176176
177177if OS_LINUX
178178abicheck :
Original file line number Diff line number Diff line change 5151#include "TestSuite.h"
5252
5353
54+ static int test_flags ;
55+
56+
5457#define TEST_VERBOSE (1 << 0)
5558#define TEST_NOFORK (1 << 1)
5659#define TEST_HELPONLY (1 << 2)
5760#define TEST_NOTHREADS (1 << 3)
5861#define TEST_DEBUGOUTPUT (1 << 4)
5962#define TEST_TRACE (1 << 5)
63+ #define TEST_VALGRIND (1 << 6)
6064
6165
6266#define NANOSEC_PER_SEC 1000000000UL
@@ -296,6 +300,13 @@ TestSuite_Init (TestSuite *suite,
296300 suite -> testname = strdup (argv [++ i ]);
297301 }
298302 }
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 ;
299310}
300311
301312
@@ -853,3 +864,17 @@ TestSuite_Destroy (TestSuite *suite)
853864 free (suite -> prgname );
854865 free (suite -> testname );
855866}
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" {
182182 } \
183183 } while (0)
184184
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+
185194#define MAX_TEST_NAME_LENGTH 500
186195
187196
@@ -237,6 +246,9 @@ void TestSuite_AddFull (TestSuite *suite,
237246int TestSuite_Run (TestSuite * suite );
238247void TestSuite_Destroy (TestSuite * suite );
239248
249+ int test_suite_debug_output (void );
250+ int test_suite_valgrind (void );
251+
240252#ifdef __cplusplus
241253}
242254#endif
Original file line number Diff line number Diff line change @@ -635,7 +635,7 @@ test_seed_list (bool rs,
635635
636636 /* discovery should be quick despite down servers, say < 100ms */
637637 duration_usec = bson_get_monotonic_time () - start ;
638- ASSERT_CMPINT ((int ) (duration_usec / 1000 ), < , 100 );
638+ ASSERT_CMPTIME ((int ) (duration_usec / 1000 ), 100 );
639639
640640 bson_destroy (& reply );
641641
@@ -672,8 +672,8 @@ test_seed_list (bool rs,
672672 /* client waited for min heartbeat to pass before reconnecting, then
673673 * reconnected quickly despite down servers, say < 100ms later */
674674 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 );
677677
678678 bson_destroy (& reply );
679679
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ test_mongoc_usleep_basic (void)
1212 _mongoc_usleep (50 * 1000 ); /* 50 ms */
1313 duration = bson_get_monotonic_time () - start ;
1414 ASSERT_CMPINT ((int ) duration , > , 0 );
15- ASSERT_CMPINT ((int ) duration , < , 200 * 1000 );
15+ ASSERT_CMPTIME ((int ) duration , 200 * 1000 );
1616}
1717
1818void
You can’t perform that action at this time.
0 commit comments