Debian Codegraph @

debian/patches/0003-Provide-a-way-to-extend-test-timeouts.patch

raw
1 From: Keith Packard <[email protected]>
2 Date: Sun, 5 Jan 2025 09:18:22 -0800
3 Subject: Provide a way to extend test timeouts
4
5 Some hardware is really slow; let users set CMARK_TIMING_SCALE to
6 multiply the timeouts by an arbitrary amount
7
8 Signed-off-by: Keith Packard <[email protected]>
9 ---
10 api_test/main.c | 17 +++++++++++++++--
11 test/pathological_tests.py | 4 +++-
12 2 files changed, 18 insertions(+), 3 deletions(-)
13
14 diff --git a/api_test/main.c b/api_test/main.c
15 index 1a41e69..790327c 100644
16 --- a/api_test/main.c
17 +++ b/api_test/main.c
18 @@ -942,6 +942,13 @@ static void test_feed_across_line_ending(test_batch_runner *runner) {
19 # include <sys/time.h>
20 static struct timeval _before, _after;
21 static int _timing;
22 +static int _timing_scale = 1;
23 +# define SETUP_TIMING() \
24 + do { \
25 + char *scale = getenv("CMARK_TIMING_SCALE"); \
26 + if (scale) \
27 + _timing_scale = atoi(scale); \
28 + } while (0)
29 # define START_TIMING() \
30 gettimeofday(&_before, NULL)
31
32 @@ -952,10 +959,13 @@ static int _timing;
33 } while (0)
34
35 # define TIMING _timing
36 +# define TIMING_SCALE _timing_scale
37 #else
38 +# define SETUP_TIMING()
39 # define START_TIMING()
40 # define END_TIMING()
41 # define TIMING 0
42 +# define TIMING_SCALE 1
43 #endif
44
45 static void test_pathological_regressions(test_batch_runner *runner) {
46 @@ -973,7 +983,8 @@ static void test_pathological_regressions(test_batch_runner *runner) {
47 free(html);
48 free(input);
49
50 - OK(runner, TIMING < 1000, "takes less than 1000ms to run");
51 + OK(runner, TIMING < 1000 * TIMING_SCALE,
52 + "takes less than CMARK_TIMING_SCALE * 1000ms to run");
53 }
54
55 {
56 @@ -989,7 +1000,8 @@ static void test_pathological_regressions(test_batch_runner *runner) {
57 free(html);
58 free(input);
59
60 - OK(runner, TIMING < 1000, "takes less than 1000ms to run");
61 + OK(runner, TIMING < 1000 * TIMING_SCALE,
62 + "takes less than CMARK_TIMING_SCALE * 1000ms to run");
63 }
64 }
65
66 @@ -1133,6 +1145,7 @@ int main() {
67 int retval;
68 test_batch_runner *runner = test_batch_runner_new();
69
70 + SETUP_TIMING();
71 cmark_enable_safety_checks(true);
72 version(runner);
73 constructor(runner);
74 diff --git a/test/pathological_tests.py b/test/pathological_tests.py
75 index d0e910c..f556a1d 100644
76 --- a/test/pathological_tests.py
77 +++ b/test/pathological_tests.py
78 @@ -7,6 +7,7 @@ import sys
79 import platform
80 import itertools
81 import multiprocessing
82 +import os
83 from cmark import CMark
84
85 def hash_collisions():
86 @@ -106,7 +107,8 @@ whitespace_re = re.compile('/s+/')
87 passed = 0
88 errored = 0
89 ignored = 0
90 -TIMEOUT = 5
91 +timing_scale = float(os.getenv("CMARK_TIMING_SCALE", "1"))
92 +TIMEOUT = 5 * timing_scale
93
94 def run_test(inp, regex):
95 parser = argparse.ArgumentParser(description='Run cmark tests.')