Skip to contentSkip to conversation

tst_rod: Use args[0] as the command name

PATCH In review Martin Doucha 3 participants 9 messages Jul 28, 2022 – Aug 31, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tst_rod: Use args[0] as the command name

Using argv[1] as the command name might fail if the first argument happens to be I/O redirection. Use args[0] which is always the first argument not processed by tst_rod.

---
 testcases/lib/tst_rod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/tst_rod.c +1 -1
index 2f0ff902c..24c1fb668 100644
@@ -130,7 +130,7 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	execvp(argv[1], args);
+	execvp(args[0], args);
 
 	/* Fall back to shell if command wasn't found */
 	FILE *sin = popen("/bin/sh", "w");
Signature · 5 lines
2.36.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 2/2 tst_rod: Fail on directory change commands

Using tst_rod to check directory change success doesn't work. The command gets executed in a subprocess and will have no effect on the parent shell where the directory change is desired.

---
 testcases/lib/tst_rod.c | 7 +++++++
 1 file changed, 7 insertions(+)
testcases/lib/tst_rod.c +7 -0
index 24c1fb668..362471fa9 100644
@@ -77,6 +77,13 @@ int main(int argc, char *argv[])
 
 	args[pos] = NULL;
 
+	if (!strcmp(args[0], "cd") || !strcmp(args[0], "pushd") ||
+		!strcmp(args[0], "popd")) {
+		fprintf(stderr, "\"%s %s\" has no effect on parent shell\n",
+			argv[0], args[0]);
+		return 1;
+	}
+
 	if (stdin_path) {
 		if (close(0)) {
 			fprintf(stderr, "%s: Failed to close stdin: %s\n",
Signature · 5 lines
2.36.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH 2/2] tst_rod: Fail on directory change commands

Quoted 6 lines · Martin Doucha

Using tst_rod to check directory change success doesn't work. The command gets executed in a subprocess and will have no effect on the parent shell where the directory change is desired.

---

Beware that this patch will cause a lot of broken shell tests to fail. Another patchset fixing the incorrect ROD usage in shell tests is needed before merging this patch.

Signature · 10 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH 2/2] tst_rod: Fail on directory change commands

Hi!

Quoted 3 lines

Beware that this patch will cause a lot of broken shell tests to fail. Another patchset fixing the incorrect ROD usage in shell tests is needed before merging this patch.

The only broken test I've found is du01.sh that does "ROD_SILENT cd basedir" are there actually any other tests that does so?

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by
#4 lore raw

Re: [LTP] [PATCH 2/2] tst_rod: Fail on directory change commands

Quoted 4 lines

Hi!

Quoted 3 lines

Beware that this patch will cause a lot of broken shell tests to fail. Another patchset fixing the incorrect ROD usage in shell tests is needed before merging this patch.

I also wonder if we should care for pushd/popd which are bashism and should not be used in LTP tests which use new shell API.

So far they are used in testcases/realtime/run.sh testscripts/test_realtime.sh, which does not use shell API (and realtime should be removed after porting anything useful to rt-tests).

Quoted 2 lines

The only broken test I've found is du01.sh that does "ROD_SILENT cd basedir" are there actually any other tests that does so?

Indeed it looks just du01.sh.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Hi all,

FYI this first patch merged.
Thanks!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp