Source-Changes-HG archive

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

[src/trunk]: src/tests/bin/sh Add a test for fd redirections on functions in ...



details:   https://anonhg.NetBSD.org/src/rev/f722787cf274
branches:  trunk
changeset: 815319:f722787cf274
user:      kre <kre%NetBSD.org@localhost>
date:      Wed May 11 17:43:17 2016 +0000

description:
Add a test for fd redirections on functions in loops (the etcupdate issue)
and also fix a quoting bug which was causing a test to fail, though
ATF was ignoring (an ATF bug to be investigated later.)

OK christos@

diffstat:

 tests/bin/sh/t_redir.sh |  18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diffs (39 lines):

diff -r d5388284b197 -r f722787cf274 tests/bin/sh/t_redir.sh
--- a/tests/bin/sh/t_redir.sh   Wed May 11 17:28:30 2016 +0000
+++ b/tests/bin/sh/t_redir.sh   Wed May 11 17:43:17 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_redir.sh,v 1.7 2016/05/09 22:34:37 kre Exp $
+# $NetBSD: t_redir.sh,v 1.8 2016/05/11 17:43:17 kre Exp $
 #
 # Copyright (c) 2016 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -786,6 +786,20 @@
                ${TEST_SH} -c \
                   ". ./f-def; { f;f>/dev/null;}& wait; printf '%s\n' success10"
 
+       # This one tests the issue etcupdate had with the original 48875 fix
+       atf_check -s exit:0 -o inline:'Func a\nFunc b\nFunc c\n' -e empty \
+               ${TEST_SH} -c '
+                       f() {
+                               echo Func "$1"
+                       }
+                       exec 3<&0 4>&1
+                       ( echo x-a; echo y-b; echo z-c ) |
+                       while read A
+                       do
+                               B=${A#?-}
+                               f "$B" <&3 >&4
+                       done >&2'
+
        # Tests with sh reading stdin, which is not quite the same internal
        # mechanism.
        echo ". ./f-def || echo >&2 FAIL
@@ -796,7 +810,7 @@
        echo '
                . ./f-def || echo >&2 FAIL
                f >&-
-               printf '%s\n' stdin2
+               printf "%s\n" stdin2
        ' | atf_check -s exit:0 -o inline:'stdin2\n' -e empty ${TEST_SH}
 
        cat <<- 'DONE' > fgh.def



Home | Main Index | Thread Index | Old Index