| 318 | } |
| 319 | |
| 320 | int |
| 321 | unit_test_suite_runner(struct unit_test_suite *suite) |
| 322 | { |
| 323 | int test_success, i, ret; |
| 324 | const char *status; |
| 325 | struct unit_test_case tc; |
| 326 | struct unit_test_suite *ts; |
| 327 | unsigned int sub_ts_succeeded = 0, sub_ts_failed = 0; |
| 328 | unsigned int sub_ts_skipped = 0, sub_ts_total = 0; |
| 329 | |
| 330 | unit_test_suite_reset_counts(suite); |
| 331 | |
| 332 | if (suite->suite_name) { |
| 333 | printf(" + ------------------------------------------------------- +\n"); |
| 334 | printf(" + Test Suite : %s\n", suite->suite_name); |
| 335 | } |
| 336 | |
| 337 | if (suite->setup) { |
| 338 | test_success = suite->setup(); |
| 339 | if (test_success != 0) { |
| 340 | /* |
| 341 | * setup did not pass, so count all enabled tests and |
| 342 | * mark them as failed/skipped |
| 343 | */ |
| 344 | unit_test_suite_count_tcs_on_setup_fail(suite, |
| 345 | test_success, &sub_ts_failed, |
| 346 | &sub_ts_skipped, &sub_ts_total); |
| 347 | goto suite_summary; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | printf(" + ------------------------------------------------------- +\n"); |
| 352 | |
| 353 | FOR_EACH_SUITE_TESTCASE(suite->total, suite, tc) { |
| 354 | if (!tc.enabled) { |
| 355 | suite->skipped++; |
| 356 | continue; |
| 357 | } else { |
| 358 | suite->executed++; |
| 359 | } |
| 360 | |
| 361 | /* run test case setup */ |
| 362 | if (tc.setup) |
| 363 | test_success = tc.setup(); |
| 364 | else |
| 365 | test_success = TEST_SUCCESS; |
| 366 | |
| 367 | if (test_success == TEST_SUCCESS) { |
| 368 | /* run the test case */ |
| 369 | if (tc.testcase) |
| 370 | test_success = tc.testcase(); |
| 371 | else if (tc.testcase_with_data) |
| 372 | test_success = tc.testcase_with_data(tc.data); |
| 373 | else |
| 374 | test_success = -ENOTSUP; |
| 375 | |
| 376 | if (test_success == TEST_SUCCESS) |
| 377 | suite->succeeded++; |
no test coverage detected