summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-04-09 13:36:52 +0200
committerStefan Schmidt <stefan@osg.samsung.com>2018-04-10 11:28:01 +0200
commit6879270b5925c9acc59d8b27e7fedbb0af518396 (patch)
tree06e540f767394971cc4e914f48dfec177328150c
parent579eeb4a8c68967432ddbaa23ddc675e9b64c6b1 (diff)
tests: parallelize most test suites
Summary: check does not internally do any parallelizing and is impossible to use with threads, so using fork appears to be the only viable option for using more cpu without radically redesigning all existing tests ref T6825 ref T6848 Reviewers: stefan_schmidt Subscribers: cedric Maniphest Tasks: T6848, T6825 Differential Revision: https://phab.enlightenment.org/D5877
-rw-r--r--src/tests/efl_check.h87
1 files changed, 81 insertions, 6 deletions
diff --git a/src/tests/efl_check.h b/src/tests/efl_check.h
index 2752ea0ee8..029574c204 100644
--- a/src/tests/efl_check.h
+++ b/src/tests/efl_check.h
@@ -12,6 +12,11 @@
12#include <errno.h> /* errno */ 12#include <errno.h> /* errno */
13#include <sys/time.h> 13#include <sys/time.h>
14 14
15#ifdef HAVE_FORK
16#include <sys/types.h>
17#include <sys/wait.h>
18#endif
19
15#ifndef EINA_UNUSED 20#ifndef EINA_UNUSED
16 21
17#ifdef __GNUC__ 22#ifdef __GNUC__
@@ -197,13 +202,49 @@ _timing_end(void)
197 202
198#endif 203#endif
199 204
205static int
206_efl_suite_run_end(SRunner *sr, const char *name)
207{
208 int failed_count;
209
210 if (name)
211 {
212 char *n = strdup(name);
213 char buf[4096], *p;
214
215 for (p = n; p[0]; p++)
216 {
217 switch (p[0])
218 {
219 case ' ':
220 case '/':
221 case '\\':
222 case ';':
223 p[0] = '_';
224 break;
225 }
226 }
227 snprintf(buf, sizeof(buf), TESTS_BUILD_DIR "/check-results-%s.xml", n);
228 srunner_set_xml(sr, buf);
229 }
230 else
231 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
232 srunner_run_all(sr, CK_ENV);
233 failed_count = srunner_ntests_failed(sr);
234 srunner_free(sr);
235 return failed_count;
236}
237
200EINA_UNUSED static int 238EINA_UNUSED static int
201_efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, const Efl_Test_Case *etc, SFun init, SFun shutdown) 239_efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, const Efl_Test_Case *etc, SFun init, SFun shutdown)
202{ 240{
203 Suite *s; 241 Suite *s;
204 SRunner *sr; 242 SRunner *sr;
205 TCase *tc; 243 TCase *tc;
206 int i, failed_count; 244 int i, failed_count = 0;
245 int do_fork;
246 int num_forks = 0;
247 int can_fork = 0;
207#ifdef ENABLE_TIMING_INFO 248#ifdef ENABLE_TIMING_INFO
208 double tstart; 249 double tstart;
209 int timing = _timing_enabled(); 250 int timing = _timing_enabled();
@@ -213,27 +254,61 @@ _efl_suite_build_and_run(int argc, const char **argv, const char *suite_name, co
213#endif 254#endif
214 s = suite_create(suite_name); 255 s = suite_create(suite_name);
215 sr = srunner_create(s); 256 sr = srunner_create(s);
257 do_fork = _efl_test_fork_has(sr);
258 can_fork = strcmp(suite_name, "Eldbus" /* T6848 */);
216 259
217 for (i = 0; etc[i].test_case; ++i) 260 for (i = 0; etc[i].test_case; ++i)
218 { 261 {
262 int pid = 0;
263
219 if (!_efl_test_use(argc, argv, etc[i].test_case)) 264 if (!_efl_test_use(argc, argv, etc[i].test_case))
220 continue; 265 continue;
266#ifdef HAVE_FORK
267 if (do_fork && can_fork)
268 {
269 pid = fork();
270 if (pid > 0)
271 {
272 num_forks++;
273 continue;
274 }
275 }
276#endif
221 277
222 tc = tcase_create(etc[i].test_case); 278 tc = tcase_create(etc[i].test_case);
223 if (init || shutdown) 279 if (init || shutdown)
224 tcase_add_checked_fixture(tc, init, shutdown); 280 tcase_add_checked_fixture(tc, init, shutdown);
225 281
226 if (_efl_test_fork_has(sr)) 282 if (do_fork)
227 tcase_set_timeout(tc, 0); 283 tcase_set_timeout(tc, 0);
228 284
229 etc[i].build(tc); 285 etc[i].build(tc);
230 suite_add_tcase(s, tc); 286 suite_add_tcase(s, tc);
287#ifdef HAVE_FORK
288 if (do_fork && (!pid) && can_fork)
289 {
290 failed_count = _efl_suite_run_end(sr, etc[i].test_case);
291 if (failed_count > 255)
292 failed_count = 255;
293 exit(failed_count);
294 }
295#endif
231 } 296 }
232 297
233 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml"); 298#ifdef HAVE_FORK
234 srunner_run_all(sr, CK_ENV); 299 if (num_forks)
235 failed_count = srunner_ntests_failed(sr); 300 {
236 srunner_free(sr); 301 do
302 {
303 int status = 0;
304 waitpid(0, &status, 0);
305 failed_count += WEXITSTATUS(status);
306 } while (--num_forks);
307 }
308 else
309#endif
310 failed_count = _efl_suite_run_end(sr, NULL);
311
237#ifdef ENABLE_TIMING_INFO 312#ifdef ENABLE_TIMING_INFO
238 if (timing) 313 if (timing)
239 printf("SUITE TIME %s: %.5g\n", suite_name, _timing_time_get() - tstart); 314 printf("SUITE TIME %s: %.5g\n", suite_name, _timing_time_get() - tstart);