Source-Changes-HG archive

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

[src/trunk]: src/tests/bin/sh Give this test a promotion! This was the test...



details:   https://anonhg.NetBSD.org/src/rev/95ef30672dd4
branches:  trunk
changeset: 824963:95ef30672dd4
user:      kre <kre%NetBSD.org@localhost>
date:      Sat Jun 24 11:09:42 2017 +0000

description:
Give this test a promotion!   This was the test that enabled the sh's
STACKSTRNUL() bug to eventually be found.   Not any of the test cases
directly - the shell running the tests (the same /bin/sh) managed to
build one of the f_variable_syntax sub-tests incorrectly, and that was
enough to eventually allow the bug to be located and squashed.

Like all good promotions, this one comes with increased work, and no extra pay.

diffstat:

 tests/bin/sh/t_syntax.sh |  54 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 2 deletions(-)

diffs (75 lines):

diff -r 0de2769417fd -r 95ef30672dd4 tests/bin/sh/t_syntax.sh
--- a/tests/bin/sh/t_syntax.sh  Sat Jun 24 11:06:17 2017 +0000
+++ b/tests/bin/sh/t_syntax.sh  Sat Jun 24 11:09:42 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_syntax.sh,v 1.4 2017/06/16 07:30:32 kre Exp $
+# $NetBSD: t_syntax.sh,v 1.5 2017/06/24 11:09:42 kre Exp $
 #
 # Copyright (c) 2017 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -364,7 +364,9 @@
        for vname in a ab _a _9 a123 a_1_2_3 __ ___ ____ __1__ _0 \
            A AA AAA AaBb _A_a A_a_ a1_ abc_123 ab_12_cd_ef_34_99 \
            abcdefghijklmnopqrstuvwzyz ABCDEFGHIJKLMNOPQRSTUVWXYZ_ \
-           
A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all xyzzy \
+           
A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all \
+           
Then_Make_it_Even_Longer_by_Multiplying_it___A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all__A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all__A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all__A_VERY_LONG_VARIABLE_NAME_that_is_probably_longer_than_most_used_in_the_average_shell_script_already_about_100_chars_in_this_one_but_there_is_not_supposed_to_be_any_limit_on_the_length_at_all
 \
+           xyzzy __0123454321__ _0_1_2_3_4_5_6_7_8_9_ ABBA X_ Y__ Z___ \
            _____________________________________________________________
        do
                atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
@@ -383,6 +385,54 @@
                        "${vname}=GOOD; unset ${vname}x; printf %s \$${vname}"
                atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
                        "unset ${vname}x; ${vname}=GOOD; printf %s \$${vname}x"
+               atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
+                       "${vname}=GOOD; ${vname}_=BAD; printf %s \$${vname}"
+
+               case "${vname}" in
+               ?)      continue;;
+               esac
+
+               # The following tests do not work for 1 char var names.
+               # hence the check and "continue" above to skip the remaining
+               # tests for that case
+
+               atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
+                       "${vname}=GOOD; unset ${vname%?}; printf %s \$${vname}"
+
+               # (this next would work, but becomes just a duplicate of
+               # an earlier test, so is pointless for 1 ch names)
+               atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
+       "${vname}=GOOD; unset ${vname}x ${vname%?}; printf %s \$${vname}"
+
+               atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+                       "unset ${vname%?};${vname}=GOOD; printf %s \$${vname%?}"
+
+               atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
+                       "${vname}=GOOD; ${vname%?}=BAD; printf %s \$${vname}"
+
+               # all the remaining tests require the 2nd char of the
+               # variable name to be a legal first character.  That
+               # is, not a digit, so skip the rest if we have a digit
+               # second...
+               case "${vname}" in
+               ?[0-9]*)        continue;;
+               esac
+
+               atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
+                       "${vname}=GOOD; unset ${vname#?}; printf %s \$${vname}"
+               atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+                       "unset ${vname#?};${vname}=GOOD; printf %s \$${vname#?}"
+
+               atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
+                       "${vname}=GOOD; ${vname#?}=BAD; printf %s \$${vname}"
+
+               atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \
+                       "unset ${vname%?} ${vname#?} ${vname}x; ${vname}=GOOD;
+                       printf %s \$${vname%?}\$${vname#?}\$${vname}x"
+
+               atf_check -s exit:0 -o match:GOOD -e empty ${TEST_SH} -c \
+                       "${vname}=GOOD; ${vname%?}=BAD; ${vname}_=BAD;
+                       ${vname#?}=BAD; printf %s \$${vname}"
        done
 
        # don't test '.' in var names, some shells permit that (in ${} anyway)



Home | Main Index | Thread Index | Old Index