diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-03-31 22:35:15 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-03-31 22:35:15 +0300 |
commit | bbeeb351c73fb1ee4ff20c3774e0477e9e8a7513 (patch) | |
tree | 95f926cd9bf02578e9c860726a56441ac00e95b2 /test | |
parent | eb53fb0398911202d4361b869eefa6c1449ebec8 (diff) | |
parent | 902b25a40d5cc612dd7a0becb27a5a48afa49716 (diff) | |
download | egawk-bbeeb351c73fb1ee4ff20c3774e0477e9e8a7513.tar.gz egawk-bbeeb351c73fb1ee4ff20c3774e0477e9e8a7513.tar.bz2 egawk-bbeeb351c73fb1ee4ff20c3774e0477e9e8a7513.zip |
Merge branch 'master' into feature/regex-type
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 54 | ||||
-rw-r--r-- | test/Makefile.am | 32 | ||||
-rw-r--r-- | test/Makefile.in | 47 | ||||
-rw-r--r-- | test/Maketests | 15 | ||||
-rw-r--r-- | test/errno.awk | 10 | ||||
-rw-r--r-- | test/errno.in | 3 | ||||
-rw-r--r-- | test/errno.ok | 3 | ||||
-rw-r--r-- | test/exitval3.awk | 2 | ||||
-rw-r--r-- | test/exitval3.ok | 1 | ||||
-rw-r--r-- | test/getfile.awk | 35 | ||||
-rw-r--r-- | test/getfile.ok | 17 | ||||
-rw-r--r-- | test/id.ok | 1 | ||||
-rw-r--r-- | test/indirectbuiltin.awk | 371 | ||||
-rw-r--r-- | test/indirectbuiltin.ok | 43 | ||||
-rw-r--r-- | test/testext.ok | 12 | ||||
-rw-r--r-- | test/timeout.awk | 26 | ||||
-rw-r--r-- | test/timeout.ok | 12 |
17 files changed, 674 insertions, 10 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 5c74f3a4..02752ace 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,25 @@ +2015-03-31 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (indirectbuiltin): New test. + * indirectbuiltin.awk, indirectbuiltin.ok: New files. + +2015-03-27 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am: Remove defvar test and reference to files; test + code moved into extension/testext.c. + * defvar.awk, defvar.ok: Removed. + * testext.ok: Updated. + +2015-03-24 Arnold D. Robbins <arnold@skeeve.com> + + * id.ok: Update after fixes in code. + +2015-03-24 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (EXTRA_DIST): Add exitval3.awk and exitval3.ok. + (BASIC_TESTS): Add new test exitval3. + * exitval3.awk, exitval3.ok: New files. + 2015-03-17 Andrew J. Schorr <aschorr@telemetry-investments.com> * inplace1.ok, inplace2.ok, inplace3.ok: Update error message line @@ -113,6 +135,34 @@ * testext.ok: Adjust for code changes. +2015-01-06 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (EXTRA_DIST): Add defvar.awk and defvar.ok. + (SHLIB_TESTS): Add defvar. + (defvar): New test. + * defvar.awk, defvar.ok: New files. + +2015-01-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (EXTRA_DIST): Add getfile.awk and getfile.ok. + (SHLIB_TESTS): Add getfile. + (getfile): New test. + * getfile.awk, getfile.ok: New files. + +2015-01-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (EXTRA_DIST): Add timeout.awk and timeout.ok. + (BASIC_TESTS): Remove errno. + (GAWK_EXT_TESTS): Add errno and timeout. + * timeout.awk, timeout.ok: New files. + +2015-01-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (EXTRA_DIST): Add errno.awk, errno.in, and errno.ok. + (BASIC_TESTS): Add errno. + (errno): New test. + * errno.awk, errno.in, errno.ok: New files. + 2014-12-24 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (badbuild): New test. @@ -147,6 +197,10 @@ * mbprintf4.awk: Add record and line number for debugging. * mpprint4.ok: Adjust. +2014-11-06 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * testext.ok: Add results from new test_get_file test. + 2014-11-02 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (profile7): New test. diff --git a/test/Makefile.am b/test/Makefile.am index d2cd0ddd..b45eaf95 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -212,6 +212,9 @@ EXTRA_DIST = \ dynlj.ok \ eofsplit.awk \ eofsplit.ok \ + errno.awk \ + errno.in \ + errno.ok \ exit.ok \ exit.sh \ exit2.awk \ @@ -221,6 +224,8 @@ EXTRA_DIST = \ exitval2.awk \ exitval2.ok \ exitval2.w32 \ + exitval3.awk \ + exitval3.ok \ fcall_exit.awk \ fcall_exit.ok \ fcall_exit2.awk \ @@ -340,6 +345,8 @@ EXTRA_DIST = \ gensub.ok \ gensub2.awk \ gensub2.ok \ + getfile.awk \ + getfile.ok \ getline.awk \ getline.in \ getline.ok \ @@ -429,6 +436,8 @@ EXTRA_DIST = \ include.awk \ include.ok \ include2.ok \ + indirectbuiltin.awk \ + indirectbuiltin.ok \ indirectcall.awk \ indirectcall.in \ indirectcall.ok \ @@ -948,6 +957,8 @@ EXTRA_DIST = \ testext.ok \ time.awk \ time.ok \ + timeout.awk \ + timeout.ok \ tradanch.awk \ tradanch.in \ tradanch.ok \ @@ -1011,7 +1022,7 @@ BASIC_TESTS = \ callparam childin clobber closebad clsflnam compare compare2 concat1 concat2 \ concat3 concat4 convfmt \ datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \ - eofsplit exit2 exitval1 exitval2 \ + eofsplit exit2 exitval1 exitval2 exitval3 \ fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \ fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \ fstabplus funsemnl funsmnam funstack \ @@ -1047,13 +1058,13 @@ UNIX_TESTS = \ GAWK_EXT_TESTS = \ aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ backw badargs beginfile1 beginfile2 binmode1 charasbytes \ - colonwarn clos1way crlf dbugeval delsub devfd devfd1 devfd2 dumpvars exit \ + colonwarn clos1way crlf dbugeval delsub devfd devfd1 devfd2 dumpvars errno exit \ fieldwdth fpat1 fpat2 fpat3 fpat4 fpatnull fsfwfs funlen \ functab1 functab2 functab3 fwtest fwtest2 fwtest3 \ genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ icasefs icasers id igncdym igncfs ignrcas2 ignrcase \ incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \ - include include2 indirectcall indirectcall2 \ + include include2 indirectbuiltin indirectcall indirectcall2 \ lint lintold lintwarn \ manyfiles match1 match2 match3 mbstr1 \ nastyparm next nondec nondec2 \ @@ -1065,7 +1076,8 @@ GAWK_EXT_TESTS = \ rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ - symtab7 symtab8 symtab9 + symtab7 symtab8 symtab9 \ + timeout EXTRA_TESTS = inftest regtest @@ -1082,7 +1094,7 @@ LOCALE_CHARSET_TESTS = \ mbprintf1 mbprintf2 mbprintf3 mbprintf4 rebt8b2 rtlenmb sort1 sprintfc SHLIB_TESTS = \ - fnmatch filefuncs fork fork2 fts functab4 inplace1 inplace2 inplace3 \ + fnmatch filefuncs fork fork2 fts functab4 getfile inplace1 inplace2 inplace3 \ ordchr ordchr2 readdir readfile readfile2 revout revtwoway rwarray testext time # List of the tests which should be run with --lint option: @@ -1341,6 +1353,11 @@ devfd:: @$(AWK) 1 /dev/fd/4 /dev/fd/5 4<"$(srcdir)"/devfd.in4 5<"$(srcdir)"/devfd.in5 >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +errno: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + fflush:: @echo $@ @"$(srcdir)"/fflush.sh >_$@ @@ -1934,6 +1951,11 @@ testext:: @$(AWK) -f ./testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ testext.awk +getfile: + @echo $@ + @$(AWK) -v TESTEXT_QUIET=1 -ltestext -f $(srcdir)/$@.awk $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + readdir: @if [ "`uname`" = Linux ] && [ "`stat -f . 2>/dev/null | awk 'NR == 2 { print $$NF }'`" = nfs ]; then \ echo This test may fail on GNU/Linux systems when run on an NFS filesystem.; \ diff --git a/test/Makefile.in b/test/Makefile.in index cf8093b8..8053df5c 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -469,6 +469,9 @@ EXTRA_DIST = \ dynlj.ok \ eofsplit.awk \ eofsplit.ok \ + errno.awk \ + errno.in \ + errno.ok \ exit.ok \ exit.sh \ exit2.awk \ @@ -478,6 +481,8 @@ EXTRA_DIST = \ exitval2.awk \ exitval2.ok \ exitval2.w32 \ + exitval3.awk \ + exitval3.ok \ fcall_exit.awk \ fcall_exit.ok \ fcall_exit2.awk \ @@ -597,6 +602,8 @@ EXTRA_DIST = \ gensub.ok \ gensub2.awk \ gensub2.ok \ + getfile.awk \ + getfile.ok \ getline.awk \ getline.in \ getline.ok \ @@ -686,6 +693,8 @@ EXTRA_DIST = \ include.awk \ include.ok \ include2.ok \ + indirectbuiltin.awk \ + indirectbuiltin.ok \ indirectcall.awk \ indirectcall.in \ indirectcall.ok \ @@ -1205,6 +1214,8 @@ EXTRA_DIST = \ testext.ok \ time.awk \ time.ok \ + timeout.awk \ + timeout.ok \ tradanch.awk \ tradanch.in \ tradanch.ok \ @@ -1267,7 +1278,7 @@ BASIC_TESTS = \ callparam childin clobber closebad clsflnam compare compare2 concat1 concat2 \ concat3 concat4 convfmt \ datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \ - eofsplit exit2 exitval1 exitval2 \ + eofsplit exit2 exitval1 exitval2 exitval3 \ fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \ fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \ fstabplus funsemnl funsmnam funstack \ @@ -1303,13 +1314,13 @@ UNIX_TESTS = \ GAWK_EXT_TESTS = \ aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ backw badargs beginfile1 beginfile2 binmode1 charasbytes \ - colonwarn clos1way crlf dbugeval delsub devfd devfd1 devfd2 dumpvars exit \ + colonwarn clos1way crlf dbugeval delsub devfd devfd1 devfd2 dumpvars errno exit \ fieldwdth fpat1 fpat2 fpat3 fpat4 fpatnull fsfwfs funlen \ functab1 functab2 functab3 fwtest fwtest2 fwtest3 \ genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ icasefs icasers id igncdym igncfs ignrcas2 ignrcase \ incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \ - include include2 indirectcall indirectcall2 \ + include include2 indirectbuiltin indirectcall indirectcall2 \ lint lintold lintwarn \ manyfiles match1 match2 match3 mbstr1 \ nastyparm next nondec nondec2 \ @@ -1321,7 +1332,8 @@ GAWK_EXT_TESTS = \ rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ - symtab7 symtab8 symtab9 + symtab7 symtab8 symtab9 \ + timeout EXTRA_TESTS = inftest regtest INET_TESTS = inetdayu inetdayt inetechu inetecht @@ -1335,7 +1347,7 @@ LOCALE_CHARSET_TESTS = \ mbprintf1 mbprintf2 mbprintf3 mbprintf4 rebt8b2 rtlenmb sort1 sprintfc SHLIB_TESTS = \ - fnmatch filefuncs fork fork2 fts functab4 inplace1 inplace2 inplace3 \ + fnmatch filefuncs fork fork2 fts functab4 getfile inplace1 inplace2 inplace3 \ ordchr ordchr2 readdir readfile readfile2 revout revtwoway rwarray testext time @@ -1779,6 +1791,11 @@ devfd:: @$(AWK) 1 /dev/fd/4 /dev/fd/5 4<"$(srcdir)"/devfd.in4 5<"$(srcdir)"/devfd.in5 >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +errno: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + fflush:: @echo $@ @"$(srcdir)"/fflush.sh >_$@ @@ -2371,6 +2388,11 @@ testext:: @$(AWK) -f ./testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ testext.awk +getfile: + @echo $@ + @$(AWK) -v TESTEXT_QUIET=1 -ltestext -f $(srcdir)/$@.awk $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + readdir: @if [ "`uname`" = Linux ] && [ "`stat -f . 2>/dev/null | awk 'NR == 2 { print $$NF }'`" = nfs ]; then \ echo This test may fail on GNU/Linux systems when run on an NFS filesystem.; \ @@ -2730,6 +2752,11 @@ exitval2: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +exitval3: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + fcall_exit: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @@ -3607,6 +3634,11 @@ include: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +indirectbuiltin: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + indirectcall: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @@ -3797,6 +3829,11 @@ symtab7: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +timeout: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + double1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 5011fb1f..219d592d 100644 --- a/test/Maketests +++ b/test/Maketests @@ -230,6 +230,11 @@ exitval2: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +exitval3: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + fcall_exit: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @@ -1107,6 +1112,11 @@ include: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +indirectbuiltin: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + indirectcall: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @@ -1297,6 +1307,11 @@ symtab7: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +timeout: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + double1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/errno.awk b/test/errno.awk new file mode 100644 index 00000000..bcb77614 --- /dev/null +++ b/test/errno.awk @@ -0,0 +1,10 @@ +BEGIN { + # check that PROCINFO["errno"] is working properly + getline + if (close(FILENAME)) { + print "Error `" ERRNO "' closing input file" + print "errno =", PROCINFO["errno"] + } + getline < (FILENAME "/bogus") + print (PROCINFO["errno"] > 0), ERRNO +} diff --git a/test/errno.in b/test/errno.in new file mode 100644 index 00000000..a92d664b --- /dev/null +++ b/test/errno.in @@ -0,0 +1,3 @@ +line 1 +line 2 +line 3 diff --git a/test/errno.ok b/test/errno.ok new file mode 100644 index 00000000..181afdaf --- /dev/null +++ b/test/errno.ok @@ -0,0 +1,3 @@ +Error `close of redirection that was never opened' closing input file +errno = 0 +1 Not a directory diff --git a/test/exitval3.awk b/test/exitval3.awk new file mode 100644 index 00000000..33e8c433 --- /dev/null +++ b/test/exitval3.awk @@ -0,0 +1,2 @@ +BEGIN { exit 42 } +END { exit } diff --git a/test/exitval3.ok b/test/exitval3.ok new file mode 100644 index 00000000..20f64b8c --- /dev/null +++ b/test/exitval3.ok @@ -0,0 +1 @@ +EXIT CODE: 42 diff --git a/test/getfile.awk b/test/getfile.awk new file mode 100644 index 00000000..6ee783f6 --- /dev/null +++ b/test/getfile.awk @@ -0,0 +1,35 @@ +function basename(x) { + return gensub(/^.*\//, "", 1, x) +} + +BEGIN { + print "BEGIN" + + cmd = "echo hello; echo goodbye" + rc = get_file(cmd, "<<", -1, res) + print "expected error result", rc, ERRNO + print "get_file returned", get_file(cmd, "|<", -1, res) + print "input_name", basename(res["input_name"]) + print (cmd | getline x) + print x + + # check that calling get_file on "" triggers the BEGINFILE rule + print "get_file returned", get_file("", "", -1, res) + print "input_name", basename(res["input_name"]) + print "end BEGIN" +} + +BEGINFILE { + printf "BEGINFILE (%s) ERRNO (%s)\n", basename(FILENAME), ERRNO +} + +ENDFILE { + printf "ENDFILE (%s) ERRNO (%s)\n", basename(FILENAME), ERRNO +} + +END { + print "END" + print (cmd | getline x) + print x + print close(cmd) +} diff --git a/test/getfile.ok b/test/getfile.ok new file mode 100644 index 00000000..92c915f2 --- /dev/null +++ b/test/getfile.ok @@ -0,0 +1,17 @@ +BEGIN +gawk: ./getfile.awk:9: warning: cannot open unrecognized file type `<<' for `echo hello; echo goodbye' +get_file: get_file(echo hello; echo goodbye, <<, -1) failed +expected error result 0 +get_file returned 1 +input_name echo hello; echo goodbye +1 +hello +BEGINFILE (getfile.awk) ERRNO () +get_file returned 1 +input_name getfile.awk +end BEGIN +ENDFILE (getfile.awk) ERRNO () +END +1 +goodbye +0 @@ -14,6 +14,7 @@ sprintf -> builtin ROUNDMODE -> scalar strftime -> builtin systime -> builtin +length -> builtin and -> builtin srand -> builtin FNR -> scalar diff --git a/test/indirectbuiltin.awk b/test/indirectbuiltin.awk new file mode 100644 index 00000000..4d5291d2 --- /dev/null +++ b/test/indirectbuiltin.awk @@ -0,0 +1,371 @@ +function print_result(category, fname, builtin_result, indirect_result) +{ + if (builtin_result == indirect_result) + printf("%s: %s: pass\n", category, fname) + else { + printf("%s: %s: fail: builtin: %s \tindirect: %s\n", category, fname, + builtin_result, indirect_result) + exit 1 + } +} + + +BEGIN { +# math functions + + fun = "and" + b1 = and(0x11, 0x01) + i1 = @fun(0x11, 0x01) + print_result("math", fun, b1, i1) + + fun = "atan2" + b1 = atan2(-1, 0) + i1 = @fun(-1, 0) + print_result("math", fun, b1, i1) + + fun = "compl" + b1 = compl(0x1111) + i1 = @fun(0x1111) + print_result("math", fun, b1, i1) + + fun = "cos" + b1 = cos(3.1415927 / 4) + i1 = @fun(3.1415927 / 4) + print_result("math", fun, b1, i1) + + fun = "exp" + b1 = exp(2) + i1 = @fun(2) + print_result("math", fun, b1, i1) + + fun = "int" + b1 = int(3.1415927) + i1 = @fun(3.1415927) + print_result("math", fun, b1, i1) + + fun = "log" + b1 = log(10) + i1 = @fun(10) + print_result("math", fun, b1, i1) + + fun = "lshift" + b1 = lshift(1, 2) + i1 = @fun(1, 2) + print_result("math", fun, b1, i1) + + fun = "or" + b1 = or(0x10, 0x01) + i1 = @fun(0x10, 0x01) + print_result("math", fun, b1, i1) + + fun = "rand" + srand(1) + b1 = rand(); + srand(1) + i1 = @fun() + print_result("math", fun, b1, i1) + + fun = "rshift" + b1 = rshift(0x10, 1) + i1 = @fun(0x10, 1) + print_result("math", fun, b1, i1) + + fun = "sin" + b1 = sin(3.1415927 / 4) + i1 = @fun(3.1415927 / 4) + print_result("math", fun, b1, i1) + + fun = "sqrt" + b1 = sqrt(2) + i1 = @fun(2) + print_result("math", fun, b1, i1) + + srand() + fun = "srand" + b1 = srand() + i1 = @fun() + print_result("math", fun, b1, i1) + + fun = "xor" + b1 = xor(0x11, 0x01) + i1 = @fun(0x11, 0x01) + print_result("math", fun, b1, i1) + +# string functions + + fun = "gensub" + b1 = gensub("f", "q", "g", "ff11bb") + i1 = @fun("f", "q", "g", "ff11bb") + print_result("string", fun, b1, i1) + + fun = "gsub" + $0 = "ff11bb" + b1 = gsub("f", "q") + b2 = $0 + $0 = "ff11bb" + i1 = @fun("f", "q") + i2 = $0 + print_result("string", fun, b1, i1) + if (b2 != i2) { + printf("string: %s: fail: $0 (%s) != $0 (%s)\n", + fun, b2, i2) + exit 1 + } + + fun = "index" + b1 = index("hi, how are you", "how") + i1 = @fun("hi, how are you", "how") + print_result("string", fun, b1, i1) + + fun = "dcgettext" + b1 = dcgettext("hello, world") + i1 = @fun("hello, world") + print_result("string", fun, b1, i1) + + fun = "dcngettext" + b1 = dcngettext("hello, world", "howdy", 2) + i1 = @fun("hello, world", "howdy", 2) + print_result("string", fun, b1, i1) + + fun = "length" + b1 = length("hi, how are you") + i1 = @fun("hi, how are you") + print_result("string", fun, b1, i1) + + fun = "sprintf" + b1 = sprintf("%s world", "hello") + i1 = @fun("%s world", "hello") + print_result("string", fun, b1, i1) + + fun = "strtonum" + b1 = strtonum("0xdeadbeef") + i1 = @fun("0xdeadbeef") + print_result("string", fun, b1, i1) + + fun = "sub" + $0 = "ff11bb" + b1 = sub("f", "q") + b2 = $0 + $0 = "ff11bb" + i1 = @fun("f", "q") + i2 = $0 + print_result("string", fun, b1, i1) + if (b2 != i2) { + printf("string: %s: fail: $0 (%s) != $0 (%s)\n", + fun, b2, i2) + exit 1 + } + + fun = "substr" + b1 = substr("0xdeadbeef", 7, 4) + i1 = @fun("0xdeadbeef", 7, 4) + print_result("string", fun, b1, i1) + + fun = "tolower" + b1 = tolower("0xDeAdBeEf") + i1 = @fun("0xDeAdBeEf") + print_result("string", fun, b1, i1) + + fun = "toupper" + b1 = toupper("0xDeAdBeEf") + i1 = @fun("0xDeAdBeEf") + print_result("string", fun, b1, i1) + +# time functions + + fun = "mktime" + b1 = mktime("1990 02 11 12 00 00") + i1 = @fun("1990 02 11 12 00 00") + print_result("time", fun, b1, i1) + + then = b1 + fun = "strftime" + b1 = strftime(PROCINFO["strftime"], then) + i1 = @fun(PROCINFO["strftime"], then) + print_result("time", fun, b1, i1) + + fun = "systime" + b1 = systime() + i1 = @fun() + print_result("time", fun, b1, i1) + +# regexp functions + + fun = "match" + b1 = match("o+", "fooob") + rstart = RSTART + rlength = RLENGTH + i1 = @fun("o+", "fooob") + print_result("regexp", fun, b1, i1) + if (rstart != RSTART) { + printf("match: failure: biRSTART (%d) != iRSTART (%d)\n", + rstart, RSTART) + exit 1 + } + if (rlength != RLENGTH) { + printf("match: failure: biRLENGTH (%d) != iRLENGTH (%d)\n", + rlength, RLENGTH) + exit 1 + } + + ############## start patsplit ############## + fun = "patsplit" + delete data + delete data2 + delete seps + delete seps2 + b1 = patsplit("a:b:c:d", data, ":", seps) + i1 = @fun("a:b:c:d", data2, ":", seps2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + for (i in seps) { + if ((! (i in seps2)) || seps[i] != seps2[i]) { + printf("patsplit1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", + i, seps[i], i, seps2[i]) + exit 1 + } + } + + fun = "patsplit" + delete data + delete data2 + b1 = patsplit("a:b:c:d", data, ":") + i1 = @fun("a:b:c:d", data2, ":") + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + + fun = "patsplit" + delete data + delete data2 + FPAT = "[a-z]+" + b1 = patsplit("a b c d", data) + i1 = @fun("a b c d", data2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + ############## end patsplit ############## + + ############## start split ############## + fun = "split" + delete data + delete data2 + delete seps + delete seps2 + b1 = split("a:b:c:d", data, ":", seps) + i1 = @fun("a:b:c:d", data2, ":", seps2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + for (i in seps) { + if ((! (i in seps2)) || seps[i] != seps2[i]) { + printf("split1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", + i, seps[i], i, seps2[i]) + exit 1 + } + } + + fun = "split" + delete data + delete data2 + b1 = split("a:b:c:d", data, ":") + i1 = @fun("a:b:c:d", data2, ":") + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + + fun = "split" + delete data + delete data2 + b1 = split("a b c d", data) + i1 = @fun("a b c d", data2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + ############## end split ############## + +# array functions + + split("z y x w v u t", data) + fun = "asort" + asort(data, newdata) + @fun(data, newdata2) + print_result("array", fun, b1, i1) + for (i in newdata) { + if (! (i in newdata2) || newdata[i] != newdata2[i]) { + print fun ": failed, index", i + exit + } + } + + for (i in data) + data2[data[i]] = i + + fun = "asorti" + asorti(data2, newdata) + @fun(data2, newdata2) + print_result("array", fun, b1, i1) + for (i in newdata) { + if (! (i in newdata2) || newdata[i] != newdata2[i]) { + print fun ": failed, index", i, "value", newdata[i], newdata2[i] + exit + } + } + + arr[1] = arr[2] = 42 + fun = "isarray" + b1 = isarray(arr) + i1 = @fun(arr) + print_result("array", fun, b1, i1) + +# i/o functions + + print("hi") > "x1.out" + print("hi") > "x2.out" + + fun = "fflush" + b1 = fflush("x1.out") + i1 = @fun("x2.out") + print_result("i/o", fun, b1, i1) + + fun = "close" + b1 = close("x1.out") + i1 = @fun("x2.out") + print_result("i/o", fun, b1, i1) + + fun = "system" + b1 = system("rm x1.out") + i1 = @fun("rm x2.out") + print_result("i/o", fun, b1, i1) +} diff --git a/test/indirectbuiltin.ok b/test/indirectbuiltin.ok new file mode 100644 index 00000000..312bbd76 --- /dev/null +++ b/test/indirectbuiltin.ok @@ -0,0 +1,43 @@ +math: and: pass +math: atan2: pass +math: compl: pass +math: cos: pass +math: exp: pass +math: int: pass +math: log: pass +math: lshift: pass +math: or: pass +math: rand: pass +math: rshift: pass +math: sin: pass +math: sqrt: pass +math: srand: pass +math: xor: pass +string: gensub: pass +string: gsub: pass +string: index: pass +string: dcgettext: pass +string: dcngettext: pass +string: length: pass +string: sprintf: pass +string: strtonum: pass +string: sub: pass +string: substr: pass +string: tolower: pass +string: toupper: pass +time: mktime: pass +time: strftime: pass +time: systime: pass +regexp: match: pass +regexp: patsplit: pass +regexp: patsplit: pass +regexp: patsplit: pass +regexp: split: pass +regexp: split: pass +regexp: split: pass +array: asort: pass +array: asorti: pass +array: isarray: pass +i/o: fflush: pass +i/o: close: pass +i/o: system: pass diff --git a/test/testext.ok b/test/testext.ok index a828ecb2..897a7336 100644 --- a/test/testext.ok +++ b/test/testext.ok @@ -23,6 +23,12 @@ var_test() returned 1, test_var = 42 test_errno() returned 1, ERRNO = No child processes +fubar = 9 +rumpus = -5 +uid matches 1 +api_major matches 1 +test_deferred returns 1 + length of test_array is 10, should be 10 test_array_size: incoming size is 10 test_array_size() returned 1, length is now 0 @@ -69,6 +75,12 @@ test_scalar_reserved: could not update new_value2 for ARGC - pass test_indirect_var: sym_lookup of NR passed test_indirect_var: value of NR is 3 test_indirect_var() return 1 + +test_get_file returned 0 +File [.test.alias] nr [1]: line 1 +File [.test.alias] nr [2]: line 2 +File [.test.alias] nr [3]: line 3 + answer_num = 42 message_string = hello, world new_array["hello"] = "world" diff --git a/test/timeout.awk b/test/timeout.awk new file mode 100644 index 00000000..ccf4537d --- /dev/null +++ b/test/timeout.awk @@ -0,0 +1,26 @@ +BEGIN { + cmd = "echo hello; sleep 1; echo goodbye" + + print "With timeouts" + PROCINFO[cmd, "READ_TIMEOUT"] = 300 + while ((rc = (cmd | getline x)) > 0) + print x + if (rc < 0) + print rc, (PROCINFO["errno"] != 0), (ERRNO != "") + print (close(cmd) != 0) + + PROCINFO[cmd, "RETRY"] + print "" + print "With timeouts and retries" + while (((rc = (cmd | getline x)) > 0) || (rc == -2)) { + if (rc > 0) { + print x + n = 0 + } + else + print ++n, "timed out; trying again" + } + if (rc < 0) + print rc, (PROCINFO["errno"] != 0), (ERRNO != "") + print (close(cmd) != 0) +} diff --git a/test/timeout.ok b/test/timeout.ok new file mode 100644 index 00000000..a388747b --- /dev/null +++ b/test/timeout.ok @@ -0,0 +1,12 @@ +With timeouts +hello +-1 1 1 +1 + +With timeouts and retries +hello +1 timed out; trying again +2 timed out; trying again +3 timed out; trying again +goodbye +0 |