Pull KUnit updates from Shuah Khan: "This consists of several fixes and enhancements. A few highlights: - Option --kconfig_add option allows easily tweaking kunitconfigs - make build subcommand can reconfigure if needed - doesn't error on tests without test plans - doesn't crash if no parameters are generated - defaults --jobs to # of cups - reports test parameter results as (K)TAP subtests" * tag 'linux-kselftest-kunit-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kunit: tool: Default --jobs to number of CPUs kunit: tool: fix newly introduced typechecker errors kunit: tool: make `build` subcommand also reconfigure if needed kunit: tool: delete kunit_parser.TestResult type kunit: tool: use dataclass instead of collections.namedtuple kunit: tool: suggest using decode_stacktrace.sh on kernel crash kunit: tool: reconfigure when the used kunitconfig changes kunit: tool: revamp message for invalid kunitconfig kunit: tool: add --kconfig_add to allow easily tweaking kunitconfigs kunit: tool: move Kconfig read_from_file/parse_from_string to package-level kunit: tool: print parsed test results fully incrementally kunit: Report test parameter results as (K)TAP subtests kunit: Don't crash if no parameters are generated kunit: tool: Report an error if any test has no subtests kunit: tool: Do not error on tests without test plans kunit: add run_checks.py script to validate kunit changes Documentation: kunit: remove claims that kunit is a mocking framework kunit: tool: fix --json output for skipped tests
Showing the changes to lib (1 of 13 files). Show all
Unified · Split
| @@ -504,25 +504,28 @@ int kunit_run_tests(struct kunit_suite *suite) · 503 unmodified lines | ||
| 504 | 504 | struct kunit_result_stats param_stats = { 0 }; |
| 505 | 505 | test_case->status = KUNIT_SKIPPED; |
| 506 | 506 | |
| 507 | − if (test_case->generate_params) { | |
| 507 | + if (!test_case->generate_params) { | |
| 508 | + /* Non-parameterised test. */ | |
| 509 | + kunit_run_case_catch_errors(suite, test_case, &test); | |
| 510 | + kunit_update_stats(¶m_stats, test.status); | |
| 511 | + } else { | |
| 508 | 512 | /* Get initial param. */ |
| 509 | 513 | param_desc[0] = '\0'; |
| 510 | 514 | test.param_value = test_case->generate_params(NULL, param_desc); |
| 511 | − } | |
| 515 | + kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT | |
| 516 | + "# Subtest: %s", test_case->name); | |
| 512 | 517 | |
| 513 | − do { | |
| 514 | − kunit_run_case_catch_errors(suite, test_case, &test); | |
| 518 | + while (test.param_value) { | |
| 519 | + kunit_run_case_catch_errors(suite, test_case, &test); | |
| 515 | 520 | |
| 516 | − if (test_case->generate_params) { | |
| 517 | 521 | if (param_desc[0] == '\0') { |
| 518 | 522 | snprintf(param_desc, sizeof(param_desc), |
| 519 | 523 | "param-%d", test.param_index); |
| 520 | 524 | } |
| 521 | 525 | |
| 522 | 526 | kunit_log(KERN_INFO, &test, |
| 523 | − KUNIT_SUBTEST_INDENT | |
| 524 | − "# %s: %s %d - %s", | |
| 525 | − test_case->name, | |
| 527 | + KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT | |
| 528 | + "%s %d - %s", | |
| 526 | 529 | kunit_status_to_ok_not_ok(test.status), |
| 527 | 530 | test.param_index + 1, param_desc); |
| 528 | 531 | |
| @@ -530,11 +533,11 @@ int kunit_run_tests(struct kunit_suite *suite) · 1 unmodified line | ||
| 530 | 533 | param_desc[0] = '\0'; |
| 531 | 534 | test.param_value = test_case->generate_params(test.param_value, param_desc); |
| 532 | 535 | test.param_index++; |
| 533 | − } | |
| 534 | 536 | |
| 535 | − kunit_update_stats(¶m_stats, test.status); | |
| 537 | + kunit_update_stats(¶m_stats, test.status); | |
| 538 | + } | |
| 539 | + } | |
| 536 | 540 | |
| 537 | − } while (test.param_value); | |
| 538 | 541 | |
| 539 | 542 | kunit_print_test_stats(&test, param_stats); |
| 540 | 543 | |