* [LTP] [PATCH v3 0/4] set -e and bashism fixes
@ 2022-08-08 10:10 Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 1/4] tst_test.sh: runtest.sh: Remove unused code Petr Vorel
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Petr Vorel @ 2022-08-08 10:10 UTC (permalink / raw)
To: ltp
changes v2->v3:
* 3 new commits (remove unused code + set -e fixes)
* remove useless 'exit 0' (Martin)
This time I tested it (on both dash and bash),
it should be working. But please test it as well.
Kind regards,
Petr
Petr Vorel (4):
tst_test.sh: runtest.sh: Remove unused code
tst_ansi_color.sh: Allow to run with set -e
tst_test.sh: Fix _tst_cleanup_timer() on set -e
generate_lvm_runfile.sh: Fix bashism
lib/newlib_tests/runtest.sh | 3 ---
testcases/lib/tst_ansi_color.sh | 5 +++--
testcases/lib/tst_test.sh | 5 +----
testcases/misc/lvm/generate_lvm_runfile.sh | 5 +++--
4 files changed, 7 insertions(+), 11 deletions(-)
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread* [LTP] [PATCH v3 1/4] tst_test.sh: runtest.sh: Remove unused code
2022-08-08 10:10 [LTP] [PATCH v3 0/4] set -e and bashism fixes Petr Vorel
@ 2022-08-08 10:10 ` Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 2/4] tst_ansi_color.sh: Allow to run with set -e Petr Vorel
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2022-08-08 10:10 UTC (permalink / raw)
To: ltp
This code is in tst_print_colored() (probably forgotten to remove code
from tst_test.sh in a7f613372 when moved to tst_print_colored during
development; later copy wrong code in d132084bc into runtest.sh).
Fixes: a7f613372 ("Colorize test type in the output")
Fixes: d132084bc ("lib: Add script for running tests")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/newlib_tests/runtest.sh | 3 ---
testcases/lib/tst_test.sh | 3 ---
2 files changed, 6 deletions(-)
diff --git a/lib/newlib_tests/runtest.sh b/lib/newlib_tests/runtest.sh
index f136bcb88..e78b556c5 100755
--- a/lib/newlib_tests/runtest.sh
+++ b/lib/newlib_tests/runtest.sh
@@ -48,9 +48,6 @@ runtest_res()
local res="$1"
shift
- tst_color_enabled
- local color=$?
-
printf "runtest " >&2
tst_print_colored $res "$res: " >&2
echo "$@" >&2
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index a35fa2e7b..356af0106 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -112,9 +112,6 @@ tst_res()
local res=$1
shift
- tst_color_enabled
- local color=$?
-
_tst_inc_res "$res"
printf "$TST_ID $TST_COUNT " >&2
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread* [LTP] [PATCH v3 2/4] tst_ansi_color.sh: Allow to run with set -e
2022-08-08 10:10 [LTP] [PATCH v3 0/4] set -e and bashism fixes Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 1/4] tst_test.sh: runtest.sh: Remove unused code Petr Vorel
@ 2022-08-08 10:10 ` Petr Vorel
2022-08-08 11:12 ` Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 3/4] tst_test.sh: Fix _tst_cleanup_timer() on " Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 4/4] generate_lvm_runfile.sh: Fix bashism Petr Vorel
3 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2022-08-08 10:10 UTC (permalink / raw)
To: ltp
set -e (or #!/bin/sh -e or set -o errexit) quits on any non-zero exit
code, harden tst_res TINFO to be able to be used on scripts with it.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/tst_ansi_color.sh | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/testcases/lib/tst_ansi_color.sh b/testcases/lib/tst_ansi_color.sh
index 703df1eb8..4b2255448 100644
--- a/testcases/lib/tst_ansi_color.sh
+++ b/testcases/lib/tst_ansi_color.sh
@@ -32,8 +32,9 @@ tst_color_enabled()
tst_print_colored()
{
- tst_color_enabled
- local color=$?
+ local color=0
+
+ tst_color_enabled || color=$?
[ "$color" = "1" ] && tst_flag2color "$1"
printf "$2"
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [LTP] [PATCH v3 2/4] tst_ansi_color.sh: Allow to run with set -e
2022-08-08 10:10 ` [LTP] [PATCH v3 2/4] tst_ansi_color.sh: Allow to run with set -e Petr Vorel
@ 2022-08-08 11:12 ` Petr Vorel
0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2022-08-08 11:12 UTC (permalink / raw)
To: ltp
> set -e (or #!/bin/sh -e or set -o errexit) quits on any non-zero exit
> code, harden tst_res TINFO to be able to be used on scripts with it.
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> testcases/lib/tst_ansi_color.sh | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
> diff --git a/testcases/lib/tst_ansi_color.sh b/testcases/lib/tst_ansi_color.sh
> index 703df1eb8..4b2255448 100644
> --- a/testcases/lib/tst_ansi_color.sh
> +++ b/testcases/lib/tst_ansi_color.sh
> @@ -32,8 +32,9 @@ tst_color_enabled()
> tst_print_colored()
> {
> - tst_color_enabled
> - local color=$?
> + local color=0
> +
> + tst_color_enabled || color=$?
OK, this is not working for LTP_COLORIZE_OUTPUT=n => v4 will come shortly.
Kind regards,
Petr
> [ "$color" = "1" ] && tst_flag2color "$1"
> printf "$2"
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH v3 3/4] tst_test.sh: Fix _tst_cleanup_timer() on set -e
2022-08-08 10:10 [LTP] [PATCH v3 0/4] set -e and bashism fixes Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 1/4] tst_test.sh: runtest.sh: Remove unused code Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 2/4] tst_ansi_color.sh: Allow to run with set -e Petr Vorel
@ 2022-08-08 10:10 ` Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 4/4] generate_lvm_runfile.sh: Fix bashism Petr Vorel
3 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2022-08-08 10:10 UTC (permalink / raw)
To: ltp
If test exits on time (i.e. no timeout) kill in _tst_cleanup_timer()
have nothing to kill therefore following wait exits 143.
set -e (or #!/bin/sh -e or set -o errexit) quits on any non-zero exit code,
harden _tst_cleanup_timer() to be able to be used on scripts with it.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/tst_test.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 356af0106..1d2bf06cc 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -518,7 +518,7 @@ _tst_cleanup_timer()
{
if [ -n "$_tst_setup_timer_pid" ]; then
kill -TERM $_tst_setup_timer_pid 2>/dev/null
- wait $_tst_setup_timer_pid 2>/dev/null
+ wait $_tst_setup_timer_pid 2>/dev/null || true
fi
}
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread* [LTP] [PATCH v3 4/4] generate_lvm_runfile.sh: Fix bashism
2022-08-08 10:10 [LTP] [PATCH v3 0/4] set -e and bashism fixes Petr Vorel
` (2 preceding siblings ...)
2022-08-08 10:10 ` [LTP] [PATCH v3 3/4] tst_test.sh: Fix _tst_cleanup_timer() on " Petr Vorel
@ 2022-08-08 10:10 ` Petr Vorel
3 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2022-08-08 10:10 UTC (permalink / raw)
To: ltp
ERR is not on dash (tested on 0.5.11).
using -e (i.e. implying 'set -e') is required to exit on any non zero
exit code. It requires 2 previous fixes.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/misc/lvm/generate_lvm_runfile.sh | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/testcases/misc/lvm/generate_lvm_runfile.sh b/testcases/misc/lvm/generate_lvm_runfile.sh
index 72b286a69..aba706c64 100755
--- a/testcases/misc/lvm/generate_lvm_runfile.sh
+++ b/testcases/misc/lvm/generate_lvm_runfile.sh
@@ -1,6 +1,7 @@
-#!/bin/sh
+#!/bin/sh -e
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+# Copyright (c) Linux Test Project, 2022
#
# Generate LTP runfile for LVM tests (runtest/lvm.local)
@@ -13,7 +14,7 @@ LVM_TMPDIR="$LVM_DIR/ltp/growfiles"
generate_runfile()
{
- trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR
+ trap '[ $? -eq 0 ] || tst_brk TBROK "Cannot create LVM runfile"' EXIT
INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl"
OUTFILE="$LTPROOT/runtest/lvm.local"
FS_LIST=`tst_supported_fs`
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-08 11:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-08 10:10 [LTP] [PATCH v3 0/4] set -e and bashism fixes Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 1/4] tst_test.sh: runtest.sh: Remove unused code Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 2/4] tst_ansi_color.sh: Allow to run with set -e Petr Vorel
2022-08-08 11:12 ` Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 3/4] tst_test.sh: Fix _tst_cleanup_timer() on " Petr Vorel
2022-08-08 10:10 ` [LTP] [PATCH v3 4/4] generate_lvm_runfile.sh: Fix bashism Petr Vorel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.