[Intel-gfx] [RFC i-g-t v3 1/5] igt_aux: Add igt_skip_without_suspend_support()
Lyude
lyude at redhat.com
Thu Dec 1 01:24:44 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 b5ae854..ce2f245 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -732,6 +732,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 177bd1d..41903c2 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -181,6 +181,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.9.3
More information about the Intel-gfx
mailing list