+2008-05-06 Eric Blake <ebb9@byu.net>
+
+ Improve behavior of './testsuite 01'.
+ * lib/autotest/general.m4 (AT_INIT) <at_func_validate_ranges>:
+ Alter usage to eval its arguments, in order to normalize away
+ leading zero. All callers updated.
+ * tests/autotest.at (Keywords and ranges): Test range
+ normalization with leading 0.
+
2008-04-26 Eric Blake <ebb9@byu.net>
Mention Solaris /usr/ucb/tr pitfall.
# at_func_arith
# -------------
-# Arithmetic evaluation, avoids expr if the shell is sane.
+# Arithmetic evaluation, avoids expr if the shell is sane. The
+# interpretation of leading zeroes is unspecified.
#
# subshell and eval are needed to keep Solaris sh from bailing out:
if ( eval 'test $(( 1 + 1 )) = 2' ) 2>/dev/null; then
# Description of all the test groups.
at_help_all="AS_ESCAPE(m4_dquote(m4_defn([AT_help_all])))"
-# at_func_validate_ranges [N...]
-# ------------------------------
-# validate test group ranges
+# at_func_validate_ranges [NAME...]
+# ---------------------------------
+# Validate and normalize the test group number contained in each
+# variable NAME. Leading zeroes are treated as decimal.
at_func_validate_ranges ()
{
for at_grp
do
- if test $at_grp -lt 1 || test $at_grp -gt AT_ordinal; then
- AS_ECHO(["invalid test group: $at_grp"]) >&2
+ eval at_value=\$$at_grp
+ if test $at_value -lt 1 || test $at_value -gt AT_ordinal; then
+ AS_ECHO(["invalid test group: $at_value"]) >&2
exit 1
fi
+ case $at_value in
+ 0*) # We want to treat leading 0 as decimal, like expr and test, but
+ # at_func_arith treats it as octal if it uses $(( )).
+ # With XSI shells, ${at_value#${at_value%%[1-9]*}} avoids the
+ # expr fork, but it is not worth the effort to determine if the
+ # shell supports XSI when the user can just avoid leading 0.
+ eval $at_grp='`expr $at_value + 0`' ;;
+ esac
done
}])])dnl
m4_divert_push([PARSE_ARGS])dnl
;;
[[0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9]])
- at_func_validate_ranges $at_option
+ at_func_validate_ranges at_option
at_groups="$at_groups$at_option "
;;
# Ranges
[[0-9]- | [0-9][0-9]- | [0-9][0-9][0-9]- | [0-9][0-9][0-9][0-9]-])
at_range_start=`echo $at_option |tr -d X-`
- at_func_validate_ranges $at_range_start
+ at_func_validate_ranges at_range_start
at_range=`AS_ECHO([" $at_groups_all "]) | \
sed -e 's/^.* \('$at_range_start' \)/\1/'`
at_groups="$at_groups$at_range "
[-[0-9] | -[0-9][0-9] | -[0-9][0-9][0-9] | -[0-9][0-9][0-9][0-9]])
at_range_end=`echo $at_option |tr -d X-`
- at_func_validate_ranges $at_range_end
+ at_func_validate_ranges at_range_end
at_range=`AS_ECHO([" $at_groups_all "]) | \
sed -e 's/\( '$at_range_end'\) .*$/\1/'`
at_groups="$at_groups$at_range "
at_range_end=$at_range_start
at_range_start=$at_tmp
fi
- at_func_validate_ranges $at_range_start $at_range_end
+ at_func_validate_ranges at_range_start at_range_end
at_range=`AS_ECHO([" $at_groups_all "]) | \
sed -e 's/^.*\( '$at_range_start' \)/\1/' \
-e 's/\( '$at_range_end'\) .*$/\1/'`
AT_CHECK_AT_PREP([k],
[[AT_INIT
-AT_SETUP(none)
+AT_SETUP(none) # 01
AT_CHECK(:)
AT_CLEANUP
-AT_SETUP(first)
+AT_SETUP(first) # 02
AT_KEYWORDS(key1)
AT_CHECK(:)
AT_CLEANUP
-AT_SETUP(second)
+AT_SETUP(second) # 03
AT_KEYWORDS(key2)
AT_CHECK(:)
AT_CLEANUP
-AT_SETUP(both)
+AT_SETUP(both) # 04
AT_KEYWORDS([key1 key2])
AT_KEYWORDS([key1])
AT_CHECK(:)
AT_CLEANUP
+AT_SETUP(test5) # 05
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test6) # 06
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test7) # 07
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test8) # 08
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test9) # 09
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test10) # 10
+AT_CHECK(:)
+AT_CLEANUP
]])
dnl check that AT_KEYWORDS does not duplicate words
AT_CHECK([grep 'key1.*key1' k], [1])
AT_CHECK_KEYS([-k 'fir.*'], [first], [1], [none|second|both], [0])
AT_CHECK_KEYS([1-2], [none|first], [2], [second|both], [0])
+AT_CHECK_KEYS([01-002 08], [none|first], [2], [second|both], [0])
AT_CHECK_KEYS([1-3 2-1], [none|first|second], [3], [both], [0])
AT_CHECK_KEYS([-3], [none|first|second], [3], [both], [0])
AT_CHECK_KEYS([4-], [both], [1], [none|first|second], [0])
+AT_CHECK_KEYS([010], [test10], [1], [none|first|second|both], [0])
AT_CHECK_KEYS([-k second 4-], [second|both], [2], [none|first], [0])
AT_CHECK([$CONFIG_SHELL ./k 0], [1], [ignore], [ignore])
AT_CHECK([$CONFIG_SHELL ./k 0-], [1], [ignore], [ignore])
AT_CHECK([$CONFIG_SHELL ./k -0], [1], [ignore], [ignore])
-AT_CHECK([$CONFIG_SHELL ./k 5], [1], [ignore], [ignore])
-AT_CHECK([$CONFIG_SHELL ./k 5-], [1], [ignore], [ignore])
-AT_CHECK([$CONFIG_SHELL ./k 1-5], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 11], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 11-], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 1-011], [1], [ignore], [ignore])
AT_CHECK([$CONFIG_SHELL ./k -k nonexistent], [0], [ignore])
AT_CHECK_KEYS([--list -k nonexistent], [KEYWORDS], [1], [first|second|both], [0])
AT_CHECK_KEYS([--list 1], [none], [1], [first|second|both], [0])
+AT_CHECK_KEYS([--list 01], [none], [1], [first|second|both], [0])
AT_CHECK_KEYS([--list -k none -k first], [none|first], [2], [second|both], [0])
AT_CLEANUP