diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 10 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/close_status.awk | 20 | ||||
-rw-r--r-- | test/close_status.ok | 6 |
6 files changed, 49 insertions, 2 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 0166997c..6d1758b5 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2022-02-10 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (EXTRA_DIST): close_status, new test. + * close_status.awk, close_status.ok: New files. + 2022-02-10 Arnold D. Robbins <arnold@skeeve.com> * nsidentifier.ok: Update after code changes. diff --git a/test/Makefile.am b/test/Makefile.am index f76f5d48..1a22118b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -191,6 +191,8 @@ EXTRA_DIST = \ clos1way6.ok \ closebad.awk \ closebad.ok \ + close_status.awk \ + close_status.ok \ clsflnam.awk \ clsflnam.in \ clsflnam.ok \ @@ -1404,7 +1406,8 @@ BASIC_TESTS = \ aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 aryprm8 aryprm9 \ arysubnm aryunasgn asgext awkpath assignnumfield assignnumfield2 \ back89 backgsub badassign1 badbuild callparam childin clobber \ - closebad clsflnam compare compare2 concat1 concat2 concat3 concat4 \ + closebad close_status clsflnam compare compare2 concat1 concat2 \ + concat3 concat4 \ concat5 convfmt datanonl defref delargv delarpm2 delarprm delfunc \ dfacheck2 dfamb1 dfastress dynlj escapebrace eofsplit eofsrc1 \ exit2 exitval1 exitval2 exitval3 fcall_exit fcall_exit2 fldchg \ diff --git a/test/Makefile.in b/test/Makefile.in index f0e2894a..be8e0345 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -457,6 +457,8 @@ EXTRA_DIST = \ clos1way6.ok \ closebad.awk \ closebad.ok \ + close_status.awk \ + close_status.ok \ clsflnam.awk \ clsflnam.in \ clsflnam.ok \ @@ -1670,7 +1672,8 @@ BASIC_TESTS = \ aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 aryprm8 aryprm9 \ arysubnm aryunasgn asgext awkpath assignnumfield assignnumfield2 \ back89 backgsub badassign1 badbuild callparam childin clobber \ - closebad clsflnam compare compare2 concat1 concat2 concat3 concat4 \ + closebad close_status clsflnam compare compare2 concat1 concat2 \ + concat3 concat4 \ concat5 convfmt datanonl defref delargv delarpm2 delarprm delfunc \ dfacheck2 dfamb1 dfastress dynlj escapebrace eofsplit eofsrc1 \ exit2 exitval1 exitval2 exitval3 fcall_exit fcall_exit2 fldchg \ @@ -3137,6 +3140,11 @@ closebad: @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +close_status: + @echo $@ + @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + clsflnam: @echo $@ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 923e1f78..10ef252f 100644 --- a/test/Maketests +++ b/test/Maketests @@ -185,6 +185,11 @@ closebad: @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +close_status: + @echo $@ + @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + clsflnam: @echo $@ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/close_status.awk b/test/close_status.awk new file mode 100644 index 00000000..12b48d63 --- /dev/null +++ b/test/close_status.awk @@ -0,0 +1,20 @@ +BEGIN { + exit9 = "echo red; exit 9" + while ((exit9 | getline x) > 0) + print x + printf "close(%s) returned %s\n", exit9, close(exit9) + + # run it again, but don't reap the exit status + while ((exit9 | getline x) > 0) + print x + + exit0 = "echo blue; exit 0" + while ((exit0 | getline x) > 0) + print x + # reap status out of order + printf "close(%s) returned %s\n", exit0, close(exit0) + + # check that we got the correct status from the previously + # exited process + printf "close(%s) returned %s\n", exit9, close(exit9) +} diff --git a/test/close_status.ok b/test/close_status.ok new file mode 100644 index 00000000..fbdebeb0 --- /dev/null +++ b/test/close_status.ok @@ -0,0 +1,6 @@ +red +close(echo red; exit 9) returned 9 +red +blue +close(echo blue; exit 0) returned 0 +close(echo red; exit 9) returned 9 |