[igt-dev] [PATCH i-g-t v2 10/16] tests/core_hotunplug: Skip selectively on sysfs close errors

Janusz Krzysztofik
2020-08-07T09:19:56Z

Since we no longer open a device DRM sysfs node, only a PCI one, driver
unbind operations are no longer affected by missed or unsuccessful
sysfs file close attempts. Skip only affected subtests if that
happens.

v2: Rebase on current upstream master.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>
---
tests/core_hotunplug.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 71ac4d169..b9982b330 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -82,8 +82,8 @@ static void prepare(struct hotunplug *priv)
igt_assert_fd(priv->fd.sysfs_bus);

priv->fd.sysfs_dev = local_close(priv->fd.sysfs_dev);
- igt_assert_f(priv->fd.sysfs_dev == -1,
- "Device sysfs node close failed\n");
+ igt_warn_on_f(priv->fd.sysfs_dev != -1,
+ "Device sysfs node close failed\n");
}

/* Unbind the driver from the device */
@@ -113,6 +113,9 @@ static void driver_bind(struct hotunplug *priv)
/* Remove (virtually unplug) the device from its bus */
static void device_unplug(struct hotunplug *priv, const char *prefix)
{
+ igt_require_f(priv->fd.sysfs_dev == -1,
+ "Device sysfs node not closed properly\n");
+
priv->fd.sysfs_dev = openat(priv->fd.sysfs_bus, priv->dev_bus_addr,
O_DIRECTORY);
igt_assert_fd(priv->fd.sysfs_dev);
@@ -171,8 +174,6 @@ static void post_healthcheck(struct hotunplug *priv)
igt_abort_on_f(priv->failure, "%s\n", priv->failure);

igt_require_f(priv->fd.drm == -1, "Device not closed properly\n");
- igt_require_f(priv->fd.sysfs_dev == -1,
- "Device sysfs node not closed properly\n");
}

static void set_filter_from_device(int fd)