Skip to content

Commit 18fcffa

Browse files
125hzclaude
andcommitted
check-ctx-fp: the switch's harness has the server clock and steps it (#556 follow-up)
The host check compiles ios_ctx_fp_enabled() on its own; with the answer kept for a second it needs timeout_t, monotonic_time and TICKS_PER_SEC, and each check advances the clock. One check reads twice within the second and expects the kept answer. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 2956111 commit 18fcffa

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

‎tests/host/check-ctx-fp.py‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,25 @@ def function(source, start):
7070
snprintf(buf, cap, "%s", cfg_value);
7171
return 1;
7272
}
73+
/* the server's clock: the answer is kept for a second, so the checks step it */
74+
typedef long long timeout_t;
75+
#define TICKS_PER_SEC 10000000
76+
static timeout_t monotonic_time;
7377
""" + switch + r"""
7478
#define CHECK(x) do { if (!(x)) { printf("failed line %d: %s\n", __LINE__, #x); return 1; } } while (0)
79+
#define LATER (monotonic_time += TICKS_PER_SEC)
7580
int main(void)
7681
{
7782
unsetenv("MADEIRA_CTX_FP");
7883
CHECK(ios_ctx_fp_enabled());
79-
setenv("MADEIRA_CTX_FP", "1", 1); CHECK(ios_ctx_fp_enabled());
80-
setenv("MADEIRA_CTX_FP", "0", 1); CHECK(!ios_ctx_fp_enabled());
81-
cfg_value = "1"; CHECK(ios_ctx_fp_enabled());
82-
unsetenv("MADEIRA_CTX_FP"); cfg_value = "0"; CHECK(!ios_ctx_fp_enabled());
84+
LATER; setenv("MADEIRA_CTX_FP", "1", 1); CHECK(ios_ctx_fp_enabled());
85+
LATER; setenv("MADEIRA_CTX_FP", "0", 1); CHECK(!ios_ctx_fp_enabled());
86+
/* within the second the kept answer stands: no file read for a program that captures often */
87+
setenv("MADEIRA_CTX_FP", "1", 1); CHECK(!ios_ctx_fp_enabled());
88+
LATER; CHECK(ios_ctx_fp_enabled());
89+
LATER; cfg_value = "0"; CHECK(!ios_ctx_fp_enabled());
90+
LATER; cfg_value = "1"; setenv("MADEIRA_CTX_FP", "0", 1); CHECK(ios_ctx_fp_enabled());
91+
LATER; unsetenv("MADEIRA_CTX_FP"); cfg_value = "0"; CHECK(!ios_ctx_fp_enabled());
8392
return 0;
8493
}
8594
"""

0 commit comments

Comments
 (0)