Skip to content

Commit

Permalink
Make desched_sigkill test handle the case where the phase-1 read()
Browse files Browse the repository at this point in the history
…does not fill `chs` in one call

Currently `chs` is not fully initialized in that case, which causes failures because the uninitialized bytes are written to `parent_to_child` and the children check they're equal to `x`.

Resolves #3559
  • Loading branch information
rocallahan committed Jul 19, 2023
1 parent 7e38065 commit 00c80a2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/test/desched_sigkill.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ int main(void) {

// Phase 1: Wait for all readers to become ready.
char chs[NUM_READERS];
int sum = 0;
while (sum < NUM_READERS) {
ret = read(child_to_parent[0], &chs, NUM_READERS);
int bytes_read = 0;
while (bytes_read < NUM_READERS) {
ret = read(child_to_parent[0], &chs[bytes_read], NUM_READERS - bytes_read);
test_assert(ret > 0);
sum += ret;
for (int i = 0; i < ret; ++i) {
test_assert(chs[bytes_read + i] == 'x');
}
bytes_read += ret;
}

// Phase 2: Release readers from `read` syscall.
Expand Down

0 comments on commit 00c80a2

Please sign in to comment.