Skip to content

Commit

Permalink
fix(test/drivers): fix concurrency issue
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo authored and poiana committed Mar 7, 2024
1 parent 4872fe2 commit 4abc96d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions test/drivers/test_suites/syscall_exit_suite/process_vm_readv_x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#ifdef __NR_process_vm_readv

void signal_handler(int signum) {
// Do nothing
}


TEST(SyscallExit, process_vm_readvX_failure)
{
auto evt_test = get_syscall_event_test(__NR_process_vm_readv, EXIT_EVENT);
Expand Down Expand Up @@ -71,19 +76,20 @@ TEST(SyscallExit, process_vm_readvX_success)
remote[0].iov_len = sizeof(buf);
void* target = &remote;

signal(SIGUSR2, signal_handler);

close(pipe_fd[0]);

ssize_t read = write(pipe_fd[1], &target, sizeof(void*));
ASSERT_GT(read, 0);

close(pipe_fd[1]);

/*
* The following write call makes sure that the process_vm_readv
* The following pause call makes sure that the process_vm_readv
* has been called.
*/
read = write(pipe_fd[1], buf, 2);
ASSERT_GT(read, 0);

close(pipe_fd[1]);
pause();

exit(EXIT_SUCCESS);
}
Expand All @@ -106,6 +112,8 @@ TEST(SyscallExit, process_vm_readvX_success)

close(pipe_fd[0]);

kill(child_pid, SIGUSR2);

int wstatus;
waitpid(child_pid, &wstatus, 0);
}
Expand Down

0 comments on commit 4abc96d

Please sign in to comment.