All of lore.kernel.org
 help / color / mirror / Atom feed
* [ptest-runner][PATCH 1/4] utils.c: get_available_ptests allow to specify relative directories
@ 2021-03-23  2:10 Anibal Limon
  2021-03-23  2:10 ` [ptest-runner][PATCH 2/4] utils.c: Fix exit status of a child Anibal Limon
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Anibal Limon @ 2021-03-23  2:10 UTC (permalink / raw)
  To: yocto; +Cc: yifan.yu, Randy.MacLeod, nicolas.dechesne, Aníbal Limón

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-24 18:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23  2:10 [ptest-runner][PATCH 1/4] utils.c: get_available_ptests allow to specify relative directories Anibal Limon
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

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.