diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 33 | ||||
-rw-r--r-- | test/Makefile.am | 42 | ||||
-rw-r--r-- | test/filefuncs.awk | 25 | ||||
-rw-r--r-- | test/filefuncs.ok | 0 | ||||
-rw-r--r-- | test/fork.awk | 33 | ||||
-rw-r--r-- | test/fork.ok | 0 | ||||
-rw-r--r-- | test/fork2.awk | 35 | ||||
-rw-r--r-- | test/fork2.ok | 0 | ||||
-rw-r--r-- | test/ordchr.awk | 5 | ||||
-rw-r--r-- | test/ordchr.ok | 1 | ||||
-rw-r--r-- | test/ordchr2.ok | 1 |
11 files changed, 171 insertions, 4 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index e926adf1..45920dce 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,36 @@ +2012-04-08 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (VALGRIND): Set to empty to protect against random + values in the environment. + +2012-04-08 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (EXTRA_DIST): Add missing files fork.ok, fork2.ok + and ordchr2.ok. + +2012-04-08 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (AWK, PGAWK): Include new $(VALGRIND) variable in + command line (now passed in by top-level Makefile). + +2012-04-07 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (ordchr2, readfile): Fix so "make diffout" will work + properly. + * orchr2.ok: New file. + +2012-04-07 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (check): Add new shlib-tests target. + (SHLIB_TESTS): Add tests ordchr, ordchr2, fork, fork2, readfile and + filefuncs. + * ordchr.awk, ordchr.ok, fork.awk, fork.ok, fork2.awk, fork2.ok, + filefuncs.awk, filefuncs.ok: New files. + +2012-04-01 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (valgrind-scan): Update to match modern valgrind output. + 2012-05-09 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (jarebug): New test. diff --git a/test/Makefile.am b/test/Makefile.am index 4b0bf819..05b19a7a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -201,6 +201,8 @@ EXTRA_DIST = \ fieldwdth.awk \ fieldwdth.in \ fieldwdth.ok \ + filefuncs.awk \ + filefuncs.ok \ fldchg.awk \ fldchg.in \ fldchg.ok \ @@ -233,6 +235,10 @@ EXTRA_DIST = \ fnparydl.awk \ fnparydl.ok \ fnparydl-mpfr.ok \ + fork.awk \ + fork.ok \ + fork2.awk \ + fork2.ok \ fpat1.awk \ fpat1.in \ fpat1.ok \ @@ -528,6 +534,9 @@ EXTRA_DIST = \ opasnidx.ok \ opasnslf.awk \ opasnslf.ok \ + ordchr.awk \ + ordchr.ok \ + ordchr2.ok \ out1.ok \ out2.ok \ out3.ok \ @@ -864,6 +873,8 @@ LOCALE_CHARSET_TESTS = \ asort asorti fmttest fnarydel fnparydl lc_num1 mbfw1 \ mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc +SHLIB_TESTS = ordchr ordchr2 fork fork2 readfile filefuncs + # List of the tests which should be run with --lint option: NEED_LINT = \ defref fmtspcl lintwarn noeffect nofmtch shadow \ @@ -886,13 +897,17 @@ GENTESTS_UNUSED = Makefile.in gtlnbufv.awk printfloat.awk CMP = cmp AWKPROG = ../gawk$(EXEEXT) +# Default for VALGRIND is empty unless overridden by a command-line argument. +# This protects against cruft in the environment. +VALGRIND = + # This business forces the locale to be C for running the tests, # unless we override it to something else for testing. # # This can also be done in individual tests where we wish to # check things specifically not in the C locale. -AWK = LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} $(AWKPROG) $(AWKFLAGS) +AWK = LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} $(AWKPROG) $(AWKFLAGS) # Message stuff is to make it a little easier to follow. # Make the pass-fail last and dependent on others to avoid @@ -903,7 +918,8 @@ check: msg \ unix-msg-start unix-tests unix-msg-end \ extend-msg-start gawk-extensions extend-msg-end \ machine-msg-start machine-tests machine-msg-end \ - charset-msg-start charset-tests charset-msg-end + charset-msg-start charset-tests charset-msg-end \ + shlib-msg-start shlib-tests shlib-msg-end @$(MAKE) pass-fail basic: $(BASIC_TESTS) @@ -922,6 +938,8 @@ machine-tests: $(MACHINE_TESTS) mpfr-tests: $(MPFR_TESTS) +shlib-tests: $(SHLIB_TESTS) + msg:: @echo '' @echo 'Any output from "cmp" is bad news, although some differences' @@ -962,6 +980,12 @@ charset-msg-start: charset-msg-end: @echo "======== Done with tests that can vary based on character set or locale support ========" +shlib-msg-start: + @echo "======== Starting shared library tests ========" + +shlib-msg-end: + @echo "======== Done with shared library tests ========" + lc_num1: @echo $@ @@ -1512,6 +1536,16 @@ jarebug:: $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ +ordchr2:: + @echo $@ + @$(AWK) -l ordchr 'BEGIN {print chr(ord("z"))}' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +readfile:: + @echo $@ + @$(AWK) -l readfile 'BEGIN {printf "%s", readfile("Makefile")}' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) Makefile _$@ && rm -f _$@ || cp -p Makefile $@.ok + # Targets generated for other tests: include Maketests @@ -1551,8 +1585,8 @@ valgrind-scan: function show() {if (cmd) {printf "%s: %s\n",FILENAME,cmd; cmd = ""}; \ printf "\t%s\n",$$0}; \ {$$1 = ""}; \ - /Prog and args are:/ {incmd = 1; cmd = ""; next}; \ - incmd {if (NF == 1) incmd = 0; else {cmd = (cmd $$0); next}}; \ + $$2 == "Command:" {incmd = 1; $$2 = ""; cmd = $$0; next}; \ + incmd {if (/Parent PID:/) incmd = 0; else {cmd = (cmd $$0); next}}; \ /ERROR SUMMARY:/ && !/: 0 errors from 0 contexts/ {show()}; \ /definitely lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ /possibly lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ diff --git a/test/filefuncs.awk b/test/filefuncs.awk new file mode 100644 index 00000000..aa532741 --- /dev/null +++ b/test/filefuncs.awk @@ -0,0 +1,25 @@ +@load "filefuncs" + +BEGIN { + if (chdir("..") < 0) { + printf "Error: chdir failed with ERRNO %s\n", ERRNO + exit 1 + } + + if (stat(ARGV[0], st) < 0) { + printf "Error: stat(%s) failed with ERRNO %s\n", ARGV[0], ERRNO + exit 1 + } + + nf = split("name dev ino mode nlink uid gid size blocks atime mtime ctime pmode type", f) + + for (i = 1; i <= nf; i++) { + if (!(f[i] in st)) { + printf "stat value for %s is missing\n",f[i] + rc = 1 + } + else + delete st[f[i]] + } + exit rc+0 +} diff --git a/test/filefuncs.ok b/test/filefuncs.ok new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/filefuncs.ok diff --git a/test/fork.awk b/test/fork.awk new file mode 100644 index 00000000..0b29f9ff --- /dev/null +++ b/test/fork.awk @@ -0,0 +1,33 @@ +@load "fork" + +BEGIN { + fn = ("fork.tmp." PROCINFO["pid"]) + switch (pid = fork()) { + case -1: + printf "Error: fork failed with ERRNO %s\n", ERRNO + exit 1 + case 0: + # child + printf "pid %s ppid %s\n", PROCINFO["pid"], PROCINFO["ppid"] > fn + exit 0 + default: + # parent + erc = 1 + if ((rc = wait()) < 0) + printf "Error: wait failed with ERRNO %s\n", ERRNO + else if (rc != pid) + printf "Error: wait returned %s instead of child pid %s\n", rc, pid + else if ((getline x < fn) != 1) + printf "Error: getline failed on temp file %s\n", fn + else { + expected = ("pid " pid " ppid " PROCINFO["pid"]) + if (x != expected) + printf "Error: child data (%s) != expected (%s)\n", x, expected + else if ((rc = system("rm " fn)) != 0) + printf "Error removing temp file %s with ERRNO %s\n", fn, ERRNO + else + erc = 0 + } + exit erc + } +} diff --git a/test/fork.ok b/test/fork.ok new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fork.ok diff --git a/test/fork2.awk b/test/fork2.awk new file mode 100644 index 00000000..bd364286 --- /dev/null +++ b/test/fork2.awk @@ -0,0 +1,35 @@ +@load "fork" + +BEGIN { + # avoid instantiating PROCINFO prior to the fork + switch (pid = fork()) { + case -1: + printf "Error: fork failed with ERRNO %s\n", ERRNO + exit 1 + case 0: + # child + fn = ("fork.tmp." PROCINFO["pid"]) + printf "pid %s ppid %s\n", PROCINFO["pid"], PROCINFO["ppid"] > fn + exit 0 + default: + # parent + erc = 1 + fn = ("fork.tmp." pid) + if ((rc = wait()) < 0) + printf "Error: wait failed with ERRNO %s\n", ERRNO + else if (rc != pid) + printf "Error: wait returned %s instead of child pid %s\n", rc, pid + else if ((getline x < fn) != 1) + printf "Error: getline failed on temp file %s\n", fn + else { + expected = ("pid " pid " ppid " PROCINFO["pid"]) + if (x != expected) + printf "Error: child data (%s) != expected (%s)\n", x, expected + else if ((rc = system("rm " fn)) != 0) + printf "Error removing temp file %s with ERRNO %s\n", fn, ERRNO + else + erc = 0 + } + exit erc + } +} diff --git a/test/fork2.ok b/test/fork2.ok new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fork2.ok diff --git a/test/ordchr.awk b/test/ordchr.awk new file mode 100644 index 00000000..abb793a0 --- /dev/null +++ b/test/ordchr.awk @@ -0,0 +1,5 @@ +@load "ordchr" + +BEGIN { + print chr(ord("A")) +} diff --git a/test/ordchr.ok b/test/ordchr.ok new file mode 100644 index 00000000..f70f10e4 --- /dev/null +++ b/test/ordchr.ok @@ -0,0 +1 @@ +A diff --git a/test/ordchr2.ok b/test/ordchr2.ok new file mode 100644 index 00000000..b6802534 --- /dev/null +++ b/test/ordchr2.ok @@ -0,0 +1 @@ +z |