summaryrefslogtreecommitdiff
path: root/tests/tools_test.c
diff options
context:
space:
mode:
authorPetri Latvala <petri.latvala@intel.com>2018-10-08 15:10:42 +0300
committerPetri Latvala <petri.latvala@intel.com>2018-11-05 16:09:34 +0200
commit15dff9353621d0746b80fae534c20621e03a9f01 (patch)
tree11e503ca6988d220a1e731005468128f14f10ab5 /tests/tools_test.c
parent7fd5da2567d054d7473b6a46075de9d997a529d2 (diff)
tests/tools_test: Find the tool binaries also from bindir
Also print what directory gets used. v2: Use PATH_MAX Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'tests/tools_test.c')
-rw-r--r--tests/tools_test.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/tests/tools_test.c b/tests/tools_test.c
index a0025bed..88a6ae96 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -28,6 +28,7 @@
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
+#include <linux/limits.h>
#define TOOLS "../tools/"
@@ -59,20 +60,33 @@ static void assert_cmd_success(int exec_return)
igt_assert_eq(exec_return, IGT_EXIT_SUCCESS);
}
+static bool chdir_to_tools_dir(void)
+{
+ char path[PATH_MAX];
+
+ /* Try TOOLS relative to cwd */
+ if (chdir(TOOLS) == 0)
+ return true;
+
+ /* Try TOOLS and install dir relative to test binary */
+ if (readlink("/proc/self/exe", path, sizeof(path)) > 0)
+ chdir(dirname(path));
+
+ return chdir(TOOLS) == 0 || chdir("../../bin") == 0;
+}
+
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));
+ char *path;
- igt_require_f(chdir(TOOLS) == 0,
+ igt_require_f(chdir_to_tools_dir(),
"Unable to determine the tools directory, expecting them in $cwd/" TOOLS " or $path/" TOOLS "\n");
+ path = get_current_dir_name();
+ igt_info("Using tools from %s\n", path);
+ free(path);
}
igt_subtest("sysfs_l3_parity") {