diff mbox series

[2/2] tst_rod: Fail on directory change commands

Message ID 20220728114258.30832-2-mdoucha@suse.cz
State Accepted
Headers show
Series [1/2] tst_rod: Use args[0] as the command name | expand

Commit Message

Martin Doucha July 28, 2022, 11:42 a.m. UTC
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.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/lib/tst_rod.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Martin Doucha July 28, 2022, 11:49 a.m. UTC | #1
On 28. 07. 22 13:42, Martin Doucha wrote:
> 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.
> 
> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> ---

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.
Cyril Hrubis Aug. 2, 2022, 2:53 p.m. UTC | #2
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Cyril Hrubis Aug. 2, 2022, 2:55 p.m. UTC | #3
Hi!
> 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?
Petr Vorel Aug. 16, 2022, 12:51 p.m. UTC | #4
> Hi!
> > 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.

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

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).

> 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
Cyril Hrubis Aug. 31, 2022, 12:38 p.m. UTC | #5
Hi!
Pushed now that df01.sh has been dealt with, thanks.
diff mbox series

Patch

diff --git a/testcases/lib/tst_rod.c b/testcases/lib/tst_rod.c
index 24c1fb668..362471fa9 100644
--- a/testcases/lib/tst_rod.c
+++ b/testcases/lib/tst_rod.c
@@ -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",