diff mbox series

[v2,1/5] lib: tst_cmd: Make tst_cmd() usable for global paths

Message ID 20210224165045.17738-2-chrubis@suse.cz
State RFC
Headers show
Series Another attempt at hardware discovery | expand

Commit Message

Cyril Hrubis Feb. 24, 2021, 4:50 p.m. UTC
We need to skip the check if the path to the binary starts with '/'.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/tst_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Petr Vorel Feb. 24, 2021, 5:57 p.m. UTC | #1
> We need to skip the check if the path to the binary starts with '/'.
Good point!

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr
diff mbox series

Patch

diff --git a/lib/tst_cmd.c b/lib/tst_cmd.c
index 7446249f9..b73978e20 100644
--- a/lib/tst_cmd.c
+++ b/lib/tst_cmd.c
@@ -58,7 +58,7 @@  int tst_cmd_fds_(void (cleanup_fn)(void),
 
 	char path[PATH_MAX];
 
-	if (tst_get_path(argv[0], path, sizeof(path))) {
+	if (argv[0][0] != '/' && tst_get_path(argv[0], path, sizeof(path))) {
 		if (flags & TST_CMD_TCONF_ON_MISSING)
 			tst_brkm(TCONF, cleanup_fn, "Couldn't find '%s' in $PATH at %s:%d", argv[0],
 				 __FILE__, __LINE__);