diff options
author | Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> | 2020-07-10 12:08:23 +0200 |
---|---|---|
committer | Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> | 2020-09-14 20:48:35 +0200 |
commit | 4b192984ec7e845a1ea49a385b7669642c3b3ec9 (patch) | |
tree | 71c41744483ce215ce46cd2296236c97890514f7 /tests/core_hotunplug.c | |
parent | c3c31f74f02fefd7ac4a43b4985c44963b6f2426 (diff) |
tests/core_hotunplug: Assert expected device presence/absence
Don't rely on successful write to sysfs control files, assert existence
/ non-existence of a respective device sysfs node as well.
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Reviewed-by: MichaĆ Winiarski <michal.winiarski@intel.com>
Diffstat (limited to 'tests/core_hotunplug.c')
-rw-r--r-- | tests/core_hotunplug.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index d5b8c5ed..a7dc4cf3 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -131,6 +131,9 @@ static void driver_unbind(struct hotunplug *priv, const char *prefix, priv->dev_bus_addr), "Driver unbind failure!\n"); igt_reset_timeout(); + + igt_assert_f(faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, F_OK, 0), + "Unbound device still present\n"); } /* Re-bind the driver to the device */ @@ -144,6 +147,10 @@ static void driver_bind(struct hotunplug *priv, int timeout) priv->dev_bus_addr), "Driver re-bind failure\n!"); igt_reset_timeout(); + + igt_fail_on_f(faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, + F_OK, 0), + "Rebound device not present!\n"); } /* Remove (virtually unplug) the device from its bus */ @@ -166,6 +173,9 @@ static void device_unplug(struct hotunplug *priv, const char *prefix, priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); igt_assert_eq(priv->fd.sysfs_dev, -1); + + igt_assert_f(faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, F_OK, 0), + "Unplugged device still present\n"); } /* Re-discover the device by rescanning its bus */ @@ -178,6 +188,10 @@ static void bus_rescan(struct hotunplug *priv, int timeout) igt_assert_f(igt_sysfs_set(priv->fd.sysfs_bus, "../rescan", "1"), "Bus rescan failure!\n"); igt_reset_timeout(); + + igt_fail_on_f(faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, + F_OK, 0), + "Fakely unplugged device not rediscovered!\n"); } static void cleanup(struct hotunplug *priv) |