Skip to content

Commit 80d687b

Browse files
committed
Provide a way to extend test timeouts
Some hardware is really slow; let users set CMARK_TIMING_SCALE to multiply the timeouts by an arbitrary amount Signed-off-by: Keith Packard <keithp@keithp.com>
1 parent 2c223c4 commit 80d687b

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

api_test/main.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,13 @@ static void test_feed_across_line_ending(test_batch_runner *runner) {
942942
# include <sys/time.h>
943943
static struct timeval _before, _after;
944944
static int _timing;
945+
static int _timing_scale = 1;
946+
# define SETUP_TIMING() \
947+
do { \
948+
char *scale = getenv("CMARK_TIMING_SCALE"); \
949+
if (scale) \
950+
_timing_scale = atoi(scale); \
951+
} while (0)
945952
# define START_TIMING() \
946953
gettimeofday(&_before, NULL)
947954

@@ -952,10 +959,13 @@ static int _timing;
952959
} while (0)
953960

954961
# define TIMING _timing
962+
# define TIMING_SCALE _timing_scale
955963
#else
964+
# define SETUP_TIMING()
956965
# define START_TIMING()
957966
# define END_TIMING()
958967
# define TIMING 0
968+
# define TIMING_SCALE 1
959969
#endif
960970

961971
static void test_pathological_regressions(test_batch_runner *runner) {
@@ -973,7 +983,8 @@ static void test_pathological_regressions(test_batch_runner *runner) {
973983
free(html);
974984
free(input);
975985

976-
OK(runner, TIMING < 1000, "takes less than 1000ms to run");
986+
OK(runner, TIMING < 1000 * TIMING_SCALE,
987+
"takes less than CMARK_TIMING_SCALE * 1000ms to run");
977988
}
978989

979990
{
@@ -989,7 +1000,8 @@ static void test_pathological_regressions(test_batch_runner *runner) {
9891000
free(html);
9901001
free(input);
9911002

992-
OK(runner, TIMING < 1000, "takes less than 1000ms to run");
1003+
OK(runner, TIMING < 1000 * TIMING_SCALE,
1004+
"takes less than CMARK_TIMING_SCALE * 1000ms to run");
9931005
}
9941006
}
9951007

@@ -1133,6 +1145,7 @@ int main() {
11331145
int retval;
11341146
test_batch_runner *runner = test_batch_runner_new();
11351147

1148+
SETUP_TIMING();
11361149
cmark_enable_safety_checks(true);
11371150
version(runner);
11381151
constructor(runner);

test/pathological_tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import platform
88
import itertools
99
import multiprocessing
10+
import os
1011
from cmark import CMark
1112

1213
def hash_collisions():
@@ -106,7 +107,8 @@ def badhash(ref):
106107
passed = 0
107108
errored = 0
108109
ignored = 0
109-
TIMEOUT = 5
110+
timing_scale = float(os.getenv("CMARK_TIMING_SCALE", "1"))
111+
TIMEOUT = 5 * timing_scale
110112

111113
def run_test(inp, regex):
112114
parser = argparse.ArgumentParser(description='Run cmark tests.')

0 commit comments

Comments
 (0)