diff options
author | Paul Kocialkowski <paul.kocialkowski@linux.intel.com> | 2017-08-30 16:56:09 +0300 |
---|---|---|
committer | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2017-08-30 21:13:41 +0300 |
commit | 4e4500a7a62c5583973c8da5ca366de859bbd0d1 (patch) | |
tree | 71f91e7dee765e668bfa6a3c5b591d2ea657f3fa /lib/igt_aux.c | |
parent | fc6510887f8f45e18ca267e53eb564de043bd9d6 (diff) |
lib/igt_aux: Allow sysfs open to fail when setting suspend/resume delay
This removes the igt_require condition on the sysfs open call used to
write the suspend/resume delay so that it is allowed to fail. Intsead,
the code that depends on it is put in a conditional block.
This allows running test binaries as a non-privileged user for e.g.
listing the available tests with the SuspendResumeDelay parameter set
in igtrc configuration. Sysfs access would otherwise cause it to fail.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@linux.intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib/igt_aux.c')
-rw-r--r-- | lib/igt_aux.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/igt_aux.c b/lib/igt_aux.c index f428f159..d808fe3e 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -883,19 +883,21 @@ void igt_set_autoresume_delay(int delay_secs) igt_skip_on_simulation(); - igt_require((delay_fd = open("/sys/module/suspend/parameters/pm_test_delay", - O_RDWR)) >= 0); + delay_fd = open("/sys/module/suspend/parameters/pm_test_delay", O_RDWR); + + if (delay_fd >= 0) { + if (!original_autoresume_delay) { + igt_require(read(delay_fd, delay_str, + sizeof(delay_str))); + original_autoresume_delay = atoi(delay_str); + igt_install_exit_handler(igt_restore_autoresume_delay); + } - if (!original_autoresume_delay) { - igt_require(read(delay_fd, delay_str, sizeof(delay_str))); - original_autoresume_delay = atoi(delay_str); - igt_install_exit_handler(igt_restore_autoresume_delay); - } + snprintf(delay_str, sizeof(delay_str), "%d", delay_secs); + igt_require(write(delay_fd, delay_str, strlen(delay_str))); - snprintf(delay_str, sizeof(delay_str), "%d", delay_secs); - igt_require(write(delay_fd, delay_str, strlen(delay_str))); - - close(delay_fd); + close(delay_fd); + } autoresume_delay = delay_secs; } |