Remove building with NOCRYPTO option
[minix.git] / tests / usr.bin / awk / t_awk.sh
blob77cb5f86df01affcea8ece126014d0418a4e7f39
1 # $NetBSD: t_awk.sh,v 1.5 2012/12/10 20:30:06 christos Exp $
3 # Copyright (c) 2012 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # This code is derived from software contributed to The NetBSD Foundation
7 # by Christos Zoulas
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
31 awk=awk
33 h_check()
35 local fname=d_$1
36 for sfx in in out awk; do
37 cp -r $(atf_get_srcdir)/$fname.$sfx .
38 done
39 shift 1
40 atf_check -o file:$fname.out -x "awk $@ -f $fname.awk < $fname.in"
43 atf_test_case big_regexp
45 big_regexp_head() {
46 atf_set "descr" "Checks matching long regular expressions (PR/33392)"
49 big_regexp_body() {
50 h_check big_regexp
53 atf_test_case end
55 end_head() {
56 atf_set "descr" "Checks that the last line of the input" \
57 "is available under END pattern (PR/29659)"
60 end_body() {
61 h_check end1
62 h_check end2
65 atf_test_case string1
67 string1_head() {
68 atf_set "descr" "Checks escaping newlines in string literals"
71 string1_body() {
72 for sfx in out awk; do
73 cp -r $(atf_get_srcdir)/d_string1.$sfx .
74 done
75 atf_check -o file:d_string1.out awk -f d_string1.awk
78 atf_test_case multibyte
80 multibyte_head() {
81 atf_set "descr" "Checks multibyte charsets support" \
82 "in tolower and toupper (PR/36394)"
85 multibyte_body() {
86 export LANG=en_US.UTF-8
88 h_check tolower
89 h_check toupper
92 atf_test_case period
94 period_head() {
95 atf_set "descr" "Checks that the period character is recognised" \
96 "in awk program regardless of locale (bin/42320)"
99 period_body() {
100 export LANG=ru_RU.KOI8-R
102 h_check period -v x=0.5
105 atf_test_case assign_NF
107 assign_NF_head() {
108 atf_set "descr" 'Checks that assign to NF changes $0 and $n (PR/44063)'
111 assign_NF_body() {
112 h_check assign_NF
115 atf_test_case single_char_rs
117 single_char_rs_head() {
118 atf_set "descr" "Test awk(1) with single character RS"
121 single_char_rs_body() {
122 atf_check \
123 -o "inline:1\n2\n\n3\n\n\n4\n\n" \
124 -x "echo 1a2aa3aaa4 | $awk 1 RS=a"
127 atf_test_case two_char_rs
129 two_char_rs_head() {
130 atf_set "descr" "Test awk(1) with two characters RS"
133 two_char_rs_body() {
134 atf_check \
135 -o "inline:1\n2\n3\n4\n\n" \
136 -x "echo 1ab2ab3ab4 | $awk 1 RS=ab"
139 atf_test_case single_char_regex_group_rs
141 single_char_regex_group_rs_head() {
142 atf_set "descr" "Test awk(1) with single character regex group RS"
145 single_char_regex_group_rs_body() {
146 atf_check \
147 -o "inline:1\n2\n\n3\n\n\n4\n\n" \
148 -x "echo 1a2aa3aaa4 | $awk 1 RS='[a]'"
151 atf_test_case two_char_regex_group_rs
153 two_char_regex_group_rs_head() {
154 atf_set "descr" "Test awk(1) with two characters regex group RS"
157 two_char_regex_group_rs_body() {
158 atf_check \
159 -o "inline:1\n2\n\n3\n\n\n4\n\n" \
160 -x "echo 1a2ab3aba4 | $awk 1 RS='[ab]'"
163 atf_test_case single_char_regex_star_rs
165 single_char_regex_star_rs_head() {
166 atf_set "descr" "Test awk(1) with single character regex star RS"
169 single_char_regex_star_rs_body() {
170 atf_check \
171 -o "inline:1\n2\n3\n4\n\n" \
172 -x "echo 1a2aa3aaa4 | $awk 1 RS='a*'"
175 atf_test_case two_char_regex_star_rs
177 two_char_regex_star_rs_head() {
178 atf_set "descr" "Test awk(1) with two characters regex star RS"
181 two_char_regex_star_rs_body() {
182 atf_check \
183 -o "inline:1\n2\n3\n4\n\n" \
184 -x "echo 1a2aa3aaa4 | $awk 1 RS='aa*'"
187 atf_test_case regex_two_star_rs
189 regex_two_star_rs_head() {
190 atf_set "descr" "Test awk(1) with regex two star RS"
193 regex_two_star_rs_body() {
194 atf_check \
195 -o "inline:1\n2\n3\n4\n\n" \
196 -x "echo 1a2ab3aab4 | $awk 1 RS='aa*b*'"
199 atf_test_case regex_or_1_rs
201 regex_or_1_rs_head() {
202 atf_set "descr" "Test awk(1) with regex | case 1 RS"
205 regex_or_1_rs_body() {
206 atf_check \
207 -o "inline:1a\nc\n\n" \
208 -x "echo 1abc | $awk 1 RS='abcde|b'"
211 atf_test_case regex_or_2_rs
213 regex_or_2_rs_head() {
214 atf_set "descr" "Test awk(1) with regex | case 2 RS"
217 regex_or_2_rs_body() {
218 atf_check \
219 -o "inline:1a\ncdf2\n\n" \
220 -x "echo 1abcdf2 | $awk 1 RS='abcde|b'"
223 atf_test_case regex_or_3_rs
225 regex_or_3_rs_head() {
226 atf_set "descr" "Test awk(1) with regex | case 3 RS"
229 regex_or_3_rs_body() {
230 atf_check \
231 -o "inline:1\n\nf2\n\n" \
232 -x "echo 1abcdebf2 | $awk 1 RS='abcde|b'"
235 atf_test_case regex_or_4_rs
237 regex_or_4_rs_head() {
238 atf_set "descr" "Test awk(1) with regex | case 4 RS"
241 regex_or_4_rs_body() {
242 atf_check \
243 -o "inline:1\nbcdf2\n\n" \
244 -x "echo 1abcdf2 | $awk 1 RS='abcde|a'"
248 atf_test_case regex_caret_1_rs
250 regex_caret_1_rs_head() {
251 atf_set "descr" "Test awk(1) with regex ^ case 1 RS"
254 regex_caret_1_rs_body() {
255 atf_check \
256 -o "inline:\n1a2a3a\n\n" \
257 -x "echo a1a2a3a | $awk 1 RS='^a'"
261 atf_test_case regex_caret_2_rs
263 regex_caret_2_rs_head() {
264 atf_set "descr" "Test awk(1) with regex ^ case 2 RS"
267 regex_caret_2_rs_body() {
268 atf_check \
269 -o "inline:\naa1a2a\n\n" \
270 -x "echo aaa1a2a | $awk 1 RS='^a'"
274 atf_test_case regex_dollar_1_rs
276 regex_dollar_1_rs_head() {
277 atf_set "descr" "Test awk(1) with regex $ case 1 RS"
280 regex_dollar_1_rs_body() {
281 atf_check \
282 -o "inline:a1a2a3a\n\n" \
283 -x "echo a1a2a3a | $awk 1 RS='a$'"
287 atf_test_case regex_dollar_2_rs
289 regex_dollar_2_rs_head() {
290 atf_set "descr" "Test awk(1) with regex $ case 2 RS"
293 regex_dollar_2_rs_body() {
294 atf_check \
295 -o "inline:a1a2aaa\n\n" \
296 -x "echo a1a2aaa | $awk 1 RS='a$'"
300 atf_test_case regex_reallocation_rs
302 regex_reallocation_rs_head() {
303 atf_set "descr" "Test awk(1) with regex reallocation RS"
306 regex_reallocation_rs_body() {
307 atf_check \
308 -o "inline:a\na\na\na\na\na\na\na\na\na10000\n\n" \
309 -x "jot -s a 10000 | $awk 'NR>1' RS='999[0-9]'"
313 atf_test_case empty_rs
315 empty_rs_head() {
316 atf_set "descr" "Test awk(1) with empty RS"
319 empty_rs_body() {
320 atf_check \
321 -o "inline:foo\n" \
322 -x "echo foo | $awk 1 RS=''"
326 atf_test_case newline_rs
328 newline_rs_head() {
329 atf_set "descr" "Test awk(1) with newline RS"
332 newline_rs_body() {
333 atf_check \
334 -o "inline:r1f1:r1f2\nr2f1:r2f2\n" \
335 -x "printf '\n\n\nr1f1\nr1f2\n\nr2f1\nr2f2\n\n\n' | $awk '{\$1=\$1}1' RS= OFS=:"
338 atf_test_case modify_subsep
340 modify_subsep_head() {
341 atf_set "descr" "Test awk(1) SUPSEP modification (PR/47306)"
344 modify_subsep_body() {
345 atf_check \
346 -o "inline:1\n1\n1\n" \
347 -x "printf '1\n1 2\n' | \
348 $awk '1{ arr[\$1 SUBSEP \$2 SUBSEP ++cnt[\$1]]=1} {for (f in arr) print arr[f];}'"
351 atf_init_test_cases() {
353 atf_add_test_case big_regexp
354 atf_add_test_case end
355 atf_add_test_case string1
356 atf_add_test_case multibyte
357 atf_add_test_case period
358 atf_add_test_case assign_NF
360 atf_add_test_case single_char_rs
361 atf_add_test_case two_char_rs
362 atf_add_test_case single_char_regex_group_rs
363 atf_add_test_case two_char_regex_group_rs
364 atf_add_test_case two_char_regex_star_rs
365 atf_add_test_case single_char_regex_star_rs
366 atf_add_test_case regex_two_star_rs
367 atf_add_test_case regex_or_1_rs
368 atf_add_test_case regex_or_2_rs
369 atf_add_test_case regex_or_3_rs
370 atf_add_test_case regex_caret_1_rs
371 atf_add_test_case regex_caret_2_rs
372 atf_add_test_case regex_dollar_1_rs
373 atf_add_test_case regex_dollar_2_rs
374 atf_add_test_case regex_reallocation_rs
375 atf_add_test_case empty_rs
376 atf_add_test_case newline_rs
377 atf_add_test_case modify_subsep