[PATCH igt] igt/tools_test: Check the tools exist before executing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As a simple fail-safe against a bad installation, check the tools exist
before testing whether they work.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102935
Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
 tests/tools_test.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/tests/tools_test.c b/tests/tools_test.c
index 6aea7a8a4..a4fc68e8b 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -26,6 +26,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <unistd.h>
+
+#define TOOLS "../tools/"
 
 struct line_check {
 	int found;
@@ -112,17 +115,13 @@ igt_main
 	}
 
 	igt_subtest("tools_test") {
-		char *cmd;
-
-		igt_assert(asprintf(&cmd,
-				    "../tools/intel_reg read 0x4030")
-			   != -1);
-		igt_assert(igt_system_quiet(cmd) == IGT_EXIT_SUCCESS);
-		free(cmd);
-
-		igt_assert(asprintf(&cmd, "../tools/intel_reg dump")
-			   != -1);
-		igt_assert(igt_system_quiet(cmd) == IGT_EXIT_SUCCESS);
-		free(cmd);
+		igt_require(access(TOOLS "intel_reg_read", X_OK) == 0);
+		igt_require(access(TOOLS "intel_reg_dump", X_OK) == 0);
+
+		igt_assert_eq(igt_system_quiet(TOOLS "intel_reg read 0x4030"),
+			      IGT_EXIT_SUCCESS);
+
+		igt_assert_eq(igt_system_quiet(TOOLS "intel_reg dump"),
+			      IGT_EXIT_SUCCESS);
 	}
 }
-- 
2.15.1

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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux