Better interleaving of seeks/reads

This commit is contained in:
Jōshin 2023-12-14 17:15:39 -05:00
parent e9a9da0936
commit d4978db8a1
No known key found for this signature in database

View file

@ -126,7 +126,7 @@ TEST(zipos, closeAfterVfork) {
} }
struct State { struct State {
int depth; int id;
int fd; int fd;
pthread_t thread; pthread_t thread;
}; };
@ -148,17 +148,17 @@ static void *pthread_main(void *ptr) {
int fd, rc; int fd, rc;
fd = s->fd; fd = s->fd;
if (s->depth < 3) { if (s->id < 8) {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
rc = dup(fd); rc = dup(fd);
ASSERT_NE(-1, rc); ASSERT_NE(-1, rc);
children[i].fd = 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, ASSERT_SYS(0, 0, pthread_create(&children[i].thread, NULL, pthread_main,
children + i)); children + i));
} }
} }
if (s->depth & 1) { if (s->id & 1) {
SEEKS(); SEEKS();
READS(); READS();
} else { } else {
@ -166,7 +166,7 @@ static void *pthread_main(void *ptr) {
SEEKS(); SEEKS();
} }
ASSERT_SYS(0, 0, close(fd)); ASSERT_SYS(0, 0, close(fd));
if (s->depth < 3) { if (s->id < 8) {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
ASSERT_SYS(0, 0, pthread_join(children[i].thread, NULL)); ASSERT_SYS(0, 0, pthread_join(children[i].thread, NULL));
} }
@ -175,7 +175,7 @@ static void *pthread_main(void *ptr) {
} }
TEST(zipos, ultraPosixAtomicSeekRead) { 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, 3, open("/zip/libc/testlib/hyperion.txt", O_RDONLY));
ASSERT_SYS(0, 4, dup(3)); ASSERT_SYS(0, 4, dup(3));
pthread_main((void *)&s); pthread_main((void *)&s);