From patchwork Fri Mar 10 14:42:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Latvala X-Patchwork-Id: 9617629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A099F60417 for ; Fri, 10 Mar 2017 14:42:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EEB0286E6 for ; Fri, 10 Mar 2017 14:42:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FBCF2871A; Fri, 10 Mar 2017 14:42:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2B123286E6 for ; Fri, 10 Mar 2017 14:42:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 205526EE98; Fri, 10 Mar 2017 14:42:57 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from johanna3.inet.fi (mta-out1.inet.fi [62.71.2.203]) by gabe.freedesktop.org (Postfix) with ESMTP id 9AD366EE9B for ; Fri, 10 Mar 2017 14:42:55 +0000 (UTC) RazorGate-KAS: Status: not_detected RazorGate-KAS: Rate: 0 RazorGate-KAS: Envelope from: RazorGate-KAS: Version: 5.5.3 RazorGate-KAS: LuaCore: 80 2014-11-10_18-01-23 260f8afb9361da3c7edfd3a8e3a4ca908191ad29 RazorGate-KAS: Lua profiles 69136 [Nov 12 2014] RazorGate-KAS: Method: none Received: from hufflepuff.adrinael.net (84.250.112.128) by johanna3.inet.fi (9.0.002.03-2-gbe5d057) id 58B6B9840141E4D7; Fri, 10 Mar 2017 16:42:54 +0200 Received: from adrinael by hufflepuff.adrinael.net with local (Exim 4.84_2) (envelope-from ) id 1cmLks-0004Q3-TC; Fri, 10 Mar 2017 16:42:54 +0200 From: Petri Latvala To: intel-gfx@lists.freedesktop.org Date: Fri, 10 Mar 2017 16:42:44 +0200 Message-Id: <1489156964-16931-3-git-send-email-petri.latvala@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1489156964-16931-1-git-send-email-petri.latvala@intel.com> References: <1489156964-16931-1-git-send-email-petri.latvala@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/2] Always expose IGT subtests for known kernel selftests X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Even when the running kernel does not support selftests, make subtest enumeration list known kselftests. The list is generated using selftest listing headers copied from the kernel. If the running kernel gains new selftest subtests, they are listed even without copying the headers over and rebuilding IGT. Signed-off-by: Petri Latvala --- lib/igt_kmod.c | 52 ++++++++++++++++++++++++++++++++++++++-------------- lib/igt_kmod.h | 8 +++++++- tests/drm_mm.c | 17 ++++++++++++++++- tests/drv_selftest.c | 25 +++++++++++++++++++++++-- 4 files changed, 84 insertions(+), 18 deletions(-) diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c index 4b8ea81..86b7896 100644 --- a/lib/igt_kmod.c +++ b/lib/igt_kmod.c @@ -493,30 +493,54 @@ void igt_kselftest_fini(struct igt_kselftest *tst) kmod_module_unref(tst->kmod); } +static void mocklist_mark_entry(struct igt_kselftest_mockentry *mocklist, + const char *name) +{ + struct igt_kselftest_mockentry *me; + + for (me = mocklist; me->name != NULL; ++me) { + if (!strcmp(me->name, name)) { + me->do_mock = false; + return; + } + } +} + void igt_kselftests(const char *module_name, const char *options, const char *result, - const char *filter) + const char *filter, + struct igt_kselftest_mockentry *mocklist) { struct igt_kselftest tst; IGT_LIST(tests); struct igt_kselftest_list *tl, *tn; + struct igt_kselftest_mockentry *me; - igt_require(igt_kselftest_init(&tst, module_name) == 0); - igt_fixture - igt_require(igt_kselftest_begin(&tst) == 0); + if (igt_kselftest_init(&tst, module_name) == 0) { + igt_fixture + igt_require(igt_kselftest_begin(&tst) == 0); - igt_kselftest_get_tests(tst.kmod, filter, &tests); - igt_list_for_each_safe(tl, tn, &tests, link) { - igt_subtest_f("%s", tl->name) - igt_kselftest_execute(&tst, tl, options, result); - free(tl); - } + igt_kselftest_get_tests(tst.kmod, filter, &tests); + igt_list_for_each_safe(tl, tn, &tests, link) { + igt_subtest_f("%s", tl->name) + igt_kselftest_execute(&tst, tl, options, result); + mocklist_mark_entry(mocklist, tl->name); + free(tl); + } - igt_fixture { - igt_kselftest_end(&tst); - igt_require(!igt_list_empty(&tests)); + igt_fixture { + igt_kselftest_end(&tst); + igt_require(!igt_list_empty(&tests)); + } + + igt_kselftest_fini(&tst); } - igt_kselftest_fini(&tst); + /* Expose subtests for anything the above didn't already generate. */ + for (me = mocklist; me->name != NULL; ++me) { + if (me->do_mock) + igt_subtest(me->name) + igt_skip("Kernel selftest not present"); + } } diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h index 10cd3a2..d49e9d4 100644 --- a/lib/igt_kmod.h +++ b/lib/igt_kmod.h @@ -35,10 +35,16 @@ int igt_kmod_unload(const char *mod_name, unsigned int flags); int igt_i915_driver_load(const char *opts); int igt_i915_driver_unload(void); +struct igt_kselftest_mockentry { + const char *name; + bool do_mock; +}; + void igt_kselftests(const char *module_name, const char *module_options, const char *result_option, - const char *filter); + const char *filter, + struct igt_kselftest_mockentry* mocklist); struct igt_kselftest { struct kmod_module *kmod; diff --git a/tests/drm_mm.c b/tests/drm_mm.c index 2052b11..2a3212e 100644 --- a/tests/drm_mm.c +++ b/tests/drm_mm.c @@ -28,5 +28,20 @@ IGT_TEST_DESCRIPTION("Basic sanity check of DRM's range manager (struct drm_mm)" igt_main { - igt_kselftests("test-drm_mm", NULL, NULL, NULL); + /* + * Set of subtest names that are always exposed by IGT, + * regardless of the running kernel's capabilities. Selftests + * that the kernel has but are not on these lists are also + * exposed. This is a known intentional violation of the + * general rule that subtest enumeration must not change + * depending on the runtime environment. + */ + struct igt_kselftest_mockentry drm_mm_testlist[] = { +#define selftest(n, x) { .name = #n, .do_mock = true }, +#include "drm_mm_selftests.h" +#undef selftest + { NULL, false } + }; + + igt_kselftests("test-drm_mm", NULL, NULL, NULL, drm_mm_testlist); } diff --git a/tests/drv_selftest.c b/tests/drv_selftest.c index 96dd8bf..eb34fdf 100644 --- a/tests/drv_selftest.c +++ b/tests/drv_selftest.c @@ -28,6 +28,27 @@ IGT_TEST_DESCRIPTION("Basic unit tests for i915.ko"); igt_main { - igt_kselftests("i915", "mock_selftests=-1", NULL, "mock"); - igt_kselftests("i915", "live_selftests=-1", "live_selftests", "live"); + /* + * Set of subtest names that are always exposed by IGT, + * regardless of the running kernel's capabilities. Selftests + * that the kernel has but are not on these lists are also + * exposed. This is a known intentional violation of the + * general rule that subtest enumeration must not change + * depending on the runtime environment. + */ + struct igt_kselftest_mockentry i915_mock_testlist[] = { +#define selftest(n, x) { .name = #n, .do_mock = true }, +#include "i915_mock_selftests.h" +#undef selftest + { NULL, false } + }; + struct igt_kselftest_mockentry i915_live_testlist[] = { +#define selftest(n, x) { .name = #n, .do_mock = true }, +#include "i915_mock_selftests.h" +#undef selftest + { NULL, false } + }; + + igt_kselftests("i915", "mock_selftests=-1", NULL, "mock", i915_mock_testlist); + igt_kselftests("i915", "live_selftests=-1", "live_selftests", "live", i915_live_testlist); }