public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t 1/1] tests/tools_test: Find the tool binaries also from bindir
Date: Mon,  8 Oct 2018 15:10:42 +0300	[thread overview]
Message-ID: <20181008121042.30556-1-petri.latvala@intel.com> (raw)

Also print what directory gets used.

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
 tests/tools_test.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/tests/tools_test.c b/tests/tools_test.c
index a0025bed..ac8717c5 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -59,20 +59,33 @@ static void assert_cmd_success(int exec_return)
 	igt_assert_eq(exec_return, IGT_EXIT_SUCCESS);
 }
 
+bool chdir_to_tools_dir()
+{
+	char path[4096];
+
+	/* 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") {
-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2018-10-08 12:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-08 12:10 Petri Latvala [this message]
2018-10-08 13:28 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/1] tests/tools_test: Find the tool binaries also from bindir Patchwork
2018-10-08 14:41 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2018-10-08 15:49 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-11-05 10:50 ` [igt-dev] [PATCH i-g-t 1/1] " Arkadiusz Hiler
2018-11-05 11:42   ` Petri Latvala
2018-11-05 13:45     ` Arkadiusz Hiler

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=20181008121042.30556-1-petri.latvala@intel.com \
    --to=petri.latvala@intel.com \
    --cc=igt-dev@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