Print this page
12482 Have /usr/bin/awk point to /usr/bin/nawk
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/util-tests/tests/awk/runtests.sh
+++ new/usr/src/test/util-tests/tests/awk/runtests.sh
1 1 #! /usr/bin/ksh93
2 2 #
3 3 #
4 4 # This file and its contents are supplied under the terms of the
|
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
5 5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 6 # You may only use this file in accordance with the terms of version
7 7 # 1.0 of the CDDL.
8 8 #
9 9 # A full copy of the text of the CDDL should have accompanied this
10 10 # source. A copy of the CDDL is also available via the Internet at
11 11 # http://www.illumos.org/license/CDDL.
12 12 #
13 13
14 14 #
15 -# Copyright 2018, Joyent, Inc.
15 +# Copyright 2020 Joyent, Inc.
16 16 #
17 17
18 -AWK=/usr/bin/nawk
18 +AWK=/usr/bin/awk
19 19 WORKDIR=$(mktemp -d /tmp/nawktest.XXXXXX)
20 20
21 21 SUCCESSES=0
22 22 TOTAL=0
23 23
24 24 function proctemplate {
25 25 bash <<-EOF
26 26 IFS= read -rd '' OUTPUT < $1;
27 27 printf "%s" "\${OUTPUT//\\\$AWK/\$AWK}";
28 28 EOF
29 29 }
30 30
31 31 while [[ $# -gt 0 ]]; do
32 32 case $1 in
33 33 -o)
34 34 AWK=$2
35 35 shift 2
36 36 ;;
37 37 *)
38 38 printf 'Usage: runtests.sh [-o <override awk executable>]\n' >&2
39 39 exit 1
40 40 ;;
41 41 esac
42 42 done
43 43
44 44 # Make path absolute so we can change directories.
45 45 AWK=$(cd $(dirname $AWK); pwd)/$(basename $AWK)
46 46 TOP=$(cd $(dirname $0); pwd)
47 47
48 48 # Move into $TOP in case we were run from elsewhere.
49 49 cd $TOP
50 50
51 51 if [[ ! -x $AWK ]]; then
52 52 printf 'awk executable "%s" is not executable\n' "$AWK" >&2
53 53 exit 1
54 54 fi
55 55
56 56 if [[ ! -x /bin/bash ]]; then
57 57 printf 'executable "/bin/bash" not found\n' >&2
58 58 exit 1
59 59 fi
60 60
61 61 if [[ "$(id -u)" == "0" ]]; then
62 62 printf 'runtests.sh should not be run as root\n' >&2
63 63 exit 1
64 64 fi
65 65
66 66
67 67 export AWK
68 68 export WORKDIR
69 69 export UMEM_DEBUG="default"
70 70
71 71 mkdir -p $WORKDIR
72 72
73 73 printf 'Running AWK tests ($AWK="%s")\n' "$AWK"
74 74
75 75 printf '\n# Examples from "The AWK Programming Environment"\n\n'
76 76
77 77 for script in examples/awk/p.*; do
78 78 ((TOTAL+=1))
79 79 printf "$script... "
80 80 if cmp -s <($AWK -f ${script} data/test.countries 2>&1) ${script/awk/out}; then
81 81 printf "ok\n"
82 82 ((SUCCESSES+=1))
83 83 else
84 84 printf "failed\n"
85 85 fi
86 86 done
87 87
88 88 printf '\n# One True AWK Example Programs\n\n'
89 89
90 90 for script in examples/awk/t.*; do
91 91 ((TOTAL+=1))
92 92 printf "$script... "
93 93 if diff <($AWK -f ${script} data/test.data 2>&1) ${script/awk/out}; then
94 94 printf "ok\n"
95 95 ((SUCCESSES+=1))
96 96 else
97 97 printf "failed\n"
98 98 fi
99 99 done
100 100
101 101 cd bugs-fixed || exit 1
102 102 for PROG in *.awk; do
103 103 ((TOTAL+=1))
104 104 export LANG=C
105 105 printf "$PROG... "
106 106 $AWK -f $PROG > $WORKDIR/test.temp.out 2>&1 || \
107 107 echo EXIT CODE: $? >> $WORKDIR/test.temp.out
108 108 if diff $WORKDIR/test.temp.out <(proctemplate ${PROG/.awk/.ok}); then
109 109 printf "ok\n"
110 110 ((SUCCESSES+=1))
111 111 else
112 112 printf "failed\n"
113 113 fi
114 114 done
115 115 cd $TOP
116 116
117 117 # Run the test programs
118 118
119 119 printf '\n# One True AWK Test Programs\n\n'
120 120
121 121 cd tests || exit 1
122 122 for script in ./T.*; do
123 123 ((TOTAL+=1))
124 124 rm -f $WORKDIR/test.temp*
125 125 printf "$script... "
126 126 if $script > /dev/null 2>&1; then
127 127 printf "ok\n"
128 128 ((SUCCESSES+=1))
129 129 else
130 130 printf "failed\n"
131 131 fi
132 132 done
133 133 cd $TOP
134 134
135 135 printf '\n# Imported GAWK Test Programs\n\n'
136 136
137 137 cd gnu || exit 1
138 138 for PROG in *.awk; do
139 139 ((TOTAL+=1))
140 140 export LANG=C
141 141 printf "$PROG... "
142 142 INPUT="${PROG/.awk/.in}"
143 143 if [[ -f $INPUT ]]; then
144 144 $AWK -f $PROG < $INPUT > $WORKDIR/test.temp.out 2>&1 || \
145 145 echo EXIT CODE: $? >> $WORKDIR/test.temp.out
146 146 else
147 147 $AWK -f $PROG > $WORKDIR/test.temp.out 2>&1 || \
148 148 echo EXIT CODE: $? >> $WORKDIR/test.temp.out
149 149 fi
150 150 if diff $WORKDIR/test.temp.out ${PROG/.awk/.ok}; then
151 151 printf "ok\n"
152 152 ((SUCCESSES+=1))
153 153 else
154 154 printf "failed\n"
155 155 fi
156 156 done
157 157
158 158 for script in ./*.sh; do
159 159 ((TOTAL+=1))
160 160 export LANG=C
161 161 printf "$script... "
162 162 $script > $WORKDIR/test.temp.out 2>&1
163 163 if diff $WORKDIR/test.temp.out ${script/.sh/.ok}; then
164 164 printf "ok\n"
165 165 ((SUCCESSES+=1))
166 166 else
167 167 printf "failed\n"
168 168 fi
169 169 done
170 170 cd $TOP
171 171
172 172 printf '\n# Imported GAWK Syntax Tests\n\n'
173 173
174 174 cd syn || exit 1
175 175 for PROG in *.awk; do
176 176 ((TOTAL+=1))
177 177 printf "$PROG... "
178 178 if $AWK -f $PROG /dev/null > /dev/null 2> $WORKDIR/test.temp.out; then
179 179 printf "failed (should exit nonzero)\n"
180 180 continue
181 181 fi
182 182
183 183 if diff $WORKDIR/test.temp.out <(proctemplate ${PROG/.awk/.ok}); then
184 184 printf "ok\n"
185 185 ((SUCCESSES+=1))
186 186 else
187 187 printf "failed\n"
188 188 fi
189 189 done
190 190 cd $TOP
191 191
192 192 printf '\n\nTOTAL: %d/%d\n' "$SUCCESSES" "$TOTAL"
193 193
194 194 rm -rf $WORKDIR
195 195
196 196 if [[ $SUCCESSES != $TOTAL ]]; then
197 197 exit 1
198 198 fi
|
↓ open down ↓ |
170 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX