mirror of
https://github.com/cuberite/libevent.git
synced 2025-08-04 01:36:23 -04:00
test: detect test failures if atexit handler calls _exit(!0) (sanitizers)
tinytest uses another way of detecting test failures, it uses pipe between child and parent, and if the test function in child returns OK it writes OK flag into pipe, and reads it in parent. However sanitizers uses atexit handlers to detect leaks, and this will not detect failures in case of exit() will be called from the atexit handlers, fix this by checking status after waitpid(). (cherry picked from commit 6754740f15e8200a12605a2e707fc6d3e6754d6a)
This commit is contained in:
parent
48e04887f2
commit
19a68bd194
@ -279,7 +279,7 @@ testcase_run_forked_(const struct testgroup_t *group,
|
|||||||
return FAIL; /* unreachable */
|
return FAIL; /* unreachable */
|
||||||
} else {
|
} else {
|
||||||
/* parent */
|
/* parent */
|
||||||
int status, r;
|
int status, r, exitcode;
|
||||||
char b[1];
|
char b[1];
|
||||||
/* Close this now, so that if the other side closes it,
|
/* Close this now, so that if the other side closes it,
|
||||||
* our read fails. */
|
* our read fails. */
|
||||||
@ -287,12 +287,20 @@ testcase_run_forked_(const struct testgroup_t *group,
|
|||||||
r = (int)read(outcome_pipe[0], b, 1);
|
r = (int)read(outcome_pipe[0], b, 1);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
printf("[Lost connection!] ");
|
printf("[Lost connection!] ");
|
||||||
return 0;
|
return FAIL;
|
||||||
} else if (r != 1) {
|
} else if (r != 1) {
|
||||||
perror("read outcome from pipe");
|
perror("read outcome from pipe");
|
||||||
}
|
}
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
exitcode = WEXITSTATUS(status);
|
||||||
close(outcome_pipe[0]);
|
close(outcome_pipe[0]);
|
||||||
|
if (opt_verbosity>1)
|
||||||
|
printf("%s%s: exited with %i (%i)\n", group->prefix, testcase->name, exitcode, status);
|
||||||
|
if (exitcode != 0)
|
||||||
|
{
|
||||||
|
printf("[atexit failure!] ");
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
return b[0]=='Y' ? OK : (b[0]=='S' ? SKIP : FAIL);
|
return b[0]=='Y' ? OK : (b[0]=='S' ? SKIP : FAIL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user