From patchwork Thu Jun 7 12:59:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10451829 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 7F58160146 for ; Thu, 7 Jun 2018 12:59:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E43929E55 for ; Thu, 7 Jun 2018 12:59:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6206A29E58; Thu, 7 Jun 2018 12:59:41 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 6A15029E55 for ; Thu, 7 Jun 2018 12:59:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A77776F267; Thu, 7 Jun 2018 12:59:39 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id F14286F267; Thu, 7 Jun 2018 12:59:37 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 11973821-1500050 for multiple; Thu, 07 Jun 2018 13:59:32 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Thu, 07 Jun 2018 13:59:31 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Jun 2018 13:59:30 +0100 Message-Id: <20180607125930.31000-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607105850.30067-1-chris@chris-wilson.co.uk> References: <20180607105850.30067-1-chris@chris-wilson.co.uk> X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH i-g-t] HAX igt/drv_module_reload: Revamp fault-injection X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The current method of checking for a failed module load is flawed, as we only report the error on probing it is not being reported back by modprobe. So we have to dig inside the module_parameters while the module is still loaded to discover the error. v2: Expect i915.inject_load_failure to be zero on success w/o display --- tests/drv_module_reload.c | 47 ++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/tests/drv_module_reload.c b/tests/drv_module_reload.c index 3046d8227..d88851b68 100644 --- a/tests/drv_module_reload.c +++ b/tests/drv_module_reload.c @@ -234,6 +234,40 @@ reload(const char *opts_i915) return err; } +static int open_parameters(const char *module_name) +{ + char path[256]; + + snprintf(path, sizeof(path), "/sys/module/%s/parameters", module_name); + return open(path, O_RDONLY); +} + +static int +inject_fault(const char *module_name, const char *opt, int fault) +{ + char buf[1024]; + int dir; + + igt_assert(fault > 0); + snprintf(buf, sizeof(buf), "%s=%d disable_display=1", opt, fault); + + if (igt_kmod_load(module_name, buf)) { + igt_warn("Failed to load module '%s' with options '%s'\n", + module_name, buf); + return 1; + } + + dir = open_parameters(module_name); + igt_sysfs_scanf(dir, opt, "%d", &fault); + close(dir); + + igt_debug("Loaded '%s %s', result=%d\n", module_name, buf, fault); + + igt_kmod_unload(module_name, 0); + + return fault; +} + static void gem_sanitycheck(void) { @@ -320,12 +354,15 @@ igt_main igt_assert_eq(reload("disable_display=1"), 0); igt_subtest("basic-reload-inject") { - char buf[64]; int i = 0; - do { - snprintf(buf, sizeof(buf), - "inject_load_failure=%d", ++i); - } while (reload(buf)); + + igt_i915_driver_unload(); + + while (inject_fault("i915", "inject_load_failure", ++i) == 0) + ; + + /* We expect to hit at least one fault! */ + igt_assert(i > 1); } igt_fixture {