[Intel-gfx] [PATCH i-g-t] igt/drv_hangman: Fix clear_error_state

Michel Thierry michel.thierry at intel.com
Thu Feb 23 01:26:29 UTC 2017


clear_error_state was not doing anything (igt_sysfs_set was not writing to
the error file).

Also fix assert_entry to catch this issue; strcasecmp returns 0 when
there's a match, or an integer in a mismatch.

Finally, only print part of the error string when the assert fails.

Cc: Chris Wilson <chris at chris-wilson.co.uk>
Fixes: 79c6a84ca85b ("igt/drv_hangman: Migrate to sysfs")
Signed-off-by: Michel Thierry <michel.thierry at intel.com>
---
 tests/drv_hangman.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c
index cafdf4c1..43f73661 100644
--- a/tests/drv_hangman.c
+++ b/tests/drv_hangman.c
@@ -58,9 +58,15 @@ static void assert_entry(const char *s, bool expect)
 	error = igt_sysfs_get(sysfs, "error");
 	igt_assert(error);
 
-	igt_assert_f(strcasecmp(error, s) != expect,
-		     "contents of error: '%s' (expected %s '%s')\n",
-		     error, expect ? "": "not", s);
+	if (expect) {
+		igt_assert_f(strcasecmp(error, s) == 0,
+			     "contents of error: '%.24s' (expected %s '%s')\n",
+			     error, expect ? "": "not", s);
+	} else {
+		igt_assert_f(strcasecmp(error, s) != 0,
+			     "contents of error: '%.24s' (expected %s '%s')\n",
+			     error, expect ? "": "not", s);
+	}
 
 	free(error);
 }
@@ -77,7 +83,7 @@ static void assert_error_state_collected(void)
 
 static void clear_error_state(void)
 {
-	igt_sysfs_set(sysfs, "error", "");
+	igt_sysfs_set(sysfs, "error", " ");
 }
 
 static void test_error_state_basic(void)
-- 
2.11.0



More information about the Intel-gfx mailing list