[Intel-gfx] [RFC i-g-t 1/4] igt_aux: Add igt_skip_without_suspend_support()
Lyude
lyude at redhat.com
Tue Nov 8 00:05:13 UTC 2016
Since all of the chamelium calls are blocking, we need to be able to
make suspend/resume tests with it multi-threaded. As such, it's not the
best idea to rely on igt_system_suspend_autoresume() for skipping tests
on systems without suspend/resume support since we could accidentally
leave the thread controlling the chamelium running after the test gets
skipped.
Signed-off-by: Lyude <lyude at redhat.com>
---
lib/igt_aux.c | 21 +++++++++++++++++++++
lib/igt_aux.h | 2 ++
2 files changed, 23 insertions(+)
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 421f6d4..9754148 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -743,6 +743,27 @@ static uint32_t get_supported_suspend_states(int power_dir)
}
/**
+ * igt_skip_without_suspend_state:
+ * @state: an #igt_suspend_state to check for
+ *
+ * Check whether or not the system supports the given @state, and skip the
+ * current test if it doesn't. Useful for tests we want to skip before
+ * attempting to call #igt_system_suspend_autoresume.
+ */
+void igt_skip_without_suspend_support(enum igt_suspend_state state,
+ enum igt_suspend_test test)
+{
+ int power_dir;
+
+ igt_require((power_dir = open("/sys/power", O_RDONLY)) >= 0);
+ igt_require(get_supported_suspend_states(power_dir) & (1 << state));
+ igt_require(test == SUSPEND_TEST_NONE ||
+ faccessat(power_dir, "pm_test", R_OK | W_OK, 0) == 0);
+
+ close(power_dir);
+}
+
+/**
* igt_system_suspend_autoresume:
* @state: an #igt_suspend_state, the target suspend state
* @test: an #igt_suspend_test, test point at which to complete the suspend
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index d30196b..973a9cd 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -170,6 +170,8 @@ enum igt_suspend_test {
SUSPEND_TEST_NUM,
};
+void igt_skip_without_suspend_support(enum igt_suspend_state state,
+ enum igt_suspend_test test);
void igt_system_suspend_autoresume(enum igt_suspend_state state,
enum igt_suspend_test test);
--
2.7.4
More information about the Intel-gfx
mailing list