Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/bin/sh More tests that were doing ... | atf_check ...



details:   https://anonhg.NetBSD.org/src/rev/3b7d2d712fc8
branches:  trunk
changeset: 1026397:3b7d2d712fc8
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Nov 22 05:07:15 2021 +0000

description:
More tests that were doing  ... | atf_check ...

which allows the atf_check to fail without causing the test to fail
(unless this is the (very) last command in the test case, in which case it
will fail with what can be interpreted as an internal error)/

Check for this failing and explicitly atf_fail whwn it does.

diffstat:

 tests/bin/sh/t_option.sh |   5 +++--
 tests/bin/sh/t_syntax.sh |   6 ++++--
 tests/bin/sh/t_varval.sh |  29 +++++++++++++++++++----------
 3 files changed, 26 insertions(+), 14 deletions(-)

diffs (129 lines):

diff -r a30897960e00 -r 3b7d2d712fc8 tests/bin/sh/t_option.sh
--- a/tests/bin/sh/t_option.sh  Sun Nov 21 23:58:09 2021 +0000
+++ b/tests/bin/sh/t_option.sh  Mon Nov 22 05:07:15 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_option.sh,v 1.7 2019/07/11 03:49:51 msaitoh Exp $
+# $NetBSD: t_option.sh,v 1.8 2021/11/22 05:07:15 kre Exp $
 #
 # Copyright (c) 2016 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -454,7 +454,8 @@
                        -o not-match:for -o not-match:do -o not-match:done \
                        -e match:printf -e match:111 -e not-match:111222 \
                        -e match:for -e match:do -e match:done \
-                               ${TEST_SH}
+                               ${TEST_SH} ||
+               atf_fail '111 222 333 test failure'
 }
 
 atf_test_case set_x
diff -r a30897960e00 -r 3b7d2d712fc8 tests/bin/sh/t_syntax.sh
--- a/tests/bin/sh/t_syntax.sh  Sun Nov 21 23:58:09 2021 +0000
+++ b/tests/bin/sh/t_syntax.sh  Mon Nov 22 05:07:15 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_syntax.sh,v 1.11 2021/11/16 11:12:14 kre Exp $
+# $NetBSD: t_syntax.sh,v 1.12 2021/11/22 05:07:15 kre Exp $
 #
 # Copyright (c) 2017 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -113,7 +113,7 @@
        atf_check -s exit:0 -o 'inline:##\n' -e empty ${TEST_SH} -c \
                'echo \## #\#'
 
-       cat <<-'DONE'|atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH}
+       cat <<-'DONE' |
                # test comments do not provoke synax errors !\
                echo foo # ( { " hello
                while : # that's forever
@@ -124,6 +124,8 @@
                # "hello
                exit 0
        DONE
+               atf_check -s exit:0 -o inline:'foo\n' -e empty ${TEST_SH} ||
+                       atf_fail "ignoring comments"
 }
 
 atf_test_case c_line_wrapping
diff -r a30897960e00 -r 3b7d2d712fc8 tests/bin/sh/t_varval.sh
--- a/tests/bin/sh/t_varval.sh  Sun Nov 21 23:58:09 2021 +0000
+++ b/tests/bin/sh/t_varval.sh  Mon Nov 22 05:07:15 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_varval.sh,v 1.1 2016/03/16 15:49:19 christos Exp $
+# $NetBSD: t_varval.sh,v 1.2 2021/11/22 05:07:15 kre Exp $
 #
 # Copyright (c) 2016 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -82,23 +82,28 @@
 aaa_body() {
        oneline "echo " 9 '' |
                atf_check -s exit:0 -o inline:'prefix\tsuffix\n' -e empty \
-                       ${TEST_SH}
+                       ${TEST_SH} ||
+                               atf_fail 'echo 9 -> tab'
 
        oneline "VAR=" 65 '; echo "${#VAR}:${VAR}"' |
                atf_check -s exit:0 -o inline:'13:prefixAsuffix\n' -e empty \
-                       ${TEST_SH}
+                       ${TEST_SH} ||
+                               atf_fail '65 -> A'
 
        oneline "VAR=" 1 '; echo "${#VAR}:${VAR}"' |
                atf_check -s exit:0 -o inline:'13:prefixsuffix\n' -e empty \
-                       ${TEST_SH}
+                       ${TEST_SH} ||
+                               atf_fail '1 -> ^A'
 
        oneline "VAR=" 10 '; echo "${#VAR}:${VAR}"' |
                atf_check -s exit:0 -o inline:'13:prefix\nsuffix\n' -e empty \
-                       ${TEST_SH}
+                       ${TEST_SH} ||
+                               atf_fail '10 -> \n'
 
        rm -f prefix* 2>/dev/null || :
        oneline "echo hello >" 45 "" |
-               atf_check -s exit:0 -o empty -e empty ${TEST_SH}
+               atf_check -s exit:0 -o empty -e empty ${TEST_SH} ||
+                       atf_fail 'redir into 45 -> E'
        test -f "prefix-suffix" ||
                atf_fail "failed to create prefix-suffix (45)"
        test -s "prefix-suffix" ||
@@ -119,7 +124,8 @@
 
        rm -f results || :
        mkdata "VAR=" -- '; echo ${#VAR}' |
-               atf_check -s exit:0 -o save:results -e empty ${TEST_SH}
+               atf_check -s exit:0 -o save:results -e empty ${TEST_SH} ||
+                       atf_fail 'making results'
        test -z $( grep -v "^13$" results ) ||
                atf_fail "Incorrect lengths: $(grep -nv '^13$' results)"
 
@@ -136,7 +142,8 @@
 
        rm -f results || :
        mkdata "VAR=" -- '; echo "${VAR}"' |
-               atf_check -s exit:0 -o save:results -e empty ${TEST_SH}
+               atf_check -s exit:0 -o save:results -e empty ${TEST_SH} ||
+                       atf_fail 'making results'
 
        # 256 because one output line contains a \n ...
        test $( wc -l < results ) -eq 256 ||
@@ -165,7 +172,8 @@
 
        mkdir prefix            # one of the files will be prefix/suffix
        mkdata "VAR=" -- '; echo "${VAR}" > "${VAR}"' |
-               atf_check -s exit:0 -o empty -e empty ${TEST_SH}
+               atf_check -s exit:0 -o empty -e empty ${TEST_SH} ||
+                       atf_fail "$VAR -> ./$VAR"
 
        test -f "prefix/suffix" ||
                atf_fail "Failed to create file in subdirectory"
@@ -220,7 +228,8 @@
                                (prefix | suffix)       continue;;
                                esac
                                echo "${VAR}" > "${VAR}"
-                       done'
+                       done' ||
+                               atf_fail 'mkdata'
 
        test -f "prefix/suffix" ||
                atf_fail "Failed to create file in subdirectory"



Home | Main Index | Thread Index | Old Index