diff options
author | rillig <rillig@pkgsrc.org> | 2005-11-19 21:59:51 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2005-11-19 21:59:51 +0000 |
commit | 5a1ed277475ae5328d22bf420cbeeb1c506e2526 (patch) | |
tree | de82552cdbe19f2525205a69594f1d699f9ea7a1 /regress | |
parent | 4504993e927a92e3b832b80bf882feeb74496e2c (diff) | |
download | pkgsrc-5a1ed277475ae5328d22bf420cbeeb1c506e2526.tar.gz |
Make sure that awk can handle strings of length 4096 on the command line
and of length 2^20 when copying from stdin to stdout.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/tools/files/awk-test.sh | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/regress/tools/files/awk-test.sh b/regress/tools/files/awk-test.sh index e8a83f4b627..8a04a39435c 100644 --- a/regress/tools/files/awk-test.sh +++ b/regress/tools/files/awk-test.sh @@ -1,26 +1,57 @@ #! /bin/sh -# $NetBSD: awk-test.sh,v 1.2 2005/11/19 21:31:10 rillig Exp $ +# $NetBSD: awk-test.sh,v 1.3 2005/11/19 21:59:51 rillig Exp $ # set -e -# usage: assert_equal <expected> <got> +# usage: assert_equal <testname> <expected> <got> assert_equal() { - case $1 in - "$2") ;; - *) echo "[assert_equal] expected \"$1\", got \"$2\"." 1>&2 - exit 1;; + case $2 in + "$3") ;; + *) echo "[assert_equal:$1] expected \"$2\", got \"$3\"." 1>&2 + return 1;; esac } -# usage: test_assignment <input> <expected-output> +# usage: test_assignment <testname> <input> <expected-output> test_assignment() { - o=`echo "" | awk '{print var}' var="$1"` - assert_equal "$2" "${o}" + o=`echo "" | awk '{print var}' var="$2"` + assert_equal "$1" "$3" "${o}" } -test_assignment "foo" "foo" -test_assignment "foo bar baz" "foo bar baz" -# The Solaris /usr/bin/awk does not conform to the POSIX specification, -# but passes the right hand side of the assignment uninterpreted. -test_assignment "CPPFLAGS=\\\"-Dfoo=bar\\\"" "CPPFLAGS=\"-Dfoo=bar\"" +# usage: test_passline <testname> <input> +test_passline() { + o=`awk '{print}' <<EOF +$2 +EOF +` + assert_equal "$1" "$2" "${o}" +} + +# +# Assignment of variables from the command line. The Solaris +# /usr/bin/awk does not conform to the POSIX specification, but passes +# the right hand side of the assignment uninterpreted. It fails the +# cmd.3 test case. The "for" loop makes sure that awk can handle strings +# of 4096 bytes length. +# +test_assignment "cmd.1" \ + "foo" "foo" +test_assignment "cmd.2" \ + "foo bar baz" "foo bar baz" +test_assignment "cmd.3" \ + "CPPFLAGS=\\\"-Dfoo=bar\\\"" "CPPFLAGS=\"-Dfoo=bar\"" +line="a" +for i in 0 1 2 3 4 5 6 7 8 9 10 11 12; do + test_assignment "cmd.2^${i}" "${line}" "${line}" +done + +# +# Passing strings from stdin to stdout. awk should be able to handle at +# least 2^20 characters per line. +# +line="a" +for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do + test_passline "line.2^${i}" "${line}" + line="${line}${line}" +done |