Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/util/sh Migrate three sh test cases from regress to te...
details: https://anonhg.NetBSD.org/src/rev/83ce95ebb8a9
branches: trunk
changeset: 748328:83ce95ebb8a9
user: jmmv <jmmv%NetBSD.org@localhost>
date: Tue Oct 20 21:58:35 2009 +0000
description:
Migrate three sh test cases from regress to tests.
diffstat:
tests/util/sh/Makefile | 5 +-
tests/util/sh/t_exit.sh | 69 +++++++++++++++++++++++++++++++++++++++++++
tests/util/sh/t_exitstatus.sh | 58 ------------------------------------
tests/util/sh/t_expand.sh | 14 ++++++++-
tests/util/sh/t_wait.sh | 44 +++++++++++++++++++++++++++
5 files changed, 129 insertions(+), 61 deletions(-)
diffs (239 lines):
diff -r 8ea7cd1db738 -r 83ce95ebb8a9 tests/util/sh/Makefile
--- a/tests/util/sh/Makefile Tue Oct 20 20:55:01 2009 +0000
+++ b/tests/util/sh/Makefile Tue Oct 20 21:58:35 2009 +0000
@@ -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>
diff -r 8ea7cd1db738 -r 83ce95ebb8a9 tests/util/sh/t_exit.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/util/sh/t_exit.sh Tue Oct 20 21:58:35 2009 +0000
@@ -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
+}
diff -r 8ea7cd1db738 -r 83ce95ebb8a9 tests/util/sh/t_exitstatus.sh
--- a/tests/util/sh/t_exitstatus.sh Tue Oct 20 20:55:01 2009 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-# $NetBSD: t_exitstatus.sh,v 1.2 2008/04/30 13:11:00 martin 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_init_test_cases() {
- atf_add_test_case function
- atf_add_test_case readout
-}
diff -r 8ea7cd1db738 -r 83ce95ebb8a9 tests/util/sh/t_expand.sh
--- a/tests/util/sh/t_expand.sh Tue Oct 20 20:55:01 2009 +0000
+++ b/tests/util/sh/t_expand.sh Tue Oct 20 21:58:35 2009 +0000
@@ -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
}
diff -r 8ea7cd1db738 -r 83ce95ebb8a9 tests/util/sh/t_wait.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/util/sh/t_wait.sh Tue Oct 20 21:58:35 2009 +0000
@@ -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
+}
Home |
Main Index |
Thread Index |
Old Index