Module Name: src Committed By: kre Date: Sun Jul 21 15:25:59 UTC 2019
Modified Files: src/tests/usr.bin/printf: printf.sh Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/printf/printf.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/printf/printf.sh diff -u src/tests/usr.bin/printf/printf.sh:1.3 src/tests/usr.bin/printf/printf.sh:1.4 --- src/tests/usr.bin/printf/printf.sh:1.3 Fri Sep 14 19:57:57 2018 +++ src/tests/usr.bin/printf/printf.sh Sun Jul 21 15:25:59 2019 @@ -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