KUnit update for Linux 5.17-rc1
Subsystems (4)
Shuah Khan
maintainerHi Linus,
Please pull the following KUnit update for Linux 5.17-rc1.
This KUnit update for Linux 5.17-rc1 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
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf:
Linux 5.16-rc1 (2021-11-14 13:56:52 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-kunit-5.17-rc1
for you to fetch changes up to ad659ccb5412874c6a89d3588cb18857c00e9d0f:
kunit: tool: Default --jobs to number of CPUs (2021-12-15 16:44:55 -0700)
----------------------------------------------------------------
linux-kselftest-kunit-5.17-rc1
This KUnit update for Linux 5.17-rc1 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
----------------------------------------------------------------
Daniel Latypov (13):
kunit: tool: fix --json output for skipped tests
Documentation: kunit: remove claims that kunit is a mocking framework
kunit: add run_checks.py script to validate kunit changes
kunit: tool: print parsed test results fully incrementally
kunit: tool: move Kconfig read_from_file/parse_from_string to package-level
kunit: tool: add --kconfig_add to allow easily tweaking kunitconfigs
kunit: tool: revamp message for invalid kunitconfig
kunit: tool: reconfigure when the used kunitconfig changes
kunit: tool: suggest using decode_stacktrace.sh on kernel crash
kunit: tool: use dataclass instead of collections.namedtuple
kunit: tool: delete kunit_parser.TestResult type
kunit: tool: make build subcommand also reconfigure if needed
kunit: tool: fix newly introduced typechecker errors
David Gow (5):
kunit: tool: Do not error on tests without test plans
kunit: tool: Report an error if any test has no subtests
kunit: Don't crash if no parameters are generated
kunit: Report test parameter results as (K)TAP subtests
kunit: tool: Default --jobs to number of CPUs
Documentation/dev-tools/kunit/api/index.rst | 3 +- Documentation/dev-tools/kunit/api/test.rst | 3 +- Documentation/dev-tools/kunit/index.rst | 2 +- Documentation/dev-tools/kunit/start.rst | 8 +- lib/kunit/test.c | 25 +-- tools/testing/kunit/kunit.py | 182 ++++++++++++--------- tools/testing/kunit/kunit_config.py | 61 +++---- tools/testing/kunit/kunit_json.py | 8 +- tools/testing/kunit/kunit_kernel.py | 76 ++++++--- tools/testing/kunit/kunit_parser.py | 57 ++++--- tools/testing/kunit/kunit_tool_test.py | 171 ++++++++++++++++--- tools/testing/kunit/run_checks.py | 81 +++++++++ .../test_is_test_passed-no_tests_no_plan.log | 7 + 13 files changed, 480 insertions(+), 204 deletions(-) create mode 100755 tools/testing/kunit/run_checks.py create mode 100644 tools/testing/kunit/test_data/test_is_test_passed-no_tests_no_plan.log
----------------------------------------------------------------
Documentation/dev-tools/kunit/api/index.rst +1 -2
@@ -12,5 +12,4 @@ following sections: Documentation/dev-tools/kunit/api/test.rst - - documents all of the standard testing API excluding mocking - or mocking related features. + - documents all of the standard testing API
Documentation/dev-tools/kunit/api/test.rst +1 -2
@@ -4,8 +4,7 @@ Test API ======== -This file documents all of the standard testing API excluding mocking or mocking -related features. +This file documents all of the standard testing API. .. kernel-doc:: include/kunit/test.h :internal:
Documentation/dev-tools/kunit/index.rst +1 -1
@@ -19,7 +19,7 @@ KUnit - Unit Testing for the Linux Kernel What is KUnit? ============== -KUnit is a lightweight unit testing and mocking framework for the Linux kernel. +KUnit is a lightweight unit testing framework for the Linux kernel. KUnit is heavily inspired by JUnit, Python's unittest.mock, and Googletest/Googlemock for C++. KUnit provides facilities for defining unit test
Documentation/dev-tools/kunit/start.rst +4 -4
@@ -50,10 +50,10 @@ It'll warn you if you haven't included the dependencies of the options you're using. .. note:: - Note that removing something from the ``.kunitconfig`` will not trigger a - rebuild of the ``.config`` file: the configuration is only updated if the - ``.kunitconfig`` is not a subset of ``.config``. This means that you can use - other tools (such as make menuconfig) to adjust other config options. + If you change the ``.kunitconfig``, kunit.py will trigger a rebuild of the + ``.config`` file. But you can edit the ``.config`` file directly or with + tools like ``make menuconfig O=.kunit``. As long as its a superset of + ``.kunitconfig``, kunit.py won't overwrite your changes. Running the tests (KUnit Wrapper)
lib/kunit/test.c +14 -11
@@ -504,25 +504,28 @@ int kunit_run_tests(struct kunit_suite *suite)struct kunit_result_stats param_stats = {0 }; test_case->status =KUNIT_SKIPPED ; -if (test_case->generate_params) { +if (!test_case->generate_params) { +/* Non-parameterised test. */ +kunit_run_case_catch_errors (suite, test_case, &test); +kunit_update_stats (¶m_stats, test.status); + }else {/* Get initial param. */ param_desc[0 ] ='\0' ; test.param_value = test_case->generate_params (NULL , param_desc); - } + kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT +"# Subtest: %s" , test_case->name); - do { - kunit_run_case_catch_errors(suite, test_case, &test); +while (test.param_value) { +kunit_run_case_catch_errors (suite, test_case, &test); - if (test_case->generate_params) {if (param_desc[0 ] =='\0' ) {snprintf (param_desc,sizeof (param_desc),"param-%d" , test.param_index); }kunit_log (KERN_INFO , &test, - KUNIT_SUBTEST_INDENT - "# %s: %s %d - %s", - test_case->name, + KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT +"%s %d - %s" ,kunit_status_to_ok_not_ok (test.status), test.param_index +1 , param_desc);
@@ -530,11 +533,11 @@ int kunit_run_tests(struct kunit_suite *suite) param_desc[0 ] ='\0' ; test.param_value = test_case->generate_params (test.param_value, param_desc); test.param_index++; - } -kunit_update_stats (¶m_stats, test.status); +kunit_update_stats (¶m_stats, test.status); + } + } - }while (test.param_value);kunit_print_test_stats (&test, param_stats);
tools/testing/kunit/kunit.py +105 -77
317 lines not on this page · raw message
tools/testing/kunit/kunit_config.py +31 -30
64 lines not on this page · raw message
tools/testing/kunit/kunit_json.py +5 -3
@@ -11,7 +11,7 @@ import os import kunit_parser -from kunit_parser import Test, TestResult, TestStatus +from kunit_parser import Test, TestStatus from typing import Any, Dict, Optional JsonObj = Dict[str, Any]
@@ -30,6 +30,8 @@ def _get_group_json(test: Test, def_config: str, test_case = {"name": subtest.name, "status": "FAIL"} if subtest.status == TestStatus.SUCCESS: test_case["status"] = "PASS" + elif subtest.status == TestStatus.SKIPPED: + test_case["status"] = "SKIP" elif subtest.status == TestStatus.TEST_CRASHED: test_case["status"] = "ERROR" test_cases.append(test_case)
@@ -48,9 +50,9 @@ def _get_group_json(test: Test, def_config: str, } return test_group -def get_json_result(test_result: TestResult, def_config: str, +def get_json_result(test: Test, def_config: str, build_dir: Optional[str], json_path: str) -> str: - test_group = _get_group_json(test_result.test, def_config, build_dir) + test_group = _get_group_json(test, def_config, build_dir) test_group["name"] = "KUnit Test Group" json_obj = json.dumps(test_group, indent=4) if json_path != 'stdout':
tools/testing/kunit/kunit_kernel.py +49 -27
131 lines not on this page · raw message
tools/testing/kunit/kunit_parser.py +34 -23
172 lines not on this page · raw message
tools/testing/kunit/kunit_tool_test.py +147 -24
332 lines not on this page · raw message
tools/testing/kunit/run_checks.py new file +81 -0
81 lines not on this page · raw message
tools/testing/kunit/test_data/test_is_test_passed-no_tests_no_plan.log new file +7 -0
@@ -0,0 +1,7 @@ +TAP version 14 +1..1 + # Subtest: suite + 1..1 + # Subtest: case + ok 1 - case # SKIP +ok 1 - suite
The pull request you sent on Fri, 7 Jan 2022 17:49:26 -0700:
The pull request you sent on Fri, 7 Jan 2022 17:49:26 -0700:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftesttags/linux-kselftest-kunit-5.17-rc1
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/bf4eebf8cfa2cd50e20b7321dfb3effdcdc6e909
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html