/linux/lib/kunit/ |
H A D | Kconfig | 2 # KUnit base configuration 5 menuconfig KUNIT config 6 tristate "KUnit - Enable support for unit tests" 9 Enables support for kernel unit tests (KUnit), a lightweight unit 14 Documentation/dev-tools/kunit/. 16 if KUNIT 19 bool "KUnit - Enable /sys/kernel/debug/kunit debugfs representation" if !KUNIT_ALL_TESTS 22 Enable debugfs representation for kunit. Currently this consists 23 of /sys/kernel/debug/kunit/<test_suite>/results files for each 28 bool "Enable KUnit tests which print BUG stacktraces" [all …]
|
H A D | device.c | 3 * KUnit-managed device implementation 6 * lifecycle is managed by KUnit. 15 #include <kunit/test.h> 16 #include <kunit/device.h> 17 #include <kunit/resource.h> 25 /* The root device for the KUnit bus, parent of all kunit_devices. */ 28 /* A device owned by a KUnit test. */ 31 /* The KUnit test which owns this device. */ 32 struct kunit *owner; 33 /* If the driver is managed by KUnit and unique to this device. */ [all …]
|
H A D | kunit-test.c | 3 * KUnit test for core test infrastructure. 9 #include <kunit/test.h> 10 #include <kunit/test-bug.h> 11 #include <kunit/static_stub.h> 14 #include <kunit/device.h> 26 struct kunit *test = data; in kunit_test_successful_try() 34 struct kunit *test = data; in kunit_test_no_catch() 39 static void kunit_test_try_catch_successful_try_no_catch(struct kunit *test) in kunit_test_try_catch_successful_try_no_catch() 56 struct kunit *test = data; in kunit_test_unsuccessful_try() 66 struct kunit *test = data; in kunit_test_catch() [all …]
|
H A D | platform-test.c | 3 * KUnit test for KUnit platform driver infrastructure. 8 #include <kunit/platform_device.h> 9 #include <kunit/test.h> 14 static void kunit_platform_device_alloc_test(struct kunit *test) in kunit_platform_device_alloc_test() 17 kunit_platform_device_alloc(test, "kunit-platform", 1)); in kunit_platform_device_alloc_test() 24 static void kunit_platform_device_add_test(struct kunit *test) in kunit_platform_device_add_test() 27 const char *name = "kunit-platform-add"; in kunit_platform_device_add_test() 43 static void kunit_platform_device_add_twice_fails_test(struct kunit *test) in kunit_platform_device_add_twice_fails_test() 46 const char *name = "kunit-platform-add-2"; in kunit_platform_device_add_twice_fails_test() 67 static void kunit_platform_device_add_cleans_up(struct kunit *test) in kunit_platform_device_add_cleans_up() [all …]
|
/linux/Documentation/dev-tools/kunit/ |
H A D | start.rst | 7 This page contains an overview of the kunit_tool and KUnit framework, 9 and covers common problems users face when using KUnit for the first time. 13 KUnit has the same dependencies as the Linux kernel. As long as you can 14 build the kernel, you can run KUnit. 24 ./tools/testing/kunit/kunit.py run 30 This happens because internally kunit.py specifies ``.kunit`` 46 Configuring KUnit Kernel ... 47 Building KUnit Kernel ... 48 Starting KUnit Kernel ... 54 the ``Building KUnit Kernel`` step may take a while. [all …]
|
H A D | architecture.rst | 4 KUnit Architecture 7 The KUnit architecture is divided into two parts: 15 The kernel testing library supports KUnit tests written in C using 16 KUnit. These KUnit tests are kernel code. KUnit performs the following 26 The test case is the fundamental unit in KUnit. KUnit test cases are organised 27 into suites. A KUnit test case is a function with type signature 28 ``void (*)(struct kunit *test)``. These test case functions are wrapped in a 34 Each KUnit test case receives a ``struct kunit`` context object that tracks a 35 running test. The KUnit assertion macros and other KUnit utilities use the 36 ``struct kunit`` context object. As an exception, there are two fields: [all …]
|
H A D | running_tips.rst | 4 Tips For Running KUnit Tests 7 Using ``kunit.py run`` ("kunit tool") 18 ( cd "$(git rev-parse --show-toplevel)" && ./tools/testing/kunit/kunit.py run "$@" ) 22 Early versions of ``kunit.py`` (before 5.6) didn't work unless run from 28 ``kunit.py run`` accepts an optional glob argument to filter tests. The format 35 $ echo -e 'CONFIG_KUNIT=y\nCONFIG_KUNIT_ALL_TESTS=y' > .kunit/.kunitconfig 36 $ ./tools/testing/kunit/kunit.py run 'sysctl*' 42 $ echo -e 'CONFIG_KUNIT=y\nCONFIG_KUNIT_ALL_TESTS=y' > .kunit/.kunitconfig 43 $ ./tools/testing/kunit/kunit.py run 'sysctl*.*write*' 55 ``kunit.py run`` (along with ``build``, and ``config``) supports a [all …]
|
H A D | faq.rst | 9 KUnit is a unit testing framework. Autotest, kselftest (and some others) are 25 Does KUnit support running on architectures other than UML? 30 For the most part, the KUnit core framework (what we use to write the tests) 33 module is loaded. However, there is infrastructure, like the KUnit Wrapper 34 (``tools/testing/kunit/kunit.py``) that might not support some architectures 35 (see :ref:`kunit-on-qemu`). 37 In short, yes, you can run KUnit on other architectures, but it might require 38 more work than using KUnit on UML. 40 For more information, see :ref:`kunit-on-non-uml`. 67 KUnit is not working, what should I do? [all …]
|
H A D | index.rst | 4 KUnit - Linux Kernel Unit Testing 26 KUnit (Kernel unit testing framework) provides a common framework for 27 unit tests within the Linux kernel. Using KUnit, you can define groups 29 if built-in, or load as a module. KUnit automatically flags and reports 35 KUnit tests are part of the kernel, written in the C (programming) 38 completion, KUnit can run around 100 tests in less than 10 seconds. 39 KUnit can test any kernel component, for example: file system, system 42 KUnit follows the white-box testing approach. The test has access to 43 internal system functionality. KUnit runs in kernel space and is not 46 In addition, KUnit has kunit_tool, a script (``tools/testing/kunit/kunit.py``) [all …]
|
H A D | style.rst | 7 To make finding, writing, and using KUnit tests as simple as possible, it is 9 below. While it is possible to write KUnit tests which do not follow these rules, 15 1. Porting tests to KUnit which are already known with an existing name. 32 or more KUnit test suites which test the same driver or part of the kernel. A 43 underscores. *Do not* include "test" or "kunit" directly in the subsystem name 44 unless we are actually testing other tests or the kunit framework itself. For 62 ``qos-kunit-test`` 63 This name should use underscores, and not have "kunit-test" as a 71 The KUnit API and tools do not explicitly know about subsystems. They are 79 KUnit tests are grouped into test suites, which cover a specific area of [all …]
|
H A D | usage.rst | 9 The fundamental unit in KUnit is the test case. A test case is a function with 10 the signature ``void (*)(struct kunit *test)``. It calls the function under test 15 void example_test_success(struct kunit *test) 19 void example_test_failure(struct kunit *test) 40 void add_test_basic(struct kunit *test) 48 ``struct kunit *``, which contains information about the current test context. 59 To learn about more KUnit expectations, see Documentation/dev-tools/kunit/api/test.rst. 71 void add_test_basic(struct kunit *test) 77 void add_test_negative(struct kunit *test) 82 void add_test_max(struct kunit *test) [all …]
|
/linux/drivers/firewire/ |
H A D | Kconfig | 22 tristate "KUnit tests for layout of structure in UAPI" if !KUNIT_ALL_TESTS 23 depends on FIREWIRE && KUNIT 26 This builds the KUnit tests whether structures exposed to user 29 KUnit tests run during boot and output the results to the debug 31 kernel devs running KUnit test harness and are not for inclusion 34 For more information on KUnit and unit tests in general, refer 35 to the KUnit documentation in Documentation/dev-tools/kunit/. 38 tristate "KUnit tests for device attributes" if !KUNIT_ALL_TESTS 39 depends on FIREWIRE && KUNIT 42 This builds the KUnit tests for device attribute for node and [all …]
|
/linux/lib/crypto/tests/ |
H A D | Kconfig | 4 tristate "KUnit tests for Poly1305" if !KUNIT_ALL_TESTS 5 depends on KUNIT 10 KUnit tests for the Poly1305 library functions. 13 tristate "KUnit tests for SHA-1" if !KUNIT_ALL_TESTS 14 depends on KUNIT 19 KUnit tests for the SHA-1 cryptographic hash function and its 25 tristate "KUnit tests for SHA-224 and SHA-256" if !KUNIT_ALL_TESTS 26 depends on KUNIT 31 KUnit tests for the SHA-224 and SHA-256 cryptographic hash functions 37 tristate "KUnit tests for SHA-384 and SHA-512" if !KUNIT_ALL_TESTS [all …]
|
/linux/Documentation/dev-tools/kunit/api/ |
H A D | index.rst | 17 This page documents the KUnit kernel testing API. It is divided into the 20 Core KUnit API 23 Documentation/dev-tools/kunit/api/test.rst 27 Documentation/dev-tools/kunit/api/resource.rst 29 - Documents the KUnit resource API 31 Documentation/dev-tools/kunit/api/functionredirection.rst 33 - Documents the KUnit Function Redirection API 35 Driver KUnit API 38 Documentation/dev-tools/kunit/api/clk.rst 40 - Documents the KUnit clk API [all …]
|
/linux/sound/soc/ |
H A D | soc-topology-test.c | 12 #include <kunit/device.h> 13 #include <kunit/test.h> 25 static int snd_soc_tplg_test_init(struct kunit *test) in snd_soc_tplg_test_init() 35 static void snd_soc_tplg_test_exit(struct kunit *test) in snd_soc_tplg_test_exit() 42 * component probe, we need to pass struct kunit somehow to probe function, so 46 struct kunit *kunit; member 60 KUNIT_EXPECT_EQ_MSG(kunit_comp->kunit, kunit_comp->expect, ret, in d_probe() 73 KUNIT_EXPECT_EQ(kunit_comp->kunit, 0, ret); in d_remove() 85 .name = "KUNIT Audio Port", 171 .pcm_name = "KUNIT Audio", [all …]
|
/linux/tools/testing/kunit/ |
H A D | kunit_tool_test.py | 4 # A collection of tests for tools/testing/kunit/kunit.py 25 import kunit 116 self.assertContains('# Subtest: kunit-resource-test', result) 124 self.assertContains('ok 1 - kunit-resource-test', result) 125 self.assertContains('foo bar # non-kunit output', result) 126 self.assertContains('# Subtest: kunit-try-catch-test', result) 132 self.assertContains('ok 2 - kunit-try-catch-test', result) 256 self.assertEqual('kunit-resource-test', result.subtests[0].name) 264 self.assertEqual('kunit-resource-test', result.subtests[0].name) 272 self.assertEqual('kunit-resource-test', result.subtests[0].name) [all …]
|
/linux/drivers/iio/test/ |
H A D | Kconfig | 9 depends on KUNIT 16 For more information on KUnit and unit tests in general, please refer 17 to the KUnit documentation in Documentation/dev-tools/kunit/. 23 depends on KUNIT && IIO_RESCALE 28 For more information on KUnit and unit tests in general, please refer 29 to the KUnit documentation in Documentation/dev-tools/kunit/. 35 depends on KUNIT 40 For more information on KUnit and unit tests in general, please refer 41 to the KUnit documentation in Documentation/dev-tools/kunit/.
|
/linux/drivers/gpu/drm/xe/tests/ |
H A D | xe_kunit_helpers.c | 6 #include <kunit/test.h> 7 #include <kunit/static_stub.h> 8 #include <kunit/visibility.h> 20 * xe_kunit_helper_alloc_xe_device - Allocate a &xe_device for a KUnit test. 21 * @test: the &kunit where this &xe_device will be used 33 struct xe_device *xe_kunit_helper_alloc_xe_device(struct kunit *test, in xe_kunit_helper_alloc_xe_device() 48 struct kunit *test = kunit_get_current_test(); in kunit_action_restore_priv() 54 * xe_kunit_helper_xe_device_test_init - Prepare a &xe_device for a KUnit test. 55 * @test: the &kunit where this fake &xe_device will be used 58 * pointer as &kunit.priv to allow the test code to access it. [all …]
|
/linux/include/kunit/ |
H A D | test-bug.h | 3 * KUnit API providing hooks for non-test code to interact with tests. 19 /* Static key if KUnit is running any tests. */ 22 /* Hooks table: a table of function pointers filled in when kunit loads */ 25 void *(*get_static_stub_address)(struct kunit *test, void *real_fn_addr); 30 * KUnit test. 32 * If a KUnit test is running in the current task, returns a pointer to its 33 * associated struct kunit. This pointer can then be passed to any KUnit 37 * This function is safe to call even when KUnit is disabled. If CONFIG_KUNIT 41 static inline struct kunit *kunit_get_current_test(void) in kunit_get_current_test() 51 * kunit_fail_current_test() - If a KUnit test is running, fail it. [all …]
|
H A D | device.h | 3 * KUnit basic device implementation 5 * Helpers for creating and managing fake devices for KUnit tests. 16 #include <kunit/test.h> 29 * Return: a stub struct device_driver, managed by KUnit, with the name @name. 31 struct device_driver *kunit_driver_create(struct kunit *test, const char *name); 34 * kunit_device_register() - Create a struct device for use in KUnit tests 47 struct device *kunit_device_register(struct kunit *test, const char *name); 50 * kunit_device_register_with_driver() - Create a struct device for use in KUnit tests 58 * wish KUnit to create and manage a driver for you. 63 struct device *kunit_device_register_with_driver(struct kunit *test, [all …]
|
/linux/rust/kernel/ |
H A D | kunit.rs | 3 //! KUnit-based macros for Rust unit tests. 5 //! C header: [`include/kunit/test.h`](srctree/include/kunit/test.h) 7 //! Reference: <https://docs.kernel.org/dev-tools/kunit/index.html> 15 /// Prints a KUnit error-level message. 17 /// Public but hidden since it should only be used from KUnit generated code. 31 /// Prints a KUnit info-level message. 33 /// Public but hidden since it should only be used from KUnit generated code. 51 /// Unlike the one in `core`, this one does not panic; instead, it is mapped to the KUnit 70 // The assertion failed but this task is not running a KUnit test, so we cannot call 71 // KUnit, but at least print an error to the kernel log. This may happen if this [all …]
|
/linux/include/drm/ |
H A D | drm_kunit_helpers.h | 10 #include <kunit/test.h> 18 struct kunit; 20 struct device *drm_kunit_helper_alloc_device(struct kunit *test); 21 void drm_kunit_helper_free_device(struct kunit *test, struct device *dev); 24 __drm_kunit_helper_alloc_drm_device_with_driver(struct kunit *test, 30 * drm_kunit_helper_alloc_drm_device_with_driver - Allocates a mock DRM device for KUnit tests 56 __drm_kunit_helper_alloc_drm_device(struct kunit *test, in __drm_kunit_helper_alloc_drm_device() 74 * drm_kunit_helper_alloc_drm_device - Allocates a mock DRM device for KUnit tests 101 drm_kunit_helper_atomic_state_alloc(struct kunit *test, 106 drm_kunit_helper_create_primary_plane(struct kunit *test, [all …]
|
/linux/drivers/iommu/arm/arm-smmu-v3/ |
H A D | arm-smmu-v3-test.c | 5 #include <kunit/test.h> 12 struct kunit *test; 117 struct kunit *test, const struct arm_smmu_ste *cur, in arm_smmu_v3_test_ste_expect_transition() 153 struct kunit *test, const struct arm_smmu_ste *cur, in arm_smmu_v3_test_ste_expect_non_hitless_transition() 161 struct kunit *test, const struct arm_smmu_ste *cur, in arm_smmu_v3_test_ste_expect_hitless_transition() 190 static void arm_smmu_v3_write_ste_test_bypass_to_abort(struct kunit *test) in arm_smmu_v3_write_ste_test_bypass_to_abort() 202 static void arm_smmu_v3_write_ste_test_abort_to_bypass(struct kunit *test) in arm_smmu_v3_write_ste_test_abort_to_bypass() 213 static void arm_smmu_v3_write_ste_test_cdtable_to_abort(struct kunit *test) in arm_smmu_v3_write_ste_test_cdtable_to_abort() 223 static void arm_smmu_v3_write_ste_test_abort_to_cdtable(struct kunit *test) in arm_smmu_v3_write_ste_test_abort_to_cdtable() 233 static void arm_smmu_v3_write_ste_test_cdtable_to_bypass(struct kunit *test) in arm_smmu_v3_write_ste_test_cdtable_to_bypass() [all …]
|
/linux/lib/ |
H A D | Kconfig.debug | 1949 source "lib/kunit/Kconfig" 2262 tristate "KUnit test for cpumask" if !KUNIT_ALL_TESTS 2263 depends on KUNIT 2268 For more information on KUnit and unit tests in general, please refer 2269 to the KUnit documentation in Documentation/dev-tools/kunit/. 2275 depends on KUNIT 2296 depends on KUNIT 2326 depends on KUNIT 2340 depends on KUNIT 2354 depends on KUNIT=y [all …]
|
/linux/Documentation/rust/ |
H A D | testing.rst | 11 - The KUnit tests. 15 The KUnit tests 19 get transformed into KUnit tests. 24 These tests can be run via KUnit. For example via ``kunit_tool`` (``kunit.py``) 27 ./tools/testing/kunit/kunit.py run --make_options LLVM=1 --arch x86_64 --kconfig_add CONFIG_RUST=y 29 Alternatively, KUnit can run them as kernel built-in at boot. Refer to 30 Documentation/dev-tools/kunit/index.rst for the general KUnit documentation 31 and Documentation/dev-tools/kunit/architecture.rst for the details of kernel 34 To use these KUnit doctests, the following must be enabled:: 37 Kernel hacking -> Kernel Testing and Coverage -> KUnit - Enable support for unit tests [all …]
|