runner: Correctly handle running parallel tests
PATCH 1/1 runner: Correctly handle running parallel tests
8259375 ("runner: Remove threads and mutexes") did not correctly account for the case where multiple tests are being run in parallel by ptest-runner. Fix the code to track all of the child processes (but still have them share the same stdout/stderr pipe) and wait for all of them to finish before exiting.
Signed-off-by Joshua Watt <[email protected]>
--- tests/utils.c | 39 +++++++- utils.c | 248 +++++++++++++++++++++++++++++--------------------- 2 files changed, 182 insertions(+), 105 deletions(-)
tests/utils.c +36 -3
@@ -50,9 +50,10 @@ static char *ptests_found[] = {"glibc" ,"hang" ,"python" , +"signal" ,NULL }; -static int ptests_found_length =6 ; +static int ptests_found_length =7 ;static char *ptests_not_found[] = {"busybox" , "perl",
@@ -186,6 +187,7 @@ START_TEST(test_run_ptests) head =get_available_ptests (opts_directory);ptest_list_remove (head,"hang" ,1 );ptest_list_remove (head,"fail" ,1 ); +ptest_list_remove (head,"signal" ,1 ); rc =run_ptests (head, opts,"test_run_ptests" , fp_stdout, fp_stderr);ck_assert (rc ==0 );
@@ -215,8 +217,8 @@ search_for_timeout_and_duration(const int rp, FILE *fp_stdout) found_duration = found_duration ? found_duration :find_word (line, duration_str); } -ck_assert (found_timeout == true); -ck_assert (found_duration == true); +ck_assert_msg (found_timeout == true,"TIMEOUT not found" ); +ck_assert_msg (found_duration == true,"DURATION not found" ); }START_TEST (test_run_timeout_duration_ptest)
@@ -230,6 +232,36 @@ START_TEST(test_run_timeout_duration_ptest) }END_TEST +static void +search_for_signal_and_duration (const int rp,FILE *fp_stdout) +{ +char line_buf[PRINT_PTEST_BUF_SIZE ]; +bool found_error = false, found_duration = false; +char *line =NULL ; + +ck_assert (rp !=0 ); + +while ((line =fgets (line_buf,PRINT_PTEST_BUF_SIZE , fp_stdout)) !=NULL ) { +// once true, stay true + found_error = found_error ? found_error :find_word (line,"ERROR: Exited with signal" ); + found_duration = found_duration ? found_duration :find_word (line,"DURATION" ); + } + +ck_assert_msg (found_error == true,"ERROR not found" ); +ck_assert_msg (found_duration == true,"DURATION not found" ); +} + +START_TEST (test_run_signal_ptest) +{ +struct ptest_list *head =get_available_ptests (opts_directory); +unsigned int timeout =10 ; + +test_ptest_expected_failure (head, timeout,"signal" , search_for_signal_and_duration); + +ptest_list_free_all (head); +} +END_TEST + static voidsearch_for_fail (const int rp,FILE *fp_stdout) {
@@ -318,6 +350,7 @@ utils_suite(void)tcase_add_test (tc_core, test_filter_ptests);tcase_add_test (tc_core, test_run_ptests);tcase_add_test (tc_core, test_run_timeout_duration_ptest); +tcase_add_test (tc_core, test_run_signal_ptest);tcase_add_test (tc_core, test_run_fail_ptest);tcase_add_test (tc_core, test_xml_pass);tcase_add_test (tc_core, test_xml_fail);
utils.c +146 -102
313 lines not on this page · raw message
Signature · 1 line
2.33.0