2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 05:18:00 +00:00

compel/test: Return 0 in case of error in fdspy

This commit revises the error handling in the fdspy test. Previously,
a failure case could have been incorrectly reported as successful because
of a specific check `pass != 0`, leading to potential false positives
when `check_pipe_ends()` returned `-1` due to a read/write pipe error.

To improve this, we've adjusted the error handling to return `0` in case
of any error. As such, the final success condition remains unchanged. This
approach will help accurately differentiate between successful and failed
cases, ensuring the output "All OK" is printed for success, and "Something
went WRONG" for any failure.

Fixes: 5364ca3 ("compel/test: Fix warn_unused_result")

Signed-off-by: Haorong Lu <ancientmodern4@gmail.com>
This commit is contained in:
Haorong Lu 2023-06-15 15:13:58 -07:00 committed by Andrei Vagin
parent 4c1409b8f6
commit 4455444eeb

View File

@ -110,11 +110,11 @@ static int check_pipe_ends(int wfd, int rfd)
printf("Check pipe ends are connected\n");
if (write(wfd, "1", 2) != 2) {
fprintf(stderr, "write to pipe failed\n");
return -1;
return 0;
}
if (read(rfd, aux, sizeof(aux)) != sizeof(aux)) {
fprintf(stderr, "read from pipe failed\n");
return -1;
return 0;
}
if (aux[0] != '1' || aux[1] != '\0') {
fprintf(stderr, "Pipe connectivity lost\n");