[LTP] [PATCH 1/1] lib: Add ROD shell API test

Petr Vorel pvorel@suse.cz
Wed Jul 27 17:16:57 CEST 2022


Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/newlib_tests/runtest.sh   |  2 +-
 lib/newlib_tests/shell/rod.sh | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100755 lib/newlib_tests/shell/rod.sh

diff --git a/lib/newlib_tests/runtest.sh b/lib/newlib_tests/runtest.sh
index f136bcb88..5b75fe2c7 100755
--- a/lib/newlib_tests/runtest.sh
+++ b/lib/newlib_tests/runtest.sh
@@ -8,7 +8,7 @@ tst_fuzzy_sync03 test_zero_hugepage.sh test_kconfig.sh
 test_children_cleanup.sh}"
 
 LTP_SHELL_API_TESTS="${LTP_SHELL_API_TESTS:-shell/tst_check_driver.sh
-shell/tst_check_kconfig0[1-5].sh shell/net/*.sh}"
+shell/tst_check_kconfig0[1-5].sh shell/rod.sh shell/net/*.sh}"
 
 cd $(dirname $0)
 PATH="$PWD/../../testcases/lib/:$PATH"
diff --git a/lib/newlib_tests/shell/rod.sh b/lib/newlib_tests/shell/rod.sh
new file mode 100755
index 000000000..e05516d0b
--- /dev/null
+++ b/lib/newlib_tests/shell/rod.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+
+TST_TESTFUNC="test"
+TST_NEEDS_TMPDIR=1
+TST_CNT=3
+
+test1()
+{
+	ROD cd /
+	EXPECT_PASS [ "$PWD" != "/" ]
+}
+
+test2()
+{
+	ROD echo foo > /nonexisting-file
+	tst_res TPASS "ROD redirecting without qoting continue on failure. NOTE: proper syntax needs to escape '>': ROD echo foo \> /nonexisting-file"
+	EXPECT_FAIL 'cat /nonexisting-file'
+}
+
+test3()
+{
+	ROD echo foo \> file
+	tst_res TPASS "ROD redirect quoting syntax works"
+	EXPECT_PASS '[ $(cat file) = foo ]'
+}
+
+. tst_test.sh
+tst_run
-- 
2.37.1



More information about the ltp mailing list