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 for NetBSD specific readonl...
details: https://anonhg.NetBSD.org/src/rev/48b88c7025b9
branches: trunk
changeset: 995226:48b88c7025b9
user: kre <kre%NetBSD.org@localhost>
date: Wed Dec 12 11:52:05 2018 +0000
description:
Add a new test case for NetBSD specific readonly tests.
Add more sub-tests to the export_nbsd test case.
In both cases the new -q and -p VAR options are tested.
diffstat:
tests/bin/sh/t_builtins.sh | 87 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 86 insertions(+), 1 deletions(-)
diffs (115 lines):
diff -r 652463a9c34c -r 48b88c7025b9 tests/bin/sh/t_builtins.sh
--- a/tests/bin/sh/t_builtins.sh Wed Dec 12 11:51:33 2018 +0000
+++ b/tests/bin/sh/t_builtins.sh Wed Dec 12 11:52:05 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_builtins.sh,v 1.3 2018/12/12 08:10:39 kre Exp $
+# $NetBSD: t_builtins.sh,v 1.4 2018/12/12 11:52:05 kre Exp $
#
# Copyright (c) 2018 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -416,6 +416,45 @@
atf_check -s not-exit:0 -e not-empty -o empty ${TEST_SH} -c \
'export VAR=exported; export -x VAR; export VAR=FOO'
+
+ have_builtin export '' 'export VAR;' '-q VAR' ' -q' || return 0
+
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'unset VAR; VAR=set; export -q VAR'
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ 'export VAR=set; export -q VAR'
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'VAR=set; RW=set; export -q VAR RW'
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'VAR=set; export RO=set; export -q VAR RO'
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ 'export VAR=set RO=set; export -q VAR RO'
+
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'unset VAR; export -q VAR'
+ # next one is the same as the have_builtin test, so "cannot" fail...
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ 'unset VAR; export VAR; export -q VAR'
+
+ # if we have -q we should also have -p var...
+ # What's more, we are testing NetBSD sh, so we know output format.
+
+ atf_check -s exit:0 -e empty -o match:VAR=foobar \
+ ${TEST_SH} -c \
+ 'VAR=foobar ; export VAR ; export -p VAR'
+ atf_check -s exit:0 -e empty -o inline:1 \
+ ${TEST_SH} -c \
+ 'VAR=foobar ; export VAR ;
+ printf %d $(export -p VAR | wc -l)'
+ atf_check -s exit:0 -e empty \
+ -o inline:'export VAR=foobar\nexport OTHER\n' \
+ ${TEST_SH} -c \
+ 'VAR=foobar; export VAR OTHER; export -p VAR OTHER'
+ atf_check -s exit:0 -e empty \
+ -o inline:'export A=aaa\nexport B\nexport D='"''"'\n' \
+ ${TEST_SH} -c \
+ 'A=aaa D= C=foo; unset B; export A B D;
+ export -p A B C D'
}
atf_test_case getopts
@@ -516,6 +555,51 @@
'unset VAR; readonly VAR=set; unset VAR; printf %s ${VAR-unset}'
}
+atf_test_case readonly_nbsd
+readonly_nbsd_head() {
+ atf_set "descr" "Tests NetBSD extensions to 'readonly'"
+}
+readonly_nbsd_body() {
+ have_builtin readonly '' 'readonly VAR;' '-q VAR' ' -q' || return 0
+
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'VAR=set; readonly -q VAR'
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ 'readonly VAR=set; readonly -q VAR'
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'VAR=set; RW=set; readonly -q VAR RW'
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'VAR=set; readonly RO=set; readonly -q VAR RO'
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ 'readonly VAR=set RO=set; readonly -q VAR RO'
+
+ atf_check -s exit:1 -o empty -e empty ${TEST_SH} -c \
+ 'unset VAR; readonly -q VAR'
+ # next one is the same as the have_builtin test, so "cannot" fail...
+ atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+ 'unset VAR; readonly VAR; readonly -q VAR'
+
+ # if we have -q we should also have -p var...
+ # What's more, we are testing NetBSD sh, so we know output format.
+
+ atf_check -s exit:0 -e empty -o match:VAR=foobar \
+ ${TEST_SH} -c \
+ 'VAR=foobar ; readonly VAR ; readonly -p VAR'
+ atf_check -s exit:0 -e empty -o inline:1 \
+ ${TEST_SH} -c \
+ 'VAR=foobar ; readonly VAR ;
+ printf %d $(readonly -p VAR | wc -l)'
+ atf_check -s exit:0 -e empty \
+ -o inline:'readonly VAR=foobar\nreadonly OTHER\n' \
+ ${TEST_SH} -c \
+ 'VAR=foobar; readonly VAR OTHER; readonly -p VAR OTHER'
+ atf_check -s exit:0 -e empty \
+ -o inline:'readonly A=aaa\nreadonly B\nreadonly D='"''"'\n' \
+ ${TEST_SH} -c \
+ 'A=aaa D= C=foo; unset B; readonly A B D;
+ readonly -p A B C D'
+}
+
atf_test_case cd_pwd
cd_pwd_head() {
atf_set "descr" "Tests the shell builtins 'cd' & 'pwd'"
@@ -830,6 +914,7 @@
atf_add_test_case jobid
atf_add_test_case let
atf_add_test_case local
+ atf_add_test_case readonly_nbsd
atf_add_test_case setvar
# inputrc should probably be tested in libedit tests (somehow)
Home |
Main Index |
Thread Index |
Old Index