Commit bf4eebf8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'linux-kselftest-kunit-5.17-rc1' of...

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
parents 4369b3ce ad659ccb
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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
+1 −2
Original line number Diff line number Diff line
@@ -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:
+1 −1
Original line number Diff line number Diff line
@@ -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
+4 −4
Original line number Diff line number Diff line
@@ -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)
+14 −11
Original line number Diff line number Diff line
@@ -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(&param_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 {
			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(&param_stats, test.status);
			}
		}

		} while (test.param_value);

		kunit_print_test_stats(&test, param_stats);

Loading