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

Martin Doucha mdoucha@suse.cz
Thu Jul 28 13:42:58 CEST 2022


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(+)

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",
-- 
2.36.1



More information about the ltp mailing list