forked from enlightenment/efl
tests: check WIFEXITED to determine if test exited before using exit status
Summary: the exit status value is not valid unless the process has terminated normally by calling exit() or _exit(), so only use the status if this is true. otherwise mark the process as a failed test Depends on D6597 Reviewers: ManMower Reviewed By: ManMower Subscribers: cedric, #committers Tags: #efl_tests Differential Revision: https://phab.enlightenment.org/D6600
This commit is contained in:
parent
4bdac206d2
commit
6fbcff15db
|
@ -245,6 +245,21 @@ _efl_suite_run_end(SRunner *sr, const char *name)
|
||||||
return failed_count;
|
return failed_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_FORK
|
||||||
|
EINA_UNUSED static int
|
||||||
|
_efl_suite_wait_on_fork(int *num_forks)
|
||||||
|
{
|
||||||
|
int status = 0, ret;
|
||||||
|
waitpid(0, &status, 0);
|
||||||
|
if (WIFEXITED(status))
|
||||||
|
ret = WEXITSTATUS(status);
|
||||||
|
else
|
||||||
|
ret = 1;
|
||||||
|
(*num_forks)--;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
EINA_UNUSED static int
|
EINA_UNUSED static int
|
||||||
_efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, const Efl_Test_Case *etc, SFun init, SFun shutdown)
|
_efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, const Efl_Test_Case *etc, SFun init, SFun shutdown)
|
||||||
{
|
{
|
||||||
|
@ -279,15 +294,7 @@ _efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, co
|
||||||
if (do_fork && can_fork)
|
if (do_fork && can_fork)
|
||||||
{
|
{
|
||||||
if (num_forks == eina_cpu_count())
|
if (num_forks == eina_cpu_count())
|
||||||
{
|
failed_count += _efl_suite_wait_on_fork(&num_forks);
|
||||||
do
|
|
||||||
{
|
|
||||||
int status = 0;
|
|
||||||
waitpid(0, &status, 0);
|
|
||||||
failed_count += WEXITSTATUS(status);
|
|
||||||
num_forks--;
|
|
||||||
} while (0);
|
|
||||||
}
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
{
|
{
|
||||||
|
@ -330,10 +337,8 @@ _efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, co
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int status = 0;
|
failed_count += _efl_suite_wait_on_fork(&num_forks);
|
||||||
waitpid(0, &status, 0);
|
} while (num_forks);
|
||||||
failed_count += WEXITSTATUS(status);
|
|
||||||
} while (--num_forks);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue