Skip to content

Commit

Permalink
libguac: nested send instruction test
Browse files Browse the repository at this point in the history
Fix a race condition in the test.
The server is not waiting for the child to finish writing the message and this leads to a failed test if the child code is not running fast enough.

Signed-Off-By: Sven Auhagen <[email protected]>
  • Loading branch information
svenauhagen authored Feb 1, 2024
1 parent 73f23fc commit bd5367a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libguac/tests/socket/nested_send_instruction.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <guacamole/socket.h>

#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>

/**
Expand Down Expand Up @@ -123,6 +124,7 @@ static void read_expected_instructions(int fd) {
void test_socket__nested_send_instruction() {

int fd[2];
int return_status;

/* Create pipe */
CU_ASSERT_EQUAL_FATAL(pipe(fd), 0);
Expand All @@ -141,6 +143,9 @@ void test_socket__nested_send_instruction() {
exit(0);
}

/* Wait for child to finish */
waitpid(childpid, &return_status, 0);

/* Read and verify the expected instructions within the parent process */
close(write_fd);
read_expected_instructions(read_fd);
Expand Down

0 comments on commit bd5367a

Please sign in to comment.