pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/regress/tools/files Make sure that awk can handle stri...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/7fe7a3dcc40e
branches:  trunk
changeset: 503403:7fe7a3dcc40e
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Nov 19 21:59:51 2005 +0000

description:
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:

 regress/tools/files/awk-test.sh |  59 +++++++++++++++++++++++++++++++---------
 1 files changed, 45 insertions(+), 14 deletions(-)

diffs (75 lines):

diff -r 9d731fbefb8c -r 7fe7a3dcc40e regress/tools/files/awk-test.sh
--- a/regress/tools/files/awk-test.sh   Sat Nov 19 21:31:10 2005 +0000
+++ b/regress/tools/files/awk-test.sh   Sat Nov 19 21:59:51 2005 +0000
@@ -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}"
+}
+
+# usage: test_passline <testname> <input>
+test_passline() {
+       o=`awk '{print}' <<EOF
+$2
+EOF
+`
+       assert_equal "$1" "$2" "${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\""
+#
+# 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



Home | Main Index | Thread Index | Old Index