public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Paul Kocialkowski <paul.kocialkowski@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t] lib/igt_aux: Allow sysfs open to fail when setting suspend/resume delay
Date: Wed, 30 Aug 2017 16:56:09 +0300	[thread overview]
Message-ID: <20170830135609.9010-1-paul.kocialkowski@linux.intel.com> (raw)

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>
---
 lib/igt_aux.c | 24 +++++++++++++-----------
 1 file 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;
 }
-- 
2.14.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2017-08-30 13:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 13:56 Paul Kocialkowski [this message]
2017-08-30 14:46 ` ✓ Fi.CI.BAT: success for lib/igt_aux: Allow sysfs open to fail when setting suspend/resume delay Patchwork
2017-08-30 16:41 ` ✓ Fi.CI.IGT: " Patchwork
2017-08-30 18:15 ` [PATCH i-g-t] " Arkadiusz Hiler
2017-09-04  8:07   ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170830135609.9010-1-paul.kocialkowski@linux.intel.com \
    --to=paul.kocialkowski@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox