[LTP] [PATCH 1/1] shell: Add test for set -e
Petr Vorel
pvorel@suse.cz
Mon Aug 8 14:27:16 CEST 2022
set -e was fixed in previous commits, add test on various
$LTP_COLORIZE_OUTPUT setup. Run setup and cleanup function to cover more
code.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Patch on the top of v4 patchset:
https://patchwork.ozlabs.org/project/ltp/list/?series=312953
lib/newlib_tests/runtest.sh | 2 +-
lib/newlib_tests/shell/tst_errexit.sh | 66 +++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
create mode 100755 lib/newlib_tests/shell/tst_errexit.sh
diff --git a/lib/newlib_tests/runtest.sh b/lib/newlib_tests/runtest.sh
index e78b556c5..be707fe63 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/tst_errexit.sh shell/net/*.sh}"
cd $(dirname $0)
PATH="$PWD/../../testcases/lib/:$PATH"
diff --git a/lib/newlib_tests/shell/tst_errexit.sh b/lib/newlib_tests/shell/tst_errexit.sh
new file mode 100755
index 000000000..1c981af94
--- /dev/null
+++ b/lib/newlib_tests/shell/tst_errexit.sh
@@ -0,0 +1,66 @@
+#!/bin/sh -e
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+
+TST_TESTFUNC=test
+TST_CNT=6
+
+# not needed, just cover more code
+TST_SETUP=setup
+TST_CLEANUP=cleanup
+TST_NEEDS_TMPDIR=1
+
+setup()
+{
+ tst_res TINFO "in setup"
+}
+
+cleanup()
+{
+ tst_res TINFO "in cleanup"
+}
+
+run()
+{
+ tst_res TINFO "LTP_COLORIZE_OUTPUT: '$LTP_COLORIZE_OUTPUT'"
+ tst_res TPASS "shell library works with set -e"
+}
+
+test1()
+{
+ export LTP_COLORIZE_OUTPUT=y
+ run
+}
+
+test2()
+{
+ export LTP_COLORIZE_OUTPUT=n
+ run
+}
+
+test3()
+{
+ export LTP_COLORIZE_OUTPUT=0
+ run
+}
+
+test4()
+{
+ export LTP_COLORIZE_OUTPUT=1
+ run
+}
+
+test5()
+{
+ export LTP_COLORIZE_OUTPUT=
+ run
+}
+
+test6()
+{
+ unset LTP_COLORIZE_OUTPUT
+ run
+}
+
+. tst_test.sh
+tst_run
--
2.37.1
More information about the ltp
mailing list