From d4978db8a1ed31046d0a8af40cb45938db450ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Thu, 14 Dec 2023 17:15:39 -0500 Subject: [PATCH] Better interleaving of seeks/reads --- test/libc/runtime/zipos_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/libc/runtime/zipos_test.c b/test/libc/runtime/zipos_test.c index 671e20f29..83c036b31 100644 --- a/test/libc/runtime/zipos_test.c +++ b/test/libc/runtime/zipos_test.c @@ -126,7 +126,7 @@ TEST(zipos, closeAfterVfork) { } struct State { - int depth; + int id; int fd; pthread_t thread; }; @@ -148,17 +148,17 @@ static void *pthread_main(void *ptr) { int fd, rc; fd = s->fd; - if (s->depth < 3) { + if (s->id < 8) { for (int i = 0; i < 2; ++i) { rc = dup(fd); ASSERT_NE(-1, rc); children[i].fd = rc; - children[i].depth = 1 + s->depth; + children[i].id = 2 * s->id + i; ASSERT_SYS(0, 0, pthread_create(&children[i].thread, NULL, pthread_main, children + i)); } } - if (s->depth & 1) { + if (s->id & 1) { SEEKS(); READS(); } else { @@ -166,7 +166,7 @@ static void *pthread_main(void *ptr) { SEEKS(); } ASSERT_SYS(0, 0, close(fd)); - if (s->depth < 3) { + if (s->id < 8) { for (int i = 0; i < 2; ++i) { ASSERT_SYS(0, 0, pthread_join(children[i].thread, NULL)); } @@ -175,7 +175,7 @@ static void *pthread_main(void *ptr) { } TEST(zipos, ultraPosixAtomicSeekRead) { - struct State s = { 0, 4 }; + struct State s = { 1, 4 }; ASSERT_SYS(0, 3, open("/zip/libc/testlib/hyperion.txt", O_RDONLY)); ASSERT_SYS(0, 4, dup(3)); pthread_main((void *)&s);