aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog43
-rw-r--r--test/Makefile.am33
-rw-r--r--test/Makefile.in39
-rw-r--r--test/Maketests5
-rw-r--r--test/mpfrnegzero.awk15
-rw-r--r--test/mpfrnegzero.ok9
-rw-r--r--test/readdir0.awk25
-rw-r--r--test/split_after_fpat.awk11
-rw-r--r--test/split_after_fpat.in1
-rw-r--r--test/split_after_fpat.ok4
-rw-r--r--test/strftime.awk42
11 files changed, 180 insertions, 47 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 29dff6c3..65409956 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,46 @@
+2014-02-03 Stepan Kasal <kasal@ucw.cz>
+
+ * strftime.awk: the default format uses %e, not %d (Introduced on
+ 2014-01-16; the previous code mangled the output of command "date"
+ to match %d.) Remove the "mucking" for cygwin, it's obsolete and
+ incompatible with %e.
+
+2014-01-28 Eli Zaretskii <eliz@gnu.org>
+
+ * strftime.awk: If DATECMD variable is non-empty, use it instead
+ of the literal "date" as the 'date'-like command.
+
+2014-01-19 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (mpfrnegzero): New test.
+ * mpfrnegzero.awk, mpfrnegzero.ok: New files.
+
+2014-01-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (readdir): Run ls commands outside the awk script.
+ * readdir0.awk: Read ls results from files. Helps with MinGW.
+ Thanks to Eli Zaretskii for the problem report.
+
+2014-01-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am: Quote instances of $(top_srcdir) also.
+
+2014-01-16 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * Makefile.am (strftime): Remove comment about the race condition, since
+ this should be fixed. And gawk now calls date inside the script.
+ * strftime.awk: Based on an idea from Pat Rankin, fix the race
+ condition by looping repeatedly over strftime/date/strftime until
+ the before and after strftime results match. That should fix
+ the race condition where the seconds field might increment between
+ invocations.
+
+2014-01-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (split_after_fpat): New test.
+ * split_after_fpat.awk, split_after_fpat.ok,
+ split_after_fpat.in: New files.
+
2013-12-30 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (ignrcas2): Change to use en_US.UTF-8; it
diff --git a/test/Makefile.am b/test/Makefile.am
index 9c00062d..97848a00 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,7 +1,7 @@
#
# test/Makefile.am --- automake input file for gawk
#
-# Copyright (C) 1988-2012 the Free Software Foundation, Inc.
+# Copyright (C) 1988-2014 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -522,6 +522,8 @@ EXTRA_DIST = \
mpfrexprange.ok \
mpfrieee.awk \
mpfrieee.ok \
+ mpfrnegzero.awk \
+ mpfrnegzero.ok \
mpfrnr.awk \
mpfrnr.in \
mpfrnr.ok \
@@ -808,6 +810,9 @@ EXTRA_DIST = \
sortu.awk \
sortu.ok \
space.ok \
+ split_after_fpat.awk \
+ split_after_fpat.in \
+ split_after_fpat.ok \
splitarg4.awk \
splitarg4.in \
splitarg4.ok \
@@ -995,7 +1000,8 @@ GAWK_EXT_TESTS = \
patsplit posix printfbad1 printfbad2 printfbad3 procinfs \
profile1 profile2 profile3 profile4 profile5 pty1 \
rebuf regx8bit reginttrad reint reint2 rsstart1 \
- rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \
+ rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \
+ splitarg4 strftime \
strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \
symtab7 symtab8 symtab9
@@ -1005,7 +1011,8 @@ INET_TESTS = inetdayu inetdayt inetechu inetecht
MACHINE_TESTS = double1 double2 fmtspcl intformat
-MPFR_TESTS = mpfrnr mpfrrnd mpfrieee mpfrexprange mpfrsort mpfrbigint
+MPFR_TESTS = mpfrnr mpfrnegzero mpfrrnd mpfrieee mpfrexprange \
+ mpfrsort mpfrbigint
LOCALE_CHARSET_TESTS = \
asort asorti backbigs1 backsmalls1 backsmalls2 \
@@ -1250,12 +1257,10 @@ nonl::
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
strftime::
- @echo This test could fail on slow machines or on a minute boundary,
- @echo so if it does, double check the actual results:
@echo $@
@GAWKLOCALE=C; export GAWKLOCALE; \
TZ=GMT0; export TZ; \
- (LC_ALL=C date) | $(AWK) -v OUTPUT=_$@ -f "$(srcdir)"/strftime.awk
+ $(AWK) -v OUTPUT=_$@ -f "$(srcdir)"/strftime.awk
@-$(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0
litoct::
@@ -1695,6 +1700,11 @@ mpfrrnd:
@$(AWK) -M -vPREC=53 -f "$(srcdir)"/$@.awk > _$@ 2>&1
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+mpfrnegzero:
+ @echo $@
+ @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
mpfrnr:
@echo $@
@$(AWK) -M -vPREC=113 -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in > _$@
@@ -1800,7 +1810,7 @@ inplace3::
testext::
@echo $@
- @$(AWK) '/^(@load|BEGIN)/,/^}/' $(top_srcdir)/extension/testext.c > testext.awk
+ @$(AWK) '/^(@load|BEGIN)/,/^}/' "$(top_srcdir)"/extension/testext.c > testext.awk
@$(AWK) -f testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ testext.awk
@@ -1810,9 +1820,12 @@ readdir:
echo If it does, try rerunning on an ext'[234]' filesystem. ; \
fi
@echo $@
- @$(AWK) -f "$(srcdir)"/readdir.awk $(top_srcdir) > _$@
- @ls -afli $(top_srcdir) | sed 1d | $(AWK) -f "$(srcdir)"/readdir0.awk -v extout=_$@ $(top_srcdir) > $@.ok
- @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+ @$(AWK) -f "$(srcdir)"/readdir.awk "$(top_srcdir)" > _$@
+ @ls -afi "$(top_srcdir)" > _dirlist
+ @ls -lna "$(top_srcdir)" | sed 1d > _longlist
+ @$(AWK) -f "$(srcdir)"/readdir0.awk -v extout=_$@ \
+ -v dirlist=_dirlist -v longlist=_longlist > $@.ok
+ @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@ _dirlist _longlist
fts:
@case `uname` in \
diff --git a/test/Makefile.in b/test/Makefile.in
index d1cdb26a..468c19c5 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -17,7 +17,7 @@
#
# test/Makefile.am --- automake input file for gawk
#
-# Copyright (C) 1988-2012 the Free Software Foundation, Inc.
+# Copyright (C) 1988-2014 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -768,6 +768,8 @@ EXTRA_DIST = \
mpfrexprange.ok \
mpfrieee.awk \
mpfrieee.ok \
+ mpfrnegzero.awk \
+ mpfrnegzero.ok \
mpfrnr.awk \
mpfrnr.in \
mpfrnr.ok \
@@ -1054,6 +1056,9 @@ EXTRA_DIST = \
sortu.awk \
sortu.ok \
space.ok \
+ split_after_fpat.awk \
+ split_after_fpat.in \
+ split_after_fpat.ok \
splitarg4.awk \
splitarg4.in \
splitarg4.ok \
@@ -1240,14 +1245,17 @@ GAWK_EXT_TESTS = \
patsplit posix printfbad1 printfbad2 printfbad3 procinfs \
profile1 profile2 profile3 profile4 profile5 pty1 \
rebuf regx8bit reginttrad reint reint2 rsstart1 \
- rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \
+ rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \
+ splitarg4 strftime \
strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \
symtab7 symtab8 symtab9
EXTRA_TESTS = inftest regtest
INET_TESTS = inetdayu inetdayt inetechu inetecht
MACHINE_TESTS = double1 double2 fmtspcl intformat
-MPFR_TESTS = mpfrnr mpfrrnd mpfrieee mpfrexprange mpfrsort mpfrbigint
+MPFR_TESTS = mpfrnr mpfrnegzero mpfrrnd mpfrieee mpfrexprange \
+ mpfrsort mpfrbigint
+
LOCALE_CHARSET_TESTS = \
asort asorti backbigs1 backsmalls1 backsmalls2 \
fmttest fnarydel fnparydl jarebug lc_num1 mbfw1 \
@@ -1674,12 +1682,10 @@ nonl::
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
strftime::
- @echo This test could fail on slow machines or on a minute boundary,
- @echo so if it does, double check the actual results:
@echo $@
@GAWKLOCALE=C; export GAWKLOCALE; \
TZ=GMT0; export TZ; \
- (LC_ALL=C date) | $(AWK) -v OUTPUT=_$@ -f "$(srcdir)"/strftime.awk
+ $(AWK) -v OUTPUT=_$@ -f "$(srcdir)"/strftime.awk
@-$(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0
litoct::
@@ -2118,6 +2124,11 @@ mpfrrnd:
@$(AWK) -M -vPREC=53 -f "$(srcdir)"/$@.awk > _$@ 2>&1
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+mpfrnegzero:
+ @echo $@
+ @$(AWK) -M -f "$(srcdir)"/$@.awk > _$@ 2>&1
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
mpfrnr:
@echo $@
@$(AWK) -M -vPREC=113 -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in > _$@
@@ -2223,7 +2234,7 @@ inplace3::
testext::
@echo $@
- @$(AWK) '/^(@load|BEGIN)/,/^}/' $(top_srcdir)/extension/testext.c > testext.awk
+ @$(AWK) '/^(@load|BEGIN)/,/^}/' "$(top_srcdir)"/extension/testext.c > testext.awk
@$(AWK) -f testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ testext.awk
@@ -2233,9 +2244,12 @@ readdir:
echo If it does, try rerunning on an ext'[234]' filesystem. ; \
fi
@echo $@
- @$(AWK) -f "$(srcdir)"/readdir.awk $(top_srcdir) > _$@
- @ls -afli $(top_srcdir) | sed 1d | $(AWK) -f "$(srcdir)"/readdir0.awk -v extout=_$@ $(top_srcdir) > $@.ok
- @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+ @$(AWK) -f "$(srcdir)"/readdir.awk "$(top_srcdir)" > _$@
+ @ls -afi "$(top_srcdir)" > _dirlist
+ @ls -lna "$(top_srcdir)" | sed 1d > _longlist
+ @$(AWK) -f "$(srcdir)"/readdir0.awk -v extout=_$@ \
+ -v dirlist=_dirlist -v longlist=_longlist > $@.ok
+ @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@ _dirlist _longlist
fts:
@case `uname` in \
@@ -3504,6 +3518,11 @@ sortu:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+split_after_fpat:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
splitarg4:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index df272ce8..b9b713c4 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1182,6 +1182,11 @@ sortu:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+split_after_fpat:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
splitarg4:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/mpfrnegzero.awk b/test/mpfrnegzero.awk
new file mode 100644
index 00000000..cc6bf65b
--- /dev/null
+++ b/test/mpfrnegzero.awk
@@ -0,0 +1,15 @@
+BEGIN {
+ printf("-0 -> %f, -0.0 -> %f\n", -0, -0.0)
+
+ printf("atan2(+0, -0) = %f\n", atan2(+0, -0))
+ printf("atan2(+0.0, -0.0) = %f\n", atan2(+0.0, -0.0))
+
+ printf("atan2(-0, -0) = %f\n", atan2(-0, -0))
+ printf("atan2(-0.0, -0.0) = %f\n", atan2(-0.0, -0.0))
+
+ printf("atan2(+0, +0) = %f\n", atan2(+0, +0))
+ printf("atan2(+0.0, +0.0) = %f\n", atan2(+0.0, +0.0))
+
+ printf("atan2(-0, +0) = %f\n", atan2(-0, +0))
+ printf("atan2(-0.0, +0.0) = %f\n", atan2(-0.0, +0.0))
+}
diff --git a/test/mpfrnegzero.ok b/test/mpfrnegzero.ok
new file mode 100644
index 00000000..7af16292
--- /dev/null
+++ b/test/mpfrnegzero.ok
@@ -0,0 +1,9 @@
+-0 -> -0.000000, -0.0 -> -0.000000
+atan2(+0, -0) = 3.141593
+atan2(+0.0, -0.0) = 3.141593
+atan2(-0, -0) = -3.141593
+atan2(-0.0, -0.0) = -3.141593
+atan2(+0, +0) = 0.000000
+atan2(+0.0, +0.0) = 0.000000
+atan2(-0, +0) = -0.000000
+atan2(-0.0, +0.0) = -0.000000
diff --git a/test/readdir0.awk b/test/readdir0.awk
index 296c03c7..2b7674a4 100644
--- a/test/readdir0.awk
+++ b/test/readdir0.awk
@@ -1,4 +1,9 @@
+# NOTE: This program is not a generalized parser for the output of 'ls'.
+# It's job is to read the output of ls from the gawk source code directory,
+# where we know there are no symbolic links, nor are there files with
+# spaces in their file names, etc.
BEGIN {
+ # analyze results from readdir extension
while ((getline x < extout) > 0) {
numrec++
if ((split(x, f, "/") == 3) && (f[3] == "u"))
@@ -12,12 +17,7 @@ BEGIN {
}
BEGIN {
- dir = ARGV[1]
- delete ARGV[1]
- ls_afi = "ls -afi " dir
- ls_al = ("ls -lna " dir " | sed 1d")
-
- for (i = 1; (ls_afi | getline) > 0; i++) {
+ for (i = 1; (getline < dirlist) > 0; i++) {
# inode number is $1, filename is read of record
inode = $1
$1 = ""
@@ -26,21 +26,18 @@ BEGIN {
names[i] = $0
ino[names[i]] = inode
}
- close(ls_afi)
+ close(dirlist)
- for (j = 1; (ls_al | getline) > 0; j++) {
+ for (j = 1; (getline < longlist) > 0; j++) {
type_let = substr($0, 1, 1)
if (type_let == "-")
type_let = "f"
- $1 = $2 = $3 = $4 = $5 = $6 = $7 = $8 = ""
- $0 = $0
- sub(/^ */, "")
- type[$0] = type_let
+ type[$NF] = type_let
}
- close(ls_al)
+ close(longlist)
if (i != j)
- printf("mismatch: %d from `ls -afi' and %d from `ls -l'\n", i, j) > "/dev/stderr"
+ printf("mismatch: %d from `ls -afi' and %d from `ls -lna'\n", i, j) > "/dev/stderr"
for (i = 1; i in names; i++)
printf("%s/%s/%s\n", ino[names[i]], names[i], (ftype_unknown ? "u" : type[names[i]]))
diff --git a/test/split_after_fpat.awk b/test/split_after_fpat.awk
new file mode 100644
index 00000000..7e7cfd99
--- /dev/null
+++ b/test/split_after_fpat.awk
@@ -0,0 +1,11 @@
+BEGIN { FPAT = "\"[^\"]*\"" }
+
+{ print $1 }
+
+END { f("hi there") }
+
+function f (p, a, n, i)
+{
+ n = split(p,a)
+ print n ; for (i=1; i<=n; i++) print a[i]
+}
diff --git a/test/split_after_fpat.in b/test/split_after_fpat.in
new file mode 100644
index 00000000..1aeefd59
--- /dev/null
+++ b/test/split_after_fpat.in
@@ -0,0 +1 @@
+a"stuff"b
diff --git a/test/split_after_fpat.ok b/test/split_after_fpat.ok
new file mode 100644
index 00000000..5c284490
--- /dev/null
+++ b/test/split_after_fpat.ok
@@ -0,0 +1,4 @@
+"stuff"
+2
+hi
+there
diff --git a/test/strftime.awk b/test/strftime.awk
index 775cd4e5..f1276c15 100644
--- a/test/strftime.awk
+++ b/test/strftime.awk
@@ -1,19 +1,35 @@
# strftime.awk ; test the strftime code
#
# input is the output of `date', see Makefile.in
-#
-# The mucking about with $0 and $N is to avoid problems
-# on cygwin, where the timezone field is empty and there
-# are two consecutive blanks.
-# Additional mucking about to lop off the seconds field;
-# helps decrease chance of difference due to a second boundary
+BEGIN {
+ maxtries = 10
+ # On DOS/Windows, DATECMD is set by the Makefile to point to
+ # Unix-like 'date' command.
+ datecmd = DATECMD
+ if (datecmd == "")
+ datecmd = "date"
+ fmt = "%a %b %e %H:%M:%S %Z %Y"
-{
- $3 = sprintf("%02d", $3 + 0)
- $4 = substr($4, 1, 5)
- print > "strftime.ok"
- $0 = strftime("%a %b %d %H:%M %Z %Y")
- $NF = $NF
- print > OUTPUT
+ # loop until before equals after, thereby protecting
+ # against a race condition where the seconds field might have
+ # incremented between running date and strftime
+ i = 0
+ while (1) {
+ if (++i > maxtries) {
+ printf "Warning: this system is so slow that after %d attempts, we could never get two sequential invocations of strftime to give the same result!\n", maxtries > "/dev/stderr"
+ break
+ }
+ before = strftime(fmt)
+ datecmd | getline sd
+ after = strftime(fmt)
+ close(datecmd)
+ if (before == after) {
+ if (i > 1)
+ printf "Notice: it took %d loops to get the before and after strftime values to match\n", i > "/dev/stderr"
+ break
+ }
+ }
+ print sd > "strftime.ok"
+ print after > OUTPUT
}