From 664c608e3256f956d13e104f5015e8d5cc9ed31c Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 1 Dec 2023 22:28:35 +1300 Subject: [PATCH] Put a pile of code into the concurrent_signals tight loop so it replays faster with large skid values --- src/test/concurrent_signals.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/test/concurrent_signals.c b/src/test/concurrent_signals.c index 37a843504ec..baccf951f79 100644 --- a/src/test/concurrent_signals.c +++ b/src/test/concurrent_signals.c @@ -8,6 +8,29 @@ static void handler(__attribute__((unused)) int sig) {} static void term_handler(__attribute__((unused)) int sig) { stop = 1; } +#define STATEMENT(i) \ + if (a * (i) < b) { \ + ++a; \ + } else { \ + ++b; \ + } +#define STATEMENT2(i) STATEMENT(i) STATEMENT(i + 1) +#define STATEMENT4(i) STATEMENT2(i) STATEMENT2(i + 2) +#define STATEMENT8(i) STATEMENT4(i) STATEMENT4(i + 4) +#define STATEMENT16(i) STATEMENT8(i) STATEMENT8(i + 8) +#define STATEMENT32(i) STATEMENT16(i) STATEMENT16(i + 16) +#define STATEMENT64(i) STATEMENT32(i) STATEMENT32(i + 32) +#define STATEMENT128(i) STATEMENT64(i) STATEMENT64(i + 64) +#define STATEMENT256(i) STATEMENT128(i) STATEMENT128(i + 128) +#define STATEMENT512(i) STATEMENT256(i) STATEMENT256(i + 256) +#define STATEMENT1024(i) STATEMENT512(i) STATEMENT512(i + 512) +#define STATEMENT2048(i) STATEMENT1024(i) STATEMENT1024(i + 1024) +#define STATEMENT4096(i) STATEMENT2048(i) STATEMENT2048(i + 2048) + +static volatile int a; +static volatile int b; +static volatile int i; + int main(void) { test_assert(0 == signal(SIGUSR1, handler)); test_assert(0 == signal(SIGUSR2, handler)); @@ -15,7 +38,9 @@ int main(void) { atomic_puts("ready"); - while (!stop) {} + while (!stop) { + STATEMENT4096(i); + } atomic_puts("EXIT-SUCCESS"); return 0;