public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: jeff.mcgee@intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 4/4] pm_rps: Use igt exit handler for restore
Date: Fri, 10 Jan 2014 15:12:33 -0600	[thread overview]
Message-ID: <1389388353-29980-5-git-send-email-jeff.mcgee@intel.com> (raw)
In-Reply-To: <1389388353-29980-1-git-send-email-jeff.mcgee@intel.com>

From: Jeff McGee <jeff.mcgee@intel.com>

Signed-off-by: Jeff McGee <jeff.mcgee@intel.com>
---
 tests/pm_rps.c | 42 +++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index c968ecb..7c739b6 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -36,14 +36,6 @@
 static bool verbose = false;
 static int origmin, origmax;
 
-#define restore_assert(COND) do { \
-	if (!(COND)) { \
-		writeval(stuff[MIN].filp, origmin); \
-		writeval(stuff[MAX].filp, origmax); \
-		igt_assert(0); \
-	} \
-} while (0);
-
 static const char sysfs_base_path[] = "/sys/class/drm/card%d/gt_%s_freq_mhz";
 enum {
 	CUR,
@@ -112,15 +104,15 @@ static void setfreq(int val)
 
 static void checkit(void)
 {
-	restore_assert(fmin <= fmax);
-	restore_assert(fcur <= fmax);
-	restore_assert(fmin <= fcur);
-	restore_assert(frpn <= fmin);
-	restore_assert(fmax <= frp0);
-	restore_assert(frp1 <= frp0);
-	restore_assert(frpn <= frp1);
-	restore_assert(frp0 != 0);
-	restore_assert(frp1 != 0);
+	igt_assert(fmin <= fmax);
+	igt_assert(fcur <= fmax);
+	igt_assert(fmin <= fcur);
+	igt_assert(frpn <= fmin);
+	igt_assert(fmax <= frp0);
+	igt_assert(frp1 <= frp0);
+	igt_assert(frpn <= frp1);
+	igt_assert(frp0 != 0);
+	igt_assert(frp1 != 0);
 }
 
 static void dumpit(void)
@@ -134,6 +126,16 @@ static void dumpit(void)
 	printf("\n");
 }
 
+static void pm_rps_exit_handler(int sig)
+{
+	if (origmin > fmax) {
+		writeval(stuff[MAX].filp, origmax);
+		writeval(stuff[MIN].filp, origmin);
+	} else {
+		writeval(stuff[MIN].filp, origmin);
+		writeval(stuff[MAX].filp, origmax);
+	}
+}
 
 igt_simple_main
 {
@@ -164,6 +166,8 @@ igt_simple_main
 	origmin = fmin;
 	origmax = fmax;
 
+	igt_install_exit_handler(pm_rps_exit_handler);
+
 	if (verbose)
 		printf("Original min = %d\nOriginal max = %d\n", origmin, origmax);
 
@@ -174,11 +178,11 @@ igt_simple_main
 	setfreq(origmin);
 	if (verbose)
 		dumpit();
-	restore_assert(fcur == fmin);
+	igt_assert(fcur == fmin);
 	setfreq(origmax);
 	if (verbose)
 		dumpit();
-	restore_assert(fcur == fmax);
+	igt_assert(fcur == fmax);
 	checkit();
 
 	/* And some errors */
-- 
1.8.5.2

  parent reply	other threads:[~2014-01-10 21:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-10 21:12 Various fixes and updates to igt/pm_rps jeff.mcgee
2014-01-10 21:12 ` [PATCH 1/4] pm_rps: Use unbuffered I/O on sysfs files jeff.mcgee
2014-01-10 21:12 ` [PATCH 2/4] pm_rps: Assert that valid sysfs writes return success jeff.mcgee
2014-01-10 21:12 ` [PATCH 3/4] pm_rps: Fix test to target original min and max jeff.mcgee
2014-01-10 21:12 ` jeff.mcgee [this message]
2014-01-10 21:33 ` Various fixes and updates to igt/pm_rps 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=1389388353-29980-5-git-send-email-jeff.mcgee@intel.com \
    --to=jeff.mcgee@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