diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2015-01-05 16:36:17 -0500 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2015-01-05 16:36:17 -0500 |
commit | cb5838c3c261f9a775fae45adfa70e1514e8bfe0 (patch) | |
tree | f34de2778a2b411c532764407fbd9abfea75b8c8 /test/getfile.awk | |
parent | a97507159ee06523c9dd6ec809199a0774976498 (diff) | |
download | egawk-cb5838c3c261f9a775fae45adfa70e1514e8bfe0.tar.gz egawk-cb5838c3c261f9a775fae45adfa70e1514e8bfe0.tar.bz2 egawk-cb5838c3c261f9a775fae45adfa70e1514e8bfe0.zip |
Add test of get_file API.
Diffstat (limited to 'test/getfile.awk')
-rw-r--r-- | test/getfile.awk | 35 |
1 files changed, 35 insertions, 0 deletions
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) +} |