Skip to content

Commit bf4eebf

Browse files
committed
Merge tag 'linux-kselftest-kunit-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
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
2 parents 4369b3c + ad659cc commit bf4eebf

File tree

13 files changed

+480
-204
lines changed

13 files changed

+480
-204
lines changed

Documentation/dev-tools/kunit/api/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ following sections:
1212

1313
Documentation/dev-tools/kunit/api/test.rst
1414

15-
- documents all of the standard testing API excluding mocking
16-
or mocking related features.
15+
- documents all of the standard testing API

Documentation/dev-tools/kunit/api/test.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
Test API
55
========
66

7-
This file documents all of the standard testing API excluding mocking or mocking
8-
related features.
7+
This file documents all of the standard testing API.
98

109
.. kernel-doc:: include/kunit/test.h
1110
:internal:

Documentation/dev-tools/kunit/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ KUnit - Unit Testing for the Linux Kernel
1919
What is KUnit?
2020
==============
2121

22-
KUnit is a lightweight unit testing and mocking framework for the Linux kernel.
22+
KUnit is a lightweight unit testing framework for the Linux kernel.
2323

2424
KUnit is heavily inspired by JUnit, Python's unittest.mock, and
2525
Googletest/Googlemock for C++. KUnit provides facilities for defining unit test

Documentation/dev-tools/kunit/start.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ It'll warn you if you haven't included the dependencies of the options you're
5050
using.
5151

5252
.. note::
53-
Note that removing something from the ``.kunitconfig`` will not trigger a
54-
rebuild of the ``.config`` file: the configuration is only updated if the
55-
``.kunitconfig`` is not a subset of ``.config``. This means that you can use
56-
other tools (such as make menuconfig) to adjust other config options.
53+
If you change the ``.kunitconfig``, kunit.py will trigger a rebuild of the
54+
``.config`` file. But you can edit the ``.config`` file directly or with
55+
tools like ``make menuconfig O=.kunit``. As long as its a superset of
56+
``.kunitconfig``, kunit.py won't overwrite your changes.
5757

5858

5959
Running the tests (KUnit Wrapper)

lib/kunit/test.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -504,37 +504,40 @@ int kunit_run_tests(struct kunit_suite *suite)
504504
struct kunit_result_stats param_stats = { 0 };
505505
test_case->status = KUNIT_SKIPPED;
506506

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(&param_stats, test.status);
511+
} else {
508512
/* Get initial param. */
509513
param_desc[0] = '\0';
510514
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);
512517

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);
515520

516-
if (test_case->generate_params) {
517521
if (param_desc[0] == '\0') {
518522
snprintf(param_desc, sizeof(param_desc),
519523
"param-%d", test.param_index);
520524
}
521525

522526
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",
526529
kunit_status_to_ok_not_ok(test.status),
527530
test.param_index + 1, param_desc);
528531

529532
/* Get next param. */
530533
param_desc[0] = '\0';
531534
test.param_value = test_case->generate_params(test.param_value, param_desc);
532535
test.param_index++;
533-
}
534536

535-
kunit_update_stats(&param_stats, test.status);
537+
kunit_update_stats(&param_stats, test.status);
538+
}
539+
}
536540

537-
} while (test.param_value);
538541

539542
kunit_print_test_stats(&test, param_stats);
540543

0 commit comments

Comments
 (0)