summaryrefslogtreecommitdiff
path: root/tests/usr.bin
diff options
context:
space:
mode:
authorkre <kre@NetBSD.org>2019-07-21 15:25:59 +0000
committerkre <kre@NetBSD.org>2019-07-21 15:25:59 +0000
commit9b014d6c097bee583a2f486dc23c6c039b080eb6 (patch)
tree53f5faaa3459de18890b7f7aa8ed7e6a34681bc1 /tests/usr.bin
parentf7137fdf8a6a3cfa4fd08b92c56ccb1ec9b3eefe (diff)
Stop assuming that printf handles options in any way at all
(it doesn't - that is, shouldn't) which includes processing -- as an "end of options". The first arg is (always) the format string. Remove/fix tests that assumed the contrary. Problem (with printf) pointed out on tech-userlevel by Thierry Laronde.
Diffstat (limited to 'tests/usr.bin')
-rw-r--r--tests/usr.bin/printf/printf.sh37
1 files changed, 17 insertions, 20 deletions
diff --git a/tests/usr.bin/printf/printf.sh b/tests/usr.bin/printf/printf.sh
index 7d89c8e57e3..64e2dda7772 100644
--- a/tests/usr.bin/printf/printf.sh
+++ b/tests/usr.bin/printf/printf.sh
@@ -1,4 +1,4 @@
-# $NetBSD: printf.sh,v 1.3 2018/09/14 19:57:57 kre Exp $
+# $NetBSD: printf.sh,v 1.4 2019/07/21 15:25:59 kre Exp $
#
# Copyright (c) 2018 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -206,23 +206,21 @@ basic()
{
setmsg basic
- for A in '' -- -@ # hope that '@' is not an option to printf...
- do
- if (do_printf $A >/dev/null 2>&1)
- then
- atf_fail "${A:-with no args} successful"
- fi
- if test -n "$( do_printf 2>/dev/null )"
- then
- atf_fail "${A:-with no args} produces text on stdout"
- fi
- if test -z "$( do_printf 2>&1 )"
- then
- atf_fail "${A:-with no args} no err/usage message"
- fi
-
- test -z "$A" && continue
+ if (do_printf >/dev/null 2>&1)
+ then
+ atf_fail "with no args successful"
+ fi
+ if test -n "$( do_printf 2>/dev/null )"
+ then
+ atf_fail "with no args produces text on stdout"
+ fi
+ if test -z "$( do_printf 2>&1 )"
+ then
+ atf_fail "with no args no err/usage message"
+ fi
+ for A in - -- X 1
+ do
if (do_printf "%${A}%" >/dev/null 2>&1)
then
atf_fail "%${A}% successful"
@@ -232,11 +230,10 @@ basic()
expect abcd abcd
expect % %%
expect xxx%yyy xxx%%yyy
- expect -123 -- -123
+ expect -123 -123
# technically these are all unspecified, but the only rational thing
expect_fail '' %3%
- expect_fail '' -123
expect_fail a a%.%
expect_fail '' '%*%b' # cannot continue after bad format
expect_fail a a%-%b # hence 'b' is not part of output
@@ -1126,7 +1123,7 @@ G_floats()
}
define G_floats '%G (floating) conversions'
-# It is difficul;t to test correct results from the %a conversions,
+# It is difficult to test correct results from the %a conversions,
# as they depend upon the underlying floating point format (not
# necessarily IEEE) and other factors chosen by the implementation,
# eg: the (floating) number 1 could be 0x8p-3 0x4p-2 0x1p-1 even