From patchwork Thu Aug 20 14:52:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726391 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31078138C for ; Thu, 20 Aug 2020 14:52:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 19D382075E for ; Thu, 20 Aug 2020 14:52:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19D382075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 608946E946; Thu, 20 Aug 2020 14:52:57 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9891D6E946; Thu, 20 Aug 2020 14:52:55 +0000 (UTC) IronPort-SDR: Py2mIFFFLzpzuuAFT43A4y0Tq6TBe84b3YhLAAaP7E347uRGz/e6lcdnnr8mf9KowKP1y1H6ue 6XM2zodInxxQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136133" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136133" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:55 -0700 IronPort-SDR: jQF+eAI4iJXY/Ga2AyhV/0OLY2AVtvBdXR9s36cc39qzd7sfMGq3Pf8aeo1r4JH/up1HISULpI ofGynNLPX3ig== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679673" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:52 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:02 +0200 Message-Id: <20200820145215.13238-7-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 06/19] tests/core_hotunplug: Maintain a single data structure instance X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The following changes to the test are planned: - avoid global variables, - skip subtest after device close errors, - prepare invariant data only once per test run, - move device health checks to igt_fixture sections, - try to recover from subtest failures instead of aborting. For that to be possible, maintain a single instance of hotunplug structure at igt_main level and pass it down to subtests. Signed-off-by: Janusz Krzysztofik Reviewed-by: MichaƂ Winiarski --- tests/core_hotunplug.c | 56 ++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 46f9ad118..95d326ee9 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -198,68 +198,62 @@ static void set_filter_from_device(int fd) /* Subtests */ -static void unbind_rebind(void) +static void unbind_rebind(struct hotunplug *priv) { - struct hotunplug priv; char buf[PATH_MAX]; - prepare(&priv, buf, sizeof(buf)); + prepare(priv, buf, sizeof(buf)); igt_debug("closing the device\n"); - close(priv.fd.drm); + close(priv->fd.drm); - driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr, ""); + driver_unbind(priv->fd.sysfs_drv, priv->dev_bus_addr, ""); - driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr); + driver_bind(priv->fd.sysfs_drv, priv->dev_bus_addr); healthcheck(); } -static void unplug_rescan(void) +static void unplug_rescan(struct hotunplug *priv) { - struct hotunplug priv; - - prepare(&priv, NULL, 0); + prepare(priv, NULL, 0); igt_debug("closing the device\n"); - close(priv.fd.drm); + close(priv->fd.drm); - device_unplug(priv.fd.sysfs_dev, ""); + device_unplug(priv->fd.sysfs_dev, ""); - bus_rescan(priv.fd.sysfs_bus); + bus_rescan(priv->fd.sysfs_bus); healthcheck(); } -static void hotunbind_lateclose(void) +static void hotunbind_lateclose(struct hotunplug *priv) { - struct hotunplug priv; char buf[PATH_MAX]; - prepare(&priv, buf, sizeof(buf)); + prepare(priv, buf, sizeof(buf)); - driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr, "hot "); + driver_unbind(priv->fd.sysfs_drv, priv->dev_bus_addr, "hot "); - driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr); + driver_bind(priv->fd.sysfs_drv, priv->dev_bus_addr); igt_debug("late closing the unbound device instance\n"); - close(priv.fd.drm); + close(priv->fd.drm); healthcheck(); } -static void hotunplug_lateclose(void) +static void hotunplug_lateclose(struct hotunplug *priv) { - struct hotunplug priv; - - prepare(&priv, NULL, 0); + prepare(priv, NULL, 0); - device_unplug(priv.fd.sysfs_dev, "hot "); + device_unplug(priv->fd.sysfs_dev, "hot "); - bus_rescan(priv.fd.sysfs_bus); + bus_rescan(priv->fd.sysfs_bus); igt_debug("late closing the removed device instance\n"); - close(priv.fd.drm); + close(priv->fd.drm); healthcheck(); } @@ -268,6 +262,8 @@ static void hotunplug_lateclose(void) igt_main { + struct hotunplug priv; + igt_fixture { int fd_drm; @@ -287,28 +283,28 @@ igt_main igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); igt_subtest("unbind-rebind") - unbind_rebind(); + unbind_rebind(&priv); igt_fixture igt_abort_on_f(failure, "%s\n", failure); igt_describe("Check if a device believed to be closed can be cleanly unplugged"); igt_subtest("unplug-rescan") - unplug_rescan(); + unplug_rescan(&priv); igt_fixture igt_abort_on_f(failure, "%s\n", failure); igt_describe("Check if the driver can be cleanly unbound from a still open device, then released"); igt_subtest("hotunbind-lateclose") - hotunbind_lateclose(); + hotunbind_lateclose(&priv); igt_fixture igt_abort_on_f(failure, "%s\n", failure); igt_describe("Check if a still open device can be cleanly unplugged, then released"); igt_subtest("hotunplug-lateclose") - hotunplug_lateclose(); + hotunplug_lateclose(&priv); igt_fixture igt_abort_on_f(failure, "%s\n", failure);