Module Name:    src
Committed By:   kre
Date:           Mon Nov 22 05:07:15 UTC 2021

Modified Files:
        src/tests/bin/sh: t_option.sh t_syntax.sh t_varval.sh

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/bin/sh/t_option.sh
cvs rdiff -u -r1.11 -r1.12 src/tests/bin/sh/t_syntax.sh
cvs rdiff -u -r1.1 -r1.2 src/tests/bin/sh/t_varval.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/bin/sh/t_option.sh
diff -u src/tests/bin/sh/t_option.sh:1.7 src/tests/bin/sh/t_option.sh:1.8
--- src/tests/bin/sh/t_option.sh:1.7	Thu Jul 11 03:49:51 2019
+++ src/tests/bin/sh/t_option.sh	Mon Nov 22 05:07:15 2021
@@ -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 @@ set_v_body() {
 			-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

Index: src/tests/bin/sh/t_syntax.sh
diff -u src/tests/bin/sh/t_syntax.sh:1.11 src/tests/bin/sh/t_syntax.sh:1.12
--- src/tests/bin/sh/t_syntax.sh:1.11	Tue Nov 16 11:12:14 2021
+++ src/tests/bin/sh/t_syntax.sh	Mon Nov 22 05:07:15 2021
@@ -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 @@ b_comments_body() {
 	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 @@ b_comments_body() {
 		# "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

Index: src/tests/bin/sh/t_varval.sh
diff -u src/tests/bin/sh/t_varval.sh:1.1 src/tests/bin/sh/t_varval.sh:1.2
--- src/tests/bin/sh/t_varval.sh:1.1	Wed Mar 16 15:49:19 2016
+++ src/tests/bin/sh/t_varval.sh	Mon Nov 22 05:07:15 2021
@@ -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_head() {
 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 @@ assignment_body() {
 
 	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 @@ cmdline_body() {
 
 	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 @@ redirect_body() {
 
 	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 @@ read_body() {
 				(prefix | suffix)	continue;;
 				esac
 				echo "${VAR}" > "${VAR}"
-			done'
+			done' ||
+				atf_fail 'mkdata'
 
 	test -f "prefix/suffix" ||
 		atf_fail "Failed to create file in subdirectory"

Reply via email to