From 3ee80eb4584424498147215e31603e2a2223d315 Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Sun, 20 Aug 2023 09:04:17 +0200 Subject: [PATCH] FreeBSD: try to make eventfd2 testcase deterministic Add a sleep to give child 1 a chance to run. Flush stdout every time. --- memcheck/tests/freebsd/eventfd2.c | 8 ++++++++ memcheck/tests/freebsd/eventfd2.stdout.exp | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/memcheck/tests/freebsd/eventfd2.c b/memcheck/tests/freebsd/eventfd2.c index 8e2309f96d..d620907c9d 100644 --- a/memcheck/tests/freebsd/eventfd2.c +++ b/memcheck/tests/freebsd/eventfd2.c @@ -18,6 +18,7 @@ static void xsem_wait(int fd) fprintf(stdout, "wait completed on %d: count=%" PRIu64 "\n", fd, cntr); + fflush(stdout); } static void xsem_post(int fd, int count) @@ -38,21 +39,27 @@ static void sem_player(int fd1, int fd2) * (also xsem_wait above) */ fprintf(stdout, "posting 1 on %d\n", fd1); + fflush(stdout); xsem_post(fd1, 1); fprintf(stdout, "waiting on %d\n", fd2); + fflush(stdout); xsem_wait(fd2); fprintf(stdout, "posting 1 on %d\n", fd1); + fflush(stdout); xsem_post(fd1, 1); fprintf(stdout, "waiting on %d\n", fd2); + fflush(stdout); xsem_wait(fd2); fprintf(stdout, "posting 5 on %d\n", fd1); + fflush(stdout); xsem_post(fd1, 5); fprintf(stdout, "waiting 5 times on %d\n", fd2); + fflush(stdout); xsem_wait(fd2); xsem_wait(fd2); xsem_wait(fd2); @@ -88,6 +95,7 @@ int main(int argc, char **argv) sem_player(fd1, fd2); exit(0); } + sleep(1); if ((cpid_waiter = fork()) == 0) { sem_player(fd2, fd1); exit(0); diff --git a/memcheck/tests/freebsd/eventfd2.stdout.exp b/memcheck/tests/freebsd/eventfd2.stdout.exp index 6a2cd1944e..00ecdcaca7 100644 --- a/memcheck/tests/freebsd/eventfd2.stdout.exp +++ b/memcheck/tests/freebsd/eventfd2.stdout.exp @@ -1,26 +1,26 @@ posting 1 on 3 waiting on 4 +posting 1 on 4 wait completed on 4: count=1 +waiting on 3 posting 1 on 3 waiting on 4 -wait completed on 4: count=1 -posting 5 on 3 -waiting 5 times on 4 -wait completed on 4: count=1 -wait completed on 4: count=1 -wait completed on 4: count=1 -wait completed on 4: count=1 -wait completed on 4: count=1 -posting 1 on 4 -waiting on 3 wait completed on 3: count=1 posting 1 on 4 +wait completed on 4: count=1 waiting on 3 wait completed on 3: count=1 +posting 5 on 3 posting 5 on 4 +waiting 5 times on 4 +wait completed on 4: count=1 waiting 5 times on 3 +wait completed on 4: count=1 wait completed on 3: count=1 +wait completed on 4: count=1 wait completed on 3: count=1 +wait completed on 4: count=1 wait completed on 3: count=1 +wait completed on 4: count=1 wait completed on 3: count=1 wait completed on 3: count=1 -- 2.47.2