Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/printf Stop assuming that printf handles optio...



details:   https://anonhg.NetBSD.org/src/rev/723c13706d77
branches:  trunk
changeset: 457806:723c13706d77
user:      kre <kre%NetBSD.org@localhost>
date:      Sun Jul 21 15:25:59 2019 +0000

description:
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:

 tests/usr.bin/printf/printf.sh |  37 +++++++++++++++++--------------------
 1 files changed, 17 insertions(+), 20 deletions(-)

diffs (69 lines):

diff -r ebd231e3c761 -r 723c13706d77 tests/usr.bin/printf/printf.sh
--- a/tests/usr.bin/printf/printf.sh    Sun Jul 21 15:25:39 2019 +0000
+++ b/tests/usr.bin/printf/printf.sh    Sun Jul 21 15:25:59 2019 +0000
@@ -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 @@
 {
        setmsg basic
 
-       for A in '' -- -@       # hope that '@' is not an option to printf...
+       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:-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 "%${A}%" >/dev/null 2>&1)
                then
                        atf_fail "%${A}% successful"
@@ -232,11 +230,10 @@
        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 @@
 }
 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



Home | Main Index | Thread Index | Old Index