summaryrefslogtreecommitdiff
path: root/tests/tools_test.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-12-12 17:20:57 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-12-15 09:36:31 +0000
commitd35ce13878e53c08fad2d43fec411eb041d24bb5 (patch)
treee4905a3dc8b962ead37c2f44320b061e2ce560c3 /tests/tools_test.c
parent737f59897d0ec2b8b47a77ba4100ec3790f3704e (diff)
igt/tools_test: Check the tools exist before executing
As a simple fail-safe against a bad installation, check the tools exist before testing whether they work. v2: Check intel_l3_parity as well v3: Hunt for tools/ Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102935 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Petri Latvala <petri.latvala@intel.com> #v1 Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> #v1
Diffstat (limited to 'tests/tools_test.c')
-rw-r--r--tests/tools_test.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 6aea7a8a..a0025bed 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -26,6 +26,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <libgen.h>
+#include <unistd.h>
+
+#define TOOLS "../tools/"
struct line_check {
int found;
@@ -59,10 +63,24 @@ igt_main
{
igt_skip_on_simulation();
+ igt_fixture {
+ char path[4096];
+
+ /* Try to guess where the TOOLS are! */
+ if (access(TOOLS, F_OK) &&
+ readlink("/proc/self/exe", path, sizeof(path)) > 0)
+ chdir(dirname(path));
+
+ igt_require_f(chdir(TOOLS) == 0,
+ "Unable to determine the tools directory, expecting them in $cwd/" TOOLS " or $path/" TOOLS "\n");
+ }
+
igt_subtest("sysfs_l3_parity") {
int exec_return;
struct line_check line;
+ igt_require(access("intel_l3_parity", X_OK) == 0);
+
/* Sanity check that l3 parity tool is usable: Enable
* row,bank,subbank 0,0,0.
*
@@ -71,27 +89,28 @@ igt_main
* piglit.
*/
igt_system_cmd(exec_return,
- "../tools/intel_l3_parity -r 0 -b 0 "
+ "./intel_l3_parity -r 0 -b 0 "
"-s 0 -e");
assert_cmd_success(exec_return);
/* Disable row,bank,subbank 0,0,0. */
- igt_system_cmd(exec_return, "../tools/intel_l3_parity -r 0 -b 0 "
+ igt_system_cmd(exec_return,
+ "./intel_l3_parity -r 0 -b 0 "
"-s 0 -d");
assert_cmd_success(exec_return);
/* Check that disabling was successful */
- igt_system_cmd(exec_return, "../tools/intel_l3_parity -l");
+ igt_system_cmd(exec_return,
+ "./intel_l3_parity -l");
assert_cmd_success(exec_return);
line.substr = "Row 0, Bank 0, Subbank 0 is disabled";
line.found = 0;
- igt_log_buffer_inspect(check_cmd_output,
- &line);
+ igt_log_buffer_inspect(check_cmd_output, &line);
igt_assert_eq(line.found, 1);
/* Re-enable row,bank,subbank 0,0,0 */
igt_system_cmd(exec_return,
- "../tools/intel_l3_parity -r 0 -b 0 "
+ "./intel_l3_parity -r 0 -b 0 "
"-s 0 -e");
assert_cmd_success(exec_return);
@@ -102,7 +121,8 @@ igt_main
* The previously printed line is already in the log
* buffer so we check for count 1.
*/
- igt_system_cmd(exec_return, "../tools/intel_l3_parity -l");
+ igt_system_cmd(exec_return,
+ "./intel_l3_parity -l");
assert_cmd_success(exec_return);
line.substr = "Row 0, Bank 0, Subbank 0 is disabled";
line.found = 0;
@@ -112,17 +132,12 @@ 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("intel_reg", X_OK) == 0);
+
+ igt_assert_eq(igt_system_quiet("./intel_reg read 0x4030"),
+ IGT_EXIT_SUCCESS);
+
+ igt_assert_eq(igt_system_quiet("./intel_reg dump"),
+ IGT_EXIT_SUCCESS);
}
}