| /linux/drivers/gpu/drm/xe/tests/ |
| H A D | xe_sriov_pf_service_kunit.c | 1 // SPDX-License-Identifier: GPL-2.0 AND MIT 3 * Copyright © 2024-2025 Intel Corporation 6 #include <kunit/test.h> 12 static int pf_service_test_init(struct kunit *test) in pf_service_test_init() 21 test->priv = &fake; in pf_service_test_init() 24 xe = test->priv; in pf_service_test_init() 30 * - all supported platforms VF/PF ABI versions must be defined in pf_service_test_init() 31 * - base version can't be newer than latest in pf_service_test_init() 33 KUNIT_ASSERT_NE(test, 0, xe->sriov.pf.service.version.base.major); in pf_service_test_init() 34 KUNIT_ASSERT_NE(test, 0, xe->sriov.pf.service.version.latest.major); in pf_service_test_init() [all …]
|
| H A D | xe_test.h | 1 /* SPDX-License-Identifier: GPL-2.0 AND MIT */ 12 #include <kunit/test.h> 13 #include <kunit/test-bug.h> 16 * Each test that provides a kunit private test structure, place a test id 17 * here and point the kunit->priv to an embedded struct xe_test_priv. 25 * struct xe_test_priv - Base class for test private info 36 * xe_cur_kunit_priv - Obtain the struct xe_test_priv pointed to by 37 * current->kunit->priv if it exists and is embedded in the expected subclass. 40 * Return: NULL if the process is not a kunit test, and NULL if the 41 * current kunit->priv pointer is not pointing to an object of the expected [all …]
|
| H A D | xe_bo.c | 1 // SPDX-License-Identifier: GPL-2.0 AND MIT 6 #include <kunit/test.h> 7 #include <kunit/visibility.h> 9 #include <linux/iosys-map.h> 26 struct kunit *test, struct drm_exec *exec) in ccs_test_migrate() 46 fence = xe_migrate_clear(tile->migrate, bo, bo->ttm.resource, in ccs_test_migrate() 56 return -ETIME; in ccs_test_migrate() 70 timeout = dma_resv_wait_timeout(bo->ttm.base.resv, in ccs_test_migrate() 76 return -ETIME; in ccs_test_migrate() 84 ttm = bo->ttm.ttm; in ccs_test_migrate() [all …]
|
| H A D | xe_guc_buf_kunit.c | 1 // SPDX-License-Identifier: GPL-2.0 AND MIT 6 #include <kunit/static_stub.h> 7 #include <kunit/test.h> 8 #include <kunit/test-bug.h> 23 struct kunit *test = kunit_get_current_test(); in replacement_xe_managed_bo_create_pin_map() 27 bo = drmm_kzalloc(&xe->drm, sizeof(*bo), GFP_KERNEL); in replacement_xe_managed_bo_create_pin_map() 30 buf = drmm_kzalloc(&xe->drm, size, GFP_KERNEL); in replacement_xe_managed_bo_create_pin_map() 33 bo->tile = tile; in replacement_xe_managed_bo_create_pin_map() 34 bo->ttm.bdev = &xe->ttm; in replacement_xe_managed_bo_create_pin_map() 35 bo->ttm.base.size = size; in replacement_xe_managed_bo_create_pin_map() [all …]
|
| /linux/drivers/gpu/drm/tests/ |
| H A D | drm_connector_test.c | 1 // SPDX-License-Identifier: GPL-2.0 3 * Kunit test for drm_modes functions 18 #include <kunit/test.h> 60 static int drm_test_connector_init(struct kunit *test) in drm_test_connector_init() 74 strscpy(priv->ddc.name, "dummy-connector-ddc", sizeof(priv->ddc.name)); in drm_test_connector_init() 75 priv->ddc.owner = THIS_MODULE; in drm_test_connector_init() 76 priv->ddc.algo = &dummy_ddc_algorithm; in drm_test_connector_init() 77 priv->ddc.dev.parent = dev; in drm_test_connector_init() 79 ret = i2c_add_adapter(&priv->ddc); in drm_test_connector_init() 82 ret = kunit_add_action_or_reset(test, i2c_del_adapter_wrapper, &priv->ddc); in drm_test_connector_init() [all …]
|
| H A D | drm_gem_shmem_test.c | 1 // SPDX-License-Identifier: GPL-2.0 3 * KUnit test suite for GEM objects backed by shmem buffers 10 #include <linux/dma-buf.h> 11 #include <linux/iosys-map.h> 14 #include <kunit/test.h> 43 static void drm_gem_shmem_test_obj_create(struct kunit *test) in drm_gem_shmem_test_obj_create() 45 struct drm_device *drm_dev = test->priv; in drm_gem_shmem_test_obj_create() 50 KUNIT_EXPECT_EQ(test, shmem->base.size, TEST_SIZE); in drm_gem_shmem_test_obj_create() 51 KUNIT_EXPECT_NOT_NULL(test, shmem->base.filp); in drm_gem_shmem_test_obj_create() 52 KUNIT_EXPECT_NOT_NULL(test, shmem->base.funcs); in drm_gem_shmem_test_obj_create() [all …]
|
| H A D | drm_framebuffer_test.c | 1 // SPDX-License-Identifier: GPL-2.0 8 #include <kunit/device.h> 9 #include <kunit/test.h> 52 .handles = { 1, 0, 0 }, .pitches = { 4 * MAX_WIDTH - 1, 0, 0 }, 82 .handles = { 1, 0, 0 }, .offsets = { UINT_MAX - 1, 0, 0 }, 94 * All entries in members that represents per-plane values (@modifier, @handles, 155 .handles = { 1, 1, 0 }, .pitches = { MAX_WIDTH, MAX_WIDTH - 1, 0 }, 164 { .buffer_created = 0, .name = "NV12 different modifier per-plane", 224 .handles = { 1, 1, 1 }, .pitches = { MAX_WIDTH, DIV_ROUND_UP(MAX_WIDTH, 2) - 1, 308 .handles = { 1, 0, 0 }, .pitches = { 2 * MAX_WIDTH - 1, 0, 0 } [all …]
|
| H A D | drm_damage_helper_test.c | 1 // SPDX-License-Identifier: GPL-2.0 8 #include <kunit/test.h> 26 static int drm_damage_helper_init(struct kunit *test) in drm_damage_helper_init() 33 mock->fb.width = 2048; in drm_damage_helper_init() 34 mock->fb.height = 2048; in drm_damage_helper_init() 36 mock->state.crtc = ZERO_SIZE_PTR; in drm_damage_helper_init() 37 mock->state.fb = &mock->fb; in drm_damage_helper_init() 38 mock->state.visible = true; in drm_damage_helper_init() 40 mock->old_state.plane = &mock->plane; in drm_damage_helper_init() 41 mock->state.plane = &mock->plane; in drm_damage_helper_init() [all …]
|
| H A D | drm_probe_helper_test.c | 1 // SPDX-License-Identifier: GPL-2.0 3 * Kunit test for drm_probe_helper functions 16 #include <kunit/test.h> 33 static int drm_probe_helper_test_init(struct kunit *test) in drm_probe_helper_test_init() 41 test->priv = priv; in drm_probe_helper_test_init() 43 priv->dev = drm_kunit_helper_alloc_device(test); in drm_probe_helper_test_init() 44 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->dev); in drm_probe_helper_test_init() 46 priv->drm = __drm_kunit_helper_alloc_drm_device(test, priv->dev, in drm_probe_helper_test_init() 47 sizeof(*priv->drm), 0, in drm_probe_helper_test_init() 49 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm); in drm_probe_helper_test_init() [all …]
|
| /linux/drivers/gpu/drm/ttm/tests/ |
| H A D | ttm_tt_test.c | 1 // SPDX-License-Identifier: GPL-2.0 AND MIT 20 .description = "Page-aligned size", 33 strscpy(desc, t->description, KUNIT_PARAM_DESC_SIZE); in ttm_tt_init_case_desc() 39 static void ttm_tt_init_basic(struct kunit *test) in ttm_tt_init_basic() 41 const struct ttm_tt_test_case *params = test->param_value; in ttm_tt_init_basic() 46 u32 extra_pages = params->extra_pages_num; in ttm_tt_init_basic() 47 int num_pages = params->size >> PAGE_SHIFT; in ttm_tt_init_basic() 53 bo = ttm_bo_kunit_init(test, test->priv, params->size, NULL); in ttm_tt_init_basic() 58 KUNIT_ASSERT_EQ(test, tt->num_pages, num_pages + extra_pages); in ttm_tt_init_basic() 60 KUNIT_ASSERT_EQ(test, tt->page_flags, page_flags); in ttm_tt_init_basic() [all …]
|
| H A D | ttm_bo_validate_test.c | 1 // SPDX-License-Identifier: GPL-2.0 AND MIT 28 static struct ttm_placement *ttm_placement_kunit_init(struct kunit *test, in ttm_placement_kunit_init() 37 placement->num_placement = num_places; in ttm_placement_kunit_init() 38 placement->placement = places; in ttm_placement_kunit_init() 45 return "ttm-bo-validate-fence"; in fence_name() 53 static struct dma_fence *alloc_mock_fence(struct kunit *test) in alloc_mock_fence() 65 static void dma_resv_kunit_active_fence_init(struct kunit *test, in dma_resv_kunit_active_fence_init() 83 strscpy(desc, t->description, KUNIT_PARAM_DESC_SIZE); in ttm_bo_validate_case_desc() 104 static void ttm_bo_init_reserved_sys_man(struct kunit *test) in ttm_bo_init_reserved_sys_man() 106 const struct ttm_bo_validate_test_case *params = test->param_value; in ttm_bo_init_reserved_sys_man() [all …]
|
| H A D | ttm_resource_test.c | 1 // SPDX-License-Identifier: GPL-2.0 AND MIT 10 #define TTM_PRIV_DUMMY_REG (TTM_NUM_MEM_TYPES - 1) 26 static int ttm_resource_test_init(struct kunit *test) in ttm_resource_test_init() 33 priv->devs = ttm_test_devices_all(test); in ttm_resource_test_init() 34 KUNIT_ASSERT_NOT_NULL(test, priv->devs); in ttm_resource_test_init() 36 test->priv = priv; in ttm_resource_test_init() 41 static void ttm_resource_test_fini(struct kunit *test) in ttm_resource_test_fini() 43 struct ttm_resource_test_priv *priv = test->priv; in ttm_resource_test_fini() 45 ttm_test_devices_put(test, priv->devs); in ttm_resource_test_fini() 48 static void ttm_init_test_mocks(struct kunit *test, in ttm_init_test_mocks() [all …]
|
| /linux/kernel/ |
| H A D | resource_kunit.c | 1 // SPDX-License-Identifier: GPL-2.0+ 6 #include <kunit/test.h> 85 static void resource_do_test(struct kunit *test, bool ret, struct resource *r, in resource_do_test() 90 KUNIT_EXPECT_EQ_MSG(test, r->start, exp_r->start, "Start elements are not equal"); in resource_do_test() 91 KUNIT_EXPECT_EQ_MSG(test, r->end, exp_r->end, "End elements are not equal"); in resource_do_test() 94 static void resource_do_union_test(struct kunit *test, struct result *r) in resource_do_union_test() 100 ret = resource_union(r->r1, r->r2, &result); in resource_do_union_test() 101 resource_do_test(test, ret, &result, r->ret, &r->r, r->r1, r->r2); in resource_do_union_test() 104 ret = resource_union(r->r2, r->r1, &result); in resource_do_union_test() 105 resource_do_test(test, ret, &result, r->ret, &r->r, r->r2, r->r1); in resource_do_union_test() [all …]
|
| /linux/drivers/gpu/drm/vc4/tests/ |
| H A D | vc4_mock.c | 1 // SPDX-License-Identifier: GPL-2.0 6 #include <kunit/test.h> 38 VC4_MOCK_CRTC_DESC(&(_data)->base, __VA_ARGS__) 54 VC4_MOCK_CRTC_DESC(&bcm2835_txp_data.base, 80 VC4_MOCK_CRTC_DESC(&bcm2835_txp_data.base, 109 static int __build_one_pipe(struct kunit *test, struct drm_device *drm, in __build_one_pipe() 120 dummy_crtc = vc4_mock_pv(test, drm, plane, pipe->data); in __build_one_pipe() 123 crtc = &dummy_crtc->crtc.base; in __build_one_pipe() 124 for (i = 0; i < pipe->noutputs; i++) { in __build_one_pipe() 125 const struct vc4_mock_output_desc *mock_output = &pipe->outputs[i]; in __build_one_pipe() [all …]
|
| H A D | vc4_mock.h | 1 /* SPDX-License-Identifier: GPL-2.0 */ 9 struct drm_crtc *vc4_find_crtc_for_encoder(struct kunit *test, in vc4_find_crtc_for_encoder() 15 KUNIT_ASSERT_EQ(test, hweight32(encoder->possible_crtcs), 1); in vc4_find_crtc_for_encoder() 18 if (encoder->possible_crtcs & drm_crtc_mask(crtc)) in vc4_find_crtc_for_encoder() 24 struct drm_plane *vc4_dummy_plane(struct kunit *test, struct drm_device *drm, 31 struct vc4_dummy_crtc *vc4_mock_pv(struct kunit *test, 42 container_of_const(_enc, struct vc4_dummy_output, encoder.base) 44 struct vc4_dummy_output *vc4_dummy_output(struct kunit *test, 51 struct vc4_dev *vc4_mock_device(struct kunit *test); 52 struct vc4_dev *vc5_mock_device(struct kunit *test); [all …]
|
| /linux/drivers/pinctrl/qcom/ |
| H A D | tlmm-test.c | 1 // SPDX-License-Identifier: GPL-2.0-only 6 #define pr_fmt(fmt) "tlmm-test: " fmt 8 #include <kunit/test.h> 23 * (pinctrl-msm) delivers expected number of interrupts in response to changing 27 * "gpio", which the tester is expected to specify an unused and non-connected 41 static int tlmm_test_gpio = -1; 48 void __iomem *base; member 57 * struct tlmm_test_priv - Per-test context 102 if (priv->intr_op & TLMM_TEST_COUNT) in tlmm_test_intr_fn() 103 atomic_inc(&priv->intr_count); in tlmm_test_intr_fn() [all …]
|
| /linux/lib/math/tests/ |
| H A D | int_pow_kunit.c | 1 // SPDX-License-Identifier: GPL-2.0-only 3 #include <kunit/test.h> 7 u64 base; member 16 { 0, 5, 0, "Base zero" }, 17 { 1, 64, 1, "Base one" }, 21 { U64_MAX, 1, U64_MAX, "Max base" }, 27 strscpy(desc, tc->name, KUNIT_PARAM_DESC_SIZE); in get_desc() 32 static void int_pow_test(struct kunit *test) in int_pow_test() 34 const struct test_case_params *tc = (const struct test_case_params *)test->param_value; in int_pow_test() 36 KUNIT_EXPECT_EQ(test, tc->expected_result, int_pow(tc->base, tc->exponent)); in int_pow_test() [all …]
|
| /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 | test.c | 1 // SPDX-License-Identifier: GPL-2.0 3 * Base unit test (KUnit) API. 9 #include <kunit/resource.h> 10 #include <kunit/test.h> 11 #include <kunit/test-bug.h> 12 #include <kunit/attributes.h> 23 #include "device-impl.h" 24 #include "hooks-impl.h" 25 #include "string-stream.h" 26 #include "try-catch-impl.h" [all …]
|
| /linux/drivers/firmware/cirrus/test/ |
| H A D | cs_dsp_test_bin_error.c | 1 // SPDX-License-Identifier: GPL-2.0-only 3 // KUnit tests for cs_dsp. 9 #include <kunit/device.h> 10 #include <kunit/resource.h> 11 #include <kunit/test.h> 49 static void bin_load_with_unknown_blocks(struct kunit *test) in bin_load_with_unknown_blocks() 51 struct cs_dsp_test *priv = test->priv; in bin_load_with_unknown_blocks() 52 struct cs_dsp_test_local *local = priv->local; in bin_load_with_unknown_blocks() 68 cs_dsp_mock_bin_add_raw_block(local->bin_builder, in bin_load_with_unknown_blocks() 73 cs_dsp_mock_bin_add_raw_block(local->bin_builder, in bin_load_with_unknown_blocks() [all …]
|
| H A D | cs_dsp_test_wmfw_error.c | 1 // SPDX-License-Identifier: GPL-2.0-only 3 // KUnit tests for cs_dsp. 9 #include <kunit/device.h> 10 #include <kunit/resource.h> 11 #include <kunit/test.h> 55 static void wmfw_load_with_unknown_blocks(struct kunit *test) in wmfw_load_with_unknown_blocks() 57 struct cs_dsp_test *priv = test->priv; in wmfw_load_with_unknown_blocks() 58 struct cs_dsp_test_local *local = priv->local; in wmfw_load_with_unknown_blocks() 66 cs_dsp_mock_wmfw_add_data_block(local->wmfw_builder, in wmfw_load_with_unknown_blocks() 68 local->xm_header->blob_data, in wmfw_load_with_unknown_blocks() [all …]
|
| /linux/Documentation/dev-tools/kunit/ |
| H A D | style.rst | 1 .. SPDX-License-Identifier: GPL-2.0 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. 17 example, non-deterministically producing false positives or negatives, or 29 ---------- 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 59 ``linear-ranges`` [all …]
|
| /linux/drivers/base/ |
| H A D | Kconfig | 1 # SPDX-License-Identifier: GPL-2.0 12 Before the switch to the netlink-based uevent source, this was 19 it is known to create out-of-memory situations during bootup. 73 with the PROT_EXEC flag. This can break, for example, non-KMS 77 bool "Select only drivers that don't need compile-time external firmware" 104 source "drivers/base/firmware_loader/Kconfig" 146 non-zero, devres debug messages are printed. Select this if 166 bool "KUnit Test for PM QoS features" if !KUNIT_ALL_TESTS 167 depends on KUNIT=y 171 tristate "KUnit Tests for runtime PM" if !KUNIT_ALL_TESTS [all …]
|
| /linux/scripts/ |
| H A D | rustdoc_test_gen.rs | 1 // SPDX-License-Identifier: GPL-2.0 3 //! Generates KUnit tests from saved `rustdoc`-generated tests. 5 //! KUnit passes a context (`struct kunit *`) to each test, which should be forwarded to the other 6 //! KUnit functions and macros. 10 //! - Test code should not care about the implementation. 12 //! - Documentation looks worse if it needs to carry extra details unrelated to the piece 15 //! - Test code should be able to define functions and call them, without having to carry 18 //! - Later on, we may want to be able to test non-kernel code (e.g. `core` or third-party 22 //! (i.e. `current->kunit_test`). 26 //! e.g. a `static` per test does not fully solve the issue either, because currently KUnit does [all …]
|
| /linux/sound/hda/codecs/side-codecs/ |
| H A D | cirrus_scodec_test.c | 1 // SPDX-License-Identifier: GPL-2.0-only 3 // KUnit test for the Cirrus side-codec library. 8 #include <kunit/platform_device.h> 9 #include <kunit/resource.h> 10 #include <kunit/test.h> 52 return !!(gpio_priv->pin_state & BIT(offset)); in cirrus_scodec_test_gpio_get() 58 return -EOPNOTSUPP; in cirrus_scodec_test_gpio_direction_out() 64 return -EOPNOTSUPP; in cirrus_scodec_test_gpio_set() 74 return -EOPNOTSUPP; in cirrus_scodec_test_gpio_set_config() 91 .base = -1, [all …]
|