Module Name: src Committed By: jmmv Date: Tue Oct 20 21:58:35 UTC 2009
Modified Files: src/tests/util/sh: Makefile t_expand.sh Added Files: src/tests/util/sh: t_exit.sh t_wait.sh Removed Files: src/tests/util/sh: t_exitstatus.sh Log Message: Migrate three sh test cases from regress to tests. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/util/sh/Makefile cvs rdiff -u -r0 -r1.1 src/tests/util/sh/t_exit.sh \ src/tests/util/sh/t_wait.sh cvs rdiff -u -r1.2 -r0 src/tests/util/sh/t_exitstatus.sh cvs rdiff -u -r1.3 -r1.4 src/tests/util/sh/t_expand.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/util/sh/Makefile diff -u src/tests/util/sh/Makefile:1.2 src/tests/util/sh/Makefile:1.3 --- src/tests/util/sh/Makefile:1.2 Wed Nov 21 15:39:35 2007 +++ src/tests/util/sh/Makefile Tue Oct 20 21:58:35 2009 @@ -1,15 +1,16 @@ -# $NetBSD: Makefile,v 1.2 2007/11/21 15:39:35 jmmv Exp $ +# $NetBSD: Makefile,v 1.3 2009/10/20 21:58:35 jmmv Exp $ .include <bsd.own.mk> TESTSDIR= ${TESTSBASE}/util/sh TESTS_SH= t_compexit -TESTS_SH+= t_exitstatus +TESTS_SH+= t_exit TESTS_SH+= t_expand TESTS_SH+= t_fsplit TESTS_SH+= t_here TESTS_SH+= t_set_e TESTS_SH+= t_varquote +TESTS_SH+= t_wait .include <bsd.test.mk> Index: src/tests/util/sh/t_expand.sh diff -u src/tests/util/sh/t_expand.sh:1.3 src/tests/util/sh/t_expand.sh:1.4 --- src/tests/util/sh/t_expand.sh:1.3 Wed Oct 14 13:02:03 2009 +++ src/tests/util/sh/t_expand.sh Tue Oct 20 21:58:35 2009 @@ -1,4 +1,4 @@ -# $NetBSD: t_expand.sh,v 1.3 2009/10/14 13:02:03 jmmv Exp $ +# $NetBSD: t_expand.sh,v 1.4 2009/10/20 21:58:35 jmmv Exp $ # # Copyright (c) 2007, 2009 The NetBSD Foundation, Inc. # All rights reserved. @@ -94,6 +94,17 @@ atf_check_equal '$stripped' '${line%%/\**}' } +atf_test_case varpattern_backslashes +varpattern_backslashes_head() { + atf_set "descr" "Tests that protecting wildcards with backslashes" \ + "works in variable patterns." +} +varpattern_backslashes_body() { + line='/foo/bar/*/baz' + stripped='/foo/bar/' + atf_check_equal $stripped ${line%%\**} +} + atf_test_case arithmetic arithmetic_head() { atf_set "descr" "POSIX requires shell arithmetic to use signed" \ @@ -111,5 +122,6 @@ atf_add_test_case dollar_at atf_add_test_case dollar_at_with_text atf_add_test_case strip + atf_add_test_case varpattern_backslashes atf_add_test_case arithmetic } Added files: Index: src/tests/util/sh/t_exit.sh diff -u /dev/null src/tests/util/sh/t_exit.sh:1.1 --- /dev/null Tue Oct 20 21:58:35 2009 +++ src/tests/util/sh/t_exit.sh Tue Oct 20 21:58:35 2009 @@ -0,0 +1,69 @@ +# $NetBSD: t_exit.sh,v 1.1 2009/10/20 21:58:35 jmmv Exp $ +# +# Copyright (c) 2007 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +crud() { + test yes = no + + cat <<EOF +$? +EOF +} + +atf_test_case function +function_head() { + atf_set "descr" "Tests that \$? is correctly updated inside" \ + "a function" +} +function_body() { + foo=`crud` + atf_check_equal 'x$foo' 'x1' +} + +atf_test_case readout +readout_head() { + atf_set "descr" "Tests that \$? is correctly updated in a" \ + "compound expression" +} +readout_body() { + atf_check_equal '$( true && ! true | false; echo $? )' '0' +} + +atf_test_case trap_subshell +trap_subshell_head() { + atf_set "descr" "Tests that the trap statement in a subshell" \ + "works when the subshell exits" +} +trap_subshell_body() { + atf_check -s eq:0 -o inline:'exiting\n' -x \ + '( trap "echo exiting" EXIT; /usr/bin/true )' +} + +atf_init_test_cases() { + atf_add_test_case function + atf_add_test_case readout + atf_add_test_case trap_subshell +} Index: src/tests/util/sh/t_wait.sh diff -u /dev/null src/tests/util/sh/t_wait.sh:1.1 --- /dev/null Tue Oct 20 21:58:35 2009 +++ src/tests/util/sh/t_wait.sh Tue Oct 20 21:58:35 2009 @@ -0,0 +1,44 @@ +# $NetBSD: t_wait.sh,v 1.1 2009/10/20 21:58:35 jmmv Exp $ +# +# Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +atf_test_case individual +individual_head() { + atf_set "descr" "Tests that waiting for individual jobs works" +} +individual_body() { + sleep 3 & + sleep 1 & + + wait %1 + [ $? = 0 ] || atf_fail "Waiting of first job failed" + wait %2 + [ $? = 0 ] || atf_fail "Waiting of second job failed" +} + +atf_init_test_cases() { + atf_add_test_case individual +}