2016-01-07 16:51:53 +08:00
|
|
|
#!/bin/sh
|
2000-07-08 05:06:48 +08:00
|
|
|
# Testing of printf.
|
2019-01-01 08:11:28 +08:00
|
|
|
# Copyright (C) 2000-2019 Free Software Foundation, Inc.
|
2000-07-08 05:06:48 +08:00
|
|
|
# This file is part of the GNU C Library.
|
2001-07-06 12:58:11 +08:00
|
|
|
|
2000-07-08 05:06:48 +08:00
|
|
|
# The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 12:58:11 +08:00
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
2000-07-08 05:06:48 +08:00
|
|
|
# The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 12:58:11 +08:00
|
|
|
# Lesser General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
2012-02-10 07:18:22 +08:00
|
|
|
# License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 13:40:42 +08:00
|
|
|
# <https://www.gnu.org/licenses/>.
|
2000-07-08 05:06:48 +08:00
|
|
|
|
2012-09-25 04:52:13 +08:00
|
|
|
set -e
|
|
|
|
|
2000-07-08 05:06:48 +08:00
|
|
|
common_objpfx=$1; shift
|
2013-01-11 23:14:18 +08:00
|
|
|
test_program_prefix=$1; shift
|
2000-07-08 05:06:48 +08:00
|
|
|
|
|
|
|
status=0
|
|
|
|
|
2013-01-11 23:14:18 +08:00
|
|
|
${test_program_prefix} \
|
2000-07-08 05:06:48 +08:00
|
|
|
${common_objpfx}stdio-common/tst-printf \
|
|
|
|
> ${common_objpfx}stdio-common/tst-printf.out || status=1
|
|
|
|
|
|
|
|
cat <<'EOF' |
|
|
|
|
%.4x: `0012'
|
|
|
|
%04x: `0012'
|
|
|
|
%4.4x: `0012'
|
|
|
|
%04.4x: `0012'
|
|
|
|
%4.3x: ` 012'
|
|
|
|
%04.3x: ` 012'
|
|
|
|
%.*x: `0012'
|
|
|
|
%0*x: `0012'
|
|
|
|
%*.*x: `0012'
|
|
|
|
%0*.*x: `0012'
|
|
|
|
bad format: "%b"
|
|
|
|
nil pointer (padded): " (nil)"
|
|
|
|
decimal negative: "-2345"
|
|
|
|
octal negative: "37777773327"
|
|
|
|
hex negative: "fffff6d7"
|
|
|
|
long decimal number: "-123456"
|
|
|
|
long octal negative: "37777773327"
|
|
|
|
long unsigned decimal number: "4294843840"
|
|
|
|
zero-padded LDN: "-000123456"
|
|
|
|
left-adjusted ZLDN: "-123456 "
|
|
|
|
space-padded LDN: " -123456"
|
|
|
|
left-adjusted SLDN: "-123456 "
|
|
|
|
zero-padded string: " Hi, Z."
|
|
|
|
left-adjusted Z string: "Hi, Z. "
|
|
|
|
space-padded string: " Hi, Z."
|
|
|
|
left-adjusted S string: "Hi, Z. "
|
|
|
|
null string: "(null)"
|
|
|
|
limited string: "Good morning, Doctor C"
|
2017-10-14 02:44:39 +08:00
|
|
|
a-style max: "0x1.fffffffffffffp+1023"
|
|
|
|
a-style -max: "-0x1.fffffffffffffp+1023"
|
2000-07-08 05:06:48 +08:00
|
|
|
e-style >= 1: "1.234000e+01"
|
|
|
|
e-style >= .1: "1.234000e-01"
|
|
|
|
e-style < .1: "1.234000e-03"
|
|
|
|
e-style big: "1.000000000000000000000000000000000000000000000000000000000000e+20"
|
|
|
|
e-style == .1: "1.000000e-01"
|
|
|
|
f-style >= 1: "12.340000"
|
|
|
|
f-style >= .1: "0.123400"
|
|
|
|
f-style < .1: "0.001234"
|
|
|
|
g-style >= 1: "12.34"
|
|
|
|
g-style >= .1: "0.1234"
|
|
|
|
g-style < .1: "0.001234"
|
|
|
|
g-style big: "100000000000000000000"
|
|
|
|
0.10000
|
|
|
|
0.10000
|
|
|
|
x0.5000x
|
|
|
|
0x1
|
|
|
|
something really insane: 1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
4.94066e-324
|
|
|
|
| 0.0000| 0.0000e+00| 0|
|
|
|
|
| 1.0000| 1.0000e+00| 1|
|
|
|
|
| -1.0000| -1.0000e+00| -1|
|
|
|
|
| 100.0000| 1.0000e+02| 100|
|
|
|
|
| 1000.0000| 1.0000e+03| 1000|
|
|
|
|
| 10000.0000| 1.0000e+04| 1e+04|
|
|
|
|
| 12345.0000| 1.2345e+04| 1.234e+04|
|
|
|
|
| 100000.0000| 1.0000e+05| 1e+05|
|
|
|
|
| 123456.0000| 1.2346e+05| 1.235e+05|
|
|
|
|
snprintf ("%30s", "foo") == 30, " "
|
2002-03-14 07:44:36 +08:00
|
|
|
snprintf ("%.999999u", 10) == 999999
|
2017-10-14 02:44:39 +08:00
|
|
|
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00000000
|
|
|
|
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00000000
|
2000-07-08 05:06:48 +08:00
|
|
|
1.234568e+06 should be 1.234568e+06
|
|
|
|
1234567.800000 should be 1234567.800000
|
|
|
|
1.23457e+06 should be 1.23457e+06
|
|
|
|
123.456 should be 123.456
|
|
|
|
1e+06 should be 1e+06
|
|
|
|
10 should be 10
|
|
|
|
0.02 should be 0.02
|
|
|
|
Test ok.
|
|
|
|
sprintf (buf, "%07Lo", 040000000000ll) = 40000000000
|
2000-09-25 13:12:05 +08:00
|
|
|
printf ("%hhu", 257) = 1
|
|
|
|
printf ("%hu", 65537) = 1
|
2006-05-05 21:37:35 +08:00
|
|
|
printf ("%hhi", 257) = 1
|
|
|
|
printf ("%hi", 65537) = 1
|
|
|
|
printf ("%1$hhu", 257) = 1
|
|
|
|
printf ("%1$hu", 65537) = 1
|
|
|
|
printf ("%1$hhi", 257) = 1
|
|
|
|
printf ("%1$hi", 65537) = 1
|
2000-07-08 05:06:48 +08:00
|
|
|
--- Should be no further output. ---
|
|
|
|
EOF
|
2001-03-04 16:47:11 +08:00
|
|
|
cmp - ${common_objpfx}stdio-common/tst-printf.out > /dev/null 2>&1 ||
|
2000-09-15 06:42:29 +08:00
|
|
|
cat <<'EOF' |
|
|
|
|
%.4x: `0012'
|
|
|
|
%04x: `0012'
|
|
|
|
%4.4x: `0012'
|
|
|
|
%04.4x: `0012'
|
|
|
|
%4.3x: ` 012'
|
|
|
|
%04.3x: ` 012'
|
|
|
|
%.*x: `0012'
|
|
|
|
%0*x: `0012'
|
|
|
|
%*.*x: `0012'
|
|
|
|
%0*.*x: `0012'
|
|
|
|
bad format: "%b"
|
|
|
|
nil pointer (padded): " (nil)"
|
|
|
|
decimal negative: "-2345"
|
|
|
|
octal negative: "37777773327"
|
|
|
|
hex negative: "fffff6d7"
|
|
|
|
long decimal number: "-123456"
|
|
|
|
long octal negative: "1777777777777777773327"
|
|
|
|
long unsigned decimal number: "18446744073709428160"
|
|
|
|
zero-padded LDN: "-000123456"
|
|
|
|
left-adjusted ZLDN: "-123456 "
|
|
|
|
space-padded LDN: " -123456"
|
|
|
|
left-adjusted SLDN: "-123456 "
|
|
|
|
zero-padded string: " Hi, Z."
|
|
|
|
left-adjusted Z string: "Hi, Z. "
|
|
|
|
space-padded string: " Hi, Z."
|
|
|
|
left-adjusted S string: "Hi, Z. "
|
|
|
|
null string: "(null)"
|
|
|
|
limited string: "Good morning, Doctor C"
|
2017-10-14 02:44:39 +08:00
|
|
|
a-style max: "0x1.fffffffffffffp+1023"
|
|
|
|
a-style -max: "-0x1.fffffffffffffp+1023"
|
2000-09-15 06:42:29 +08:00
|
|
|
e-style >= 1: "1.234000e+01"
|
|
|
|
e-style >= .1: "1.234000e-01"
|
|
|
|
e-style < .1: "1.234000e-03"
|
|
|
|
e-style big: "1.000000000000000000000000000000000000000000000000000000000000e+20"
|
|
|
|
e-style == .1: "1.000000e-01"
|
|
|
|
f-style >= 1: "12.340000"
|
|
|
|
f-style >= .1: "0.123400"
|
|
|
|
f-style < .1: "0.001234"
|
|
|
|
g-style >= 1: "12.34"
|
|
|
|
g-style >= .1: "0.1234"
|
|
|
|
g-style < .1: "0.001234"
|
|
|
|
g-style big: "100000000000000000000"
|
|
|
|
0.10000
|
|
|
|
0.10000
|
|
|
|
x0.5000x
|
|
|
|
0x1
|
|
|
|
something really insane: 1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
5.87747175411143754e-39
|
|
|
|
4.94066e-324
|
|
|
|
| 0.0000| 0.0000e+00| 0|
|
|
|
|
| 1.0000| 1.0000e+00| 1|
|
|
|
|
| -1.0000| -1.0000e+00| -1|
|
|
|
|
| 100.0000| 1.0000e+02| 100|
|
|
|
|
| 1000.0000| 1.0000e+03| 1000|
|
|
|
|
| 10000.0000| 1.0000e+04| 1e+04|
|
|
|
|
| 12345.0000| 1.2345e+04| 1.234e+04|
|
|
|
|
| 100000.0000| 1.0000e+05| 1e+05|
|
|
|
|
| 123456.0000| 1.2346e+05| 1.235e+05|
|
|
|
|
snprintf ("%30s", "foo") == 30, " "
|
2002-03-14 07:44:36 +08:00
|
|
|
snprintf ("%.999999u", 10) == 999999
|
2017-10-14 02:44:39 +08:00
|
|
|
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00000000
|
|
|
|
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00000000
|
2000-09-15 06:42:29 +08:00
|
|
|
1.234568e+06 should be 1.234568e+06
|
|
|
|
1234567.800000 should be 1234567.800000
|
|
|
|
1.23457e+06 should be 1.23457e+06
|
|
|
|
123.456 should be 123.456
|
|
|
|
1e+06 should be 1e+06
|
|
|
|
10 should be 10
|
|
|
|
0.02 should be 0.02
|
|
|
|
Test ok.
|
|
|
|
sprintf (buf, "%07Lo", 040000000000ll) = 40000000000
|
2000-09-25 13:12:05 +08:00
|
|
|
printf ("%hhu", 257) = 1
|
|
|
|
printf ("%hu", 65537) = 1
|
2006-05-03 04:28:05 +08:00
|
|
|
printf ("%hhi", 257) = 1
|
|
|
|
printf ("%hi", 65537) = 1
|
|
|
|
printf ("%1$hhu", 257) = 1
|
|
|
|
printf ("%1$hu", 65537) = 1
|
|
|
|
printf ("%1$hhi", 257) = 1
|
|
|
|
printf ("%1$hi", 65537) = 1
|
2000-09-15 06:42:29 +08:00
|
|
|
--- Should be no further output. ---
|
|
|
|
EOF
|
2001-03-04 16:47:11 +08:00
|
|
|
cmp - ${common_objpfx}stdio-common/tst-printf.out > /dev/null 2>&1 ||
|
2000-09-15 06:42:29 +08:00
|
|
|
{
|
|
|
|
status=1
|
|
|
|
echo "*** output comparison failed"
|
|
|
|
}
|
2000-07-08 05:06:48 +08:00
|
|
|
|
|
|
|
exit $status
|