summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-07-25 10:56:23 -0500
committerDerek Foreman <derek.foreman.samsung@gmail.com>2018-07-25 10:56:23 -0500
commit6fbcff15db98d18e9c867c36d1cb1770cba4299d (patch)
treeb5e8e6321db8fc9b2060a8c8333323a3e5e76b1b
parent4bdac206d27fc973c836730562ed07bb9f259bad (diff)
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
-rw-r--r--src/tests/efl_check.h31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/tests/efl_check.h b/src/tests/efl_check.h
index 1d9942feb3..e3218ccc29 100644
--- a/src/tests/efl_check.h
+++ b/src/tests/efl_check.h
@@ -245,6 +245,21 @@ _efl_suite_run_end(SRunner *sr, const char *name)
245 return failed_count; 245 return failed_count;
246} 246}
247 247
248#ifdef HAVE_FORK
249EINA_UNUSED static int
250_efl_suite_wait_on_fork(int *num_forks)
251{
252 int status = 0, ret;
253 waitpid(0, &status, 0);
254 if (WIFEXITED(status))
255 ret = WEXITSTATUS(status);
256 else
257 ret = 1;
258 (*num_forks)--;
259 return ret;
260}
261#endif
262
248EINA_UNUSED static int 263EINA_UNUSED static int
249_efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, const Efl_Test_Case *etc, SFun init, SFun shutdown) 264_efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, const Efl_Test_Case *etc, SFun init, SFun shutdown)
250{ 265{
@@ -279,15 +294,7 @@ _efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, co
279 if (do_fork && can_fork) 294 if (do_fork && can_fork)
280 { 295 {
281 if (num_forks == eina_cpu_count()) 296 if (num_forks == eina_cpu_count())
282 { 297 failed_count += _efl_suite_wait_on_fork(&num_forks);
283 do
284 {
285 int status = 0;
286 waitpid(0, &status, 0);
287 failed_count += WEXITSTATUS(status);
288 num_forks--;
289 } while (0);
290 }
291 pid = fork(); 298 pid = fork();
292 if (pid > 0) 299 if (pid > 0)
293 { 300 {
@@ -330,10 +337,8 @@ _efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, co
330 { 337 {
331 do 338 do
332 { 339 {
333 int status = 0; 340 failed_count += _efl_suite_wait_on_fork(&num_forks);
334 waitpid(0, &status, 0); 341 } while (num_forks);
335 failed_count += WEXITSTATUS(status);
336 } while (--num_forks);
337 } 342 }
338 else 343 else
339#endif 344#endif