All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Anibal Limon" <anibal.limon@linaro.org>
To: yocto@yoctoproject.org
Cc: yifan.yu@windriver.com, Randy.MacLeod@windriver.com,
	nicolas.dechesne@linaro.org,
	"Aníbal Limón" <anibal.limon@linaro.org>
Subject: [ptest-runner][PATCH 1/4] utils.c: get_available_ptests allow to specify relative directories
Date: Mon, 22 Mar 2021 20:10:35 -0600	[thread overview]
Message-ID: <20210323021038.1049654-1-anibal.limon@linaro.org> (raw)

Fixes,

$ ./ptest-runner -d ./tests/data bash

Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
---
 utils.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/utils.c b/utils.c
index a4e190e..43ab03b 100644
--- a/utils.c
+++ b/utils.c
@@ -34,6 +34,7 @@
 #include <poll.h>
 #include <pty.h>
 #include <signal.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -85,6 +86,9 @@ get_available_ptests(const char *dir)
 	struct dirent **namelist;
 	int fail;
 	int saved_errno = -1; /* Initalize to invalid errno. */
+	char realdir[PATH_MAX];
+
+	realpath(dir, realdir);
 
 	do
 	{
@@ -93,7 +97,7 @@ get_available_ptests(const char *dir)
 		if (head == NULL)
 			break;
 
-		if (stat(dir, &st_buf) == -1) {
+		if (stat(realdir, &st_buf) == -1) {
 			PTEST_LIST_FREE_CLEAN(head);
 			break;
 		}
@@ -104,7 +108,7 @@ get_available_ptests(const char *dir)
 			break;
 		}
 
-		n = scandir(dir, &namelist, NULL, alphasort);
+		n = scandir(realdir, &namelist, NULL, alphasort);
 		if (n == -1) {
 			PTEST_LIST_FREE_CLEAN(head);
 			break;
@@ -130,7 +134,7 @@ get_available_ptests(const char *dir)
 			}
 
 			if (asprintf(&run_ptest, "%s/%s/ptest/run-ptest",
-			    dir, d_name) == -1)  {
+			    realdir, d_name) == -1)  {
 				fail = 1;
 				saved_errno = errno;
 				free(d_name);
-- 
2.31.0


             reply	other threads:[~2021-03-23  2:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23  2:10 Anibal Limon [this message]
2021-03-23  2:10 ` [ptest-runner][PATCH 2/4] utils.c: Fix exit status of a child Anibal Limon
2021-03-23  2:10 ` [ptest-runner][PATCH 3/4] utils.c: Use a thread to read from child Anibal Limon
2021-03-23  2:10 ` [ptest-runner][PATCH 4/4] utils.c: wait_child reimplement timeout using alarm Anibal Limon
2021-03-24 15:56   ` Yi Fan Yu
2021-03-24 18:30     ` Anibal Limon

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=20210323021038.1049654-1-anibal.limon@linaro.org \
    --to=anibal.limon@linaro.org \
    --cc=Randy.MacLeod@windriver.com \
    --cc=nicolas.dechesne@linaro.org \
    --cc=yifan.yu@windriver.com \
    --cc=yocto@yoctoproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.