One-to-one conversion, no functional changes.
Now that all of the modeset selftests were converted, remove the helpers that are no longer used.
Signed-off-by: Michał Winiarski michal.winiarski@intel.com --- drivers/gpu/drm/selftests/Makefile | 8 +- .../gpu/drm/selftests/drm_modeset_selftests.h | 12 - .../drm/selftests/test-drm_modeset_common.c | 32 --- .../drm/selftests/test-drm_modeset_common.h | 24 -- drivers/gpu/drm/selftests/test-drm_rect.c | 212 ++++++++++-------- 5 files changed, 122 insertions(+), 166 deletions(-) delete mode 100644 drivers/gpu/drm/selftests/drm_modeset_selftests.h delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.c delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.h
diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index 77e37eebf099..2d524eddb4e3 100644 --- a/drivers/gpu/drm/selftests/Makefile +++ b/drivers/gpu/drm/selftests/Makefile @@ -1,11 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only -test-drm_modeset-$(CONFIG_DRM_DEBUG_SELFTEST) := \ - test-drm_modeset_common.o \ - test-drm_rect.o
-obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o +obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o
obj-$(CONFIG_DRM_KUNIT_TEST) := \ test-drm_cmdline_parser.o test-drm_plane_helper.o \ test-drm_format.o test-drm_framebuffer.o \ - test-drm_damage_helper.o test-drm_dp_mst_helper.o + test-drm_damage_helper.o test-drm_dp_mst_helper.o \ + test-drm_rect.o diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h deleted file mode 100644 index 630770d30aba..000000000000 --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* List each unit test as selftest(name, function) - * - * The name is used as both an enum and expanded as igt__name to create - * a module parameter. It must be unique and legal for a C identifier. - * - * Tests are executed in order by igt/drm_selftests_helper - */ -selftest(drm_rect_clip_scaled_div_by_zero, igt_drm_rect_clip_scaled_div_by_zero) -selftest(drm_rect_clip_scaled_not_clipped, igt_drm_rect_clip_scaled_not_clipped) -selftest(drm_rect_clip_scaled_clipped, igt_drm_rect_clip_scaled_clipped) -selftest(drm_rect_clip_scaled_signed_vs_unsigned, igt_drm_rect_clip_scaled_signed_vs_unsigned) diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.c b/drivers/gpu/drm/selftests/test-drm_modeset_common.c deleted file mode 100644 index 2a7f93774006..000000000000 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.c +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Common file for modeset selftests. - */ - -#include <linux/module.h> - -#include "test-drm_modeset_common.h" - -#define TESTS "drm_modeset_selftests.h" -#include "drm_selftest.h" - -#include "drm_selftest.c" - -static int __init test_drm_modeset_init(void) -{ - int err; - - err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL); - - return err > 0 ? 0 : err; -} - -static void __exit test_drm_modeset_exit(void) -{ -} - -module_init(test_drm_modeset_init); -module_exit(test_drm_modeset_exit); - -MODULE_AUTHOR("Intel Corporation"); -MODULE_LICENSE("GPL"); diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h deleted file mode 100644 index c7cc5edc65f1..000000000000 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -#ifndef __TEST_DRM_MODESET_COMMON_H__ -#define __TEST_DRM_MODESET_COMMON_H__ - -#include <linux/errno.h> -#include <linux/printk.h> - -#define FAIL(test, msg, ...) \ - do { \ - if (test) { \ - pr_err("%s/%u: " msg, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ - return -EINVAL; \ - } \ - } while (0) - -#define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n") - -int igt_drm_rect_clip_scaled_div_by_zero(void *ignored); -int igt_drm_rect_clip_scaled_not_clipped(void *ignored); -int igt_drm_rect_clip_scaled_clipped(void *ignored); -int igt_drm_rect_clip_scaled_signed_vs_unsigned(void *ignored); - -#endif diff --git a/drivers/gpu/drm/selftests/test-drm_rect.c b/drivers/gpu/drm/selftests/test-drm_rect.c index 3a5ff38321f4..f3d26c31ee66 100644 --- a/drivers/gpu/drm/selftests/test-drm_rect.c +++ b/drivers/gpu/drm/selftests/test-drm_rect.c @@ -3,15 +3,12 @@ * Test cases for the drm_rect functions */
-#define pr_fmt(fmt) "drm_rect: " fmt - +#include <kunit/test.h> #include <linux/limits.h>
#include <drm/drm_rect.h>
-#include "test-drm_modeset_common.h" - -int igt_drm_rect_clip_scaled_div_by_zero(void *ignored) +static void drm_rect_clip_scaled_div_by_zero(struct kunit *test) { struct drm_rect src, dst, clip; bool visible; @@ -23,21 +20,23 @@ int igt_drm_rect_clip_scaled_div_by_zero(void *ignored) drm_rect_init(&src, 0, 0, 0, 0); drm_rect_init(&dst, 0, 0, 0, 0); drm_rect_init(&clip, 1, 1, 1, 1); + visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(visible, "Destination not be visible\n"); - FAIL(drm_rect_visible(&src), "Source should not be visible\n"); + + KUNIT_EXPECT_FALSE_MSG(test, visible, "Destination not be visible"); + KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible");
drm_rect_init(&src, 0, 0, 0, 0); drm_rect_init(&dst, 3, 3, 0, 0); drm_rect_init(&clip, 1, 1, 1, 1); + visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(visible, "Destination not be visible\n"); - FAIL(drm_rect_visible(&src), "Source should not be visible\n");
- return 0; + KUNIT_EXPECT_FALSE_MSG(test, visible, "Destination not be visible"); + KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible"); }
-int igt_drm_rect_clip_scaled_not_clipped(void *ignored) +static void drm_rect_clip_scaled_not_clipped(struct kunit *test) { struct drm_rect src, dst, clip; bool visible; @@ -49,14 +48,16 @@ int igt_drm_rect_clip_scaled_not_clipped(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(src.x1 != 0 || src.x2 != 1 << 16 || - src.y1 != 0 || src.y2 != 1 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 1 || - dst.y1 != 0 || dst.y2 != 1, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 1 << 16 && + src.y1 == 0 && src.y2 == 1 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 1 && + dst.y1 == 0 && dst.y2 == 1, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible");
/* 2:1 scaling */ drm_rect_init(&src, 0, 0, 2 << 16, 2 << 16); @@ -65,14 +66,16 @@ int igt_drm_rect_clip_scaled_not_clipped(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(src.x1 != 0 || src.x2 != 2 << 16 || - src.y1 != 0 || src.y2 != 2 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 1 || - dst.y1 != 0 || dst.y2 != 1, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 2 << 16 && + src.y1 == 0 && src.y2 == 2 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 1 && + dst.y1 == 0 && dst.y2 == 1, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible");
/* 1:2 scaling */ drm_rect_init(&src, 0, 0, 1 << 16, 1 << 16); @@ -81,19 +84,19 @@ int igt_drm_rect_clip_scaled_not_clipped(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(src.x1 != 0 || src.x2 != 1 << 16 || - src.y1 != 0 || src.y2 != 1 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 2 || - dst.y1 != 0 || dst.y2 != 2, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); - - return 0; + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 1 << 16 && + src.y1 == 0 && src.y2 == 1 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 2 && + dst.y1 == 0 && dst.y2 == 2, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); }
-int igt_drm_rect_clip_scaled_clipped(void *ignored) +static void drm_rect_clip_scaled_clipped(struct kunit *test) { struct drm_rect src, dst, clip; bool visible; @@ -105,14 +108,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(src.x1 != 0 || src.x2 != 1 << 16 || - src.y1 != 0 || src.y2 != 1 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 1 || - dst.y1 != 0 || dst.y2 != 1, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 1 << 16 && + src.y1 == 0 && src.y2 == 1 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 1 && + dst.y1 == 0 && dst.y2 == 1, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible");
/* 1:1 scaling bottom/right clip */ drm_rect_init(&src, 0, 0, 2 << 16, 2 << 16); @@ -121,14 +126,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(src.x1 != 1 << 16 || src.x2 != 2 << 16 || - src.y1 != 1 << 16 || src.y2 != 2 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 1 || dst.x2 != 2 || - dst.y1 != 1 || dst.y2 != 2, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 1 << 16 && src.x2 == 2 << 16 && + src.y1 == 1 << 16 && src.y2 == 2 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 1 && dst.x2 == 2 && + dst.y1 == 1 && dst.y2 == 2, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible");
/* 2:1 scaling top/left clip */ drm_rect_init(&src, 0, 0, 4 << 16, 4 << 16); @@ -137,14 +144,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(src.x1 != 0 || src.x2 != 2 << 16 || - src.y1 != 0 || src.y2 != 2 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 1 || - dst.y1 != 0 || dst.y2 != 1, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 2 << 16 && + src.y1 == 0 && src.y2 == 2 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 1 && + dst.y1 == 0 && dst.y2 == 1, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible");
/* 2:1 scaling bottom/right clip */ drm_rect_init(&src, 0, 0, 4 << 16, 4 << 16); @@ -153,14 +162,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(src.x1 != 2 << 16 || src.x2 != 4 << 16 || - src.y1 != 2 << 16 || src.y2 != 4 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 1 || dst.x2 != 2 || - dst.y1 != 1 || dst.y2 != 2, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 2 << 16 && src.x2 == 4 << 16 && + src.y1 == 2 << 16 && src.y2 == 4 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 1 && dst.x2 == 2 && + dst.y1 == 1 && dst.y2 == 2, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible");
/* 1:2 scaling top/left clip */ drm_rect_init(&src, 0, 0, 2 << 16, 2 << 16); @@ -169,14 +180,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(src.x1 != 0 || src.x2 != 1 << 16 || - src.y1 != 0 || src.y2 != 1 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 2 || - dst.y1 != 0 || dst.y2 != 2, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 1 << 16 && + src.y1 == 0 && src.y2 == 1 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 2 && + dst.y1 == 0 && dst.y2 == 2, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible");
/* 1:2 scaling bottom/right clip */ drm_rect_init(&src, 0, 0, 2 << 16, 2 << 16); @@ -185,19 +198,19 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(src.x1 != 1 << 16 || src.x2 != 2 << 16 || - src.y1 != 1 << 16 || src.y2 != 2 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 2 || dst.x2 != 4 || - dst.y1 != 2 || dst.y2 != 4, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); - - return 0; + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 1 << 16 && src.x2 == 2 << 16 && + src.y1 == 1 << 16 && src.y2 == 2 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 2 && dst.x2 == 4 && + dst.y1 == 2 && dst.y2 == 4, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); }
-int igt_drm_rect_clip_scaled_signed_vs_unsigned(void *ignored) +static void drm_rect_clip_scaled_signed_vs_unsigned(struct kunit *test) { struct drm_rect src, dst, clip; bool visible; @@ -216,8 +229,21 @@ int igt_drm_rect_clip_scaled_signed_vs_unsigned(void *ignored)
visible = drm_rect_clip_scaled(&src, &dst, &clip);
- FAIL(visible, "Destination should not be visible\n"); - FAIL(drm_rect_visible(&src), "Source should not be visible\n"); - - return 0; + KUNIT_EXPECT_FALSE_MSG(test, visible, "Destination should not be visible"); + KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible"); } + +static struct kunit_case drm_rect_tests[] = { + KUNIT_CASE(drm_rect_clip_scaled_div_by_zero), + KUNIT_CASE(drm_rect_clip_scaled_not_clipped), + KUNIT_CASE(drm_rect_clip_scaled_clipped), + KUNIT_CASE(drm_rect_clip_scaled_signed_vs_unsigned), + {} +}; + +static struct kunit_suite drm_rect_test_suite = { + .name = "drm_rect_tests", + .test_cases = drm_rect_tests, +}; + +kunit_test_suite(drm_rect_test_suite);