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 new test case to validate N>&N redirect d...



details:   https://anonhg.NetBSD.org/src/rev/c548ed3e127a
branches:  trunk
changeset: 815404:c548ed3e127a
user:      kre <kre%NetBSD.org@localhost>
date:      Sun May 15 15:44:43 2016 +0000

description:
Add a new test case to validate N>&N redirect disables close-on-exec.
OK christos@

diffstat:

 tests/bin/sh/t_redircloexec.sh |  37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diffs (58 lines):

diff -r 6fa378d4ce54 -r c548ed3e127a tests/bin/sh/t_redircloexec.sh
--- a/tests/bin/sh/t_redircloexec.sh    Sun May 15 15:37:38 2016 +0000
+++ b/tests/bin/sh/t_redircloexec.sh    Sun May 15 15:44:43 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_redircloexec.sh,v 1.2 2016/03/16 21:13:51 christos Exp $
+# $NetBSD: t_redircloexec.sh,v 1.3 2016/05/15 15:44:43 kre Exp $
 #
 # Copyright (c) 2016 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -82,6 +82,40 @@
        cleanhelper exec
 }
 
+atf_test_case exec_redir_open
+exec_redir_open_head() {
+       atf_set "descr" "Tests that redirections created by exec can remain open"
+}
+exec_redir_open_body() {
+
+       mkhelper exec 6 \
+               "exec 6> out 6>&6; echo exec1 >&6; ${TEST_SH} exec2; exec 6>&-"
+
+       atf_check -s exit:0 -o empty -e empty ${TEST_SH} ./exec1
+       atf_check -s exit:0 -o empty -e empty ${TEST_SH} -e ./exec1
+
+       mkhelper exec 9 \
+               "exec 9> out ; echo exec1 >&9; ${TEST_SH} exec2 9>&9"
+
+       atf_check -s exit:0 -o empty -e empty ${TEST_SH} ./exec1
+
+       mkhelper exec 8 \
+               "exec 8> out; printf OK; exec 8>&8; echo exec1 >&8;" \
+               "printf OK; ${TEST_SH} exec2; printf OK"
+
+       atf_check -s exit:0 -o match:OKOKOK -e empty \
+               ${TEST_SH} -e ./exec1
+
+       mkhelper exec 7 \
+               "exec 7> out; printf OK; echo exec1 >&7;" \
+               "printf OK; ${TEST_SH} 7>&7 exec2; printf OK"
+
+       atf_check -s exit:0 -o match:OKOKOK -e empty \
+               ${TEST_SH} -e ./exec1
+
+       cleanhelper exec
+}
+
 atf_test_case loop_redir_open
 loop_redir_open_head() {
        atf_set "descr" "Tests that redirections in loops don't close on exec"
@@ -136,6 +170,7 @@
 
 atf_init_test_cases() {
        atf_add_test_case exec_redir_closed
+       atf_add_test_case exec_redir_open
        atf_add_test_case loop_redir_open
        atf_add_test_case compound_redir_open
        atf_add_test_case simple_redir_open



Home | Main Index | Thread Index | Old Index