]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/netbsd-tests/usr.bin/sort/t_sort.sh
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / netbsd-tests / usr.bin / sort / t_sort.sh
1 # $NetBSD: t_sort.sh,v 1.1 2012/03/17 16:33:15 jruoho Exp $
2 #
3 # Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 #    notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 #    notice, this list of conditions and the following disclaimer in the
13 #    documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
26 #
27
28 atf_test_case basic
29 basic_head()
30 {
31         atf_set "descr" "Basic functionality test"
32 }
33 basic_body()
34 {
35         cat >in <<EOF
36 z b m f
37 y c o e
38 x a n h
39 x a n g
40 EOF
41
42         cat >expout <<EOF
43 x a n g
44 x a n h
45 y c o e
46 z b m f
47 EOF
48
49         atf_check -o file:expout sort in
50 }
51
52 atf_test_case empty_file
53 empty_file_head()
54 {
55         atf_set "descr" "Tests sorting an empty file"
56 }
57 empty_file_body()
58 {
59         touch empty
60         atf_check -o empty sort -S empty
61         atf_check sort -S -c empty
62         atf_check sort -S -c -u empty
63 }
64
65 atf_test_case end_of_options
66 end_of_options_head()
67 {
68         atf_set "descr" "Determination of end of option list"
69 }
70 end_of_options_body()
71 {
72         echo x >-k
73         atf_check -o file:-k -x "sort -S -- -k </dev/null"
74         atf_check -s not-exit:1 -e ignore -x "sort -S - -c </dev/null"
75 }
76
77 atf_test_case missing_newline
78 missing_newline_head()
79 {
80         atf_set "descr" "Tests with missing new line in input file"
81 }
82 missing_newline_body()
83 {
84         printf '%s' x >in
85         atf_check -o inline:'x\n' sort in
86 }
87
88 atf_test_case null_bytes
89 null_bytes_head()
90 {
91         atf_set "descr" "Tests the behavior of null bytes"
92 }
93 null_bytes_body()
94 {
95         printf '\0b\n\0a\n' >in
96         atf_check -o inline:'\0a\n\0b\n' sort -S in
97 }
98
99 atf_test_case long_records
100 long_records_head()
101 {
102         atf_set "descr" "Tests long lines and keys"
103 }
104 long_records_body()
105 {
106         awk 'BEGIN {    x="x"
107         for(i=1; i<=12; i++) x = x x
108         for(i=15; i<=25; i++) print x i
109 }' >in
110
111         awk 'BEGIN {    x="x"
112         for(i=1; i<=12; i++) x = x x
113         for(i=25; i>=15; i--) print x i
114 }' >out
115
116         atf_check -o file:out sort -r in
117         atf_check -o file:out sort -k 1,1r -k 1 in
118 }
119
120 atf_test_case long_file
121 long_file_head()
122 {
123         atf_set "descr" "Tests with a long file to try to force intermediate" \
124             "files"
125 }
126 long_file_body()
127 {
128         awk 'BEGIN { for(i=0; i<20000; i++) print rand() }' >in
129         sort -S -r in | awk '$0 "x" != x { print ; x = $0 "x" }' >out
130         atf_check -o file:out sort -u -r in
131 }
132
133 atf_test_case any_char
134 any_char_head()
135 {
136         atf_set "descr" "Tests with files containing non-printable/extended" \
137             "characters"
138 }
139 any_char_body()
140 {
141         atf_check -o file:$(atf_get_srcdir)/d_any_char_dflag_out.txt \
142             sort -d -k 2 $(atf_get_srcdir)/d_any_char_in.txt
143
144         atf_check -o file:$(atf_get_srcdir)/d_any_char_fflag_out.txt \
145             sort -f -k 2 $(atf_get_srcdir)/d_any_char_in.txt
146
147         atf_check -o file:$(atf_get_srcdir)/d_any_char_iflag_out.txt \
148             sort -i -k 2 $(atf_get_srcdir)/d_any_char_in.txt
149 }
150
151 atf_test_case bflag
152 bflag_head()
153 {
154         atf_set "descr" "Tests the -b flag"
155 }
156 bflag_body()
157 {
158         cat >in <<EOF
159   b
160  a
161 EOF
162
163         atf_check -o file:in sort -b in
164         atf_check -o file:in -x "sort -b <in"
165         atf_check -s exit:1 -o ignore -e ignore -x "sort in | sort -c -r"
166 }
167
168 atf_test_case cflag
169 cflag_head()
170 {
171         atf_set "descr" "Tests the -c flag"
172 }
173 cflag_body()
174 {
175         cat >in <<EOF
176 b
177 a
178 EOF
179
180         atf_check -s exit:1 -e ignore sort -S -c in
181 }
182
183 atf_test_case kflag_one_field
184 kflag_one_field_head()
185 {
186         atf_set "descr" "Tests the -k flag with one field"
187 }
188 kflag_one_field_body()
189 {
190         cat >in <<EOF
191 z b m f
192 y c o e
193 x a n h
194 x a n g
195 EOF
196
197         cat >expout <<EOF
198 x a n g
199 x a n h
200 z b m f
201 y c o e
202 EOF
203
204         atf_check -o file:expout sort -k2.1 in
205 }
206
207 atf_test_case kflag_two_fields
208 kflag_two_fields_head()
209 {
210         atf_set "descr" "Tests the -k flag with two fields"
211 }
212 kflag_two_fields_body()
213 {
214         cat >in <<EOF
215 z b m f
216 y c o e
217 x a n h
218 x a n g
219 EOF
220
221         cat >expout <<EOF
222 x a n h
223 x a n g
224 z b m f
225 y c o e
226 EOF
227         atf_check -o file:expout sort -k2.1,2.0 in
228 }
229
230 atf_test_case kflag_many_fields
231 kflag_many_fields_head()
232 {
233         atf_set "descr" "Tests the -k flag with many fields"
234 }
235 kflag_many_fields_body()
236 {
237         cat >in <<EOF
238 0:2:3:4:5:6:7:8:9
239 1:1:3:4:5:6:7:8:9
240 1:2:2:4:5:6:7:8:9
241 1:2:3:3:5:6:7:8:9
242 1:2:3:4:4:6:7:8:9
243 1:2:3:4:5:5:7:8:9
244 1:2:3:4:5:6:6:8:9
245 1:2:3:4:5:6:7:7:9
246 1:2:3:4:5:6:7:8:8
247 EOF
248
249         cat >out <<EOF
250 1:2:3:4:5:6:7:8:8
251 1:2:3:4:5:6:7:7:9
252 1:2:3:4:5:6:6:8:9
253 1:2:3:4:5:5:7:8:9
254 1:2:3:4:4:6:7:8:9
255 1:2:3:3:5:6:7:8:9
256 1:2:2:4:5:6:7:8:9
257 1:1:3:4:5:6:7:8:9
258 0:2:3:4:5:6:7:8:9
259 EOF
260
261         atf_check -o file:out sort -t: -k9 -k8 -k7 -k6 -k5 -k4 -k3 \
262             -k2 -k1 in
263 }
264
265 atf_test_case kflag_outofbounds
266 kflag_outofbounds_head()
267 {
268         atf_set "descr" "Tests the -k flag with out of bounds fields"
269 }
270 kflag_outofbounds_body()
271 {
272         cat >in <<EOF
273 0 5
274 1 4
275 2 3
276 3 2
277 4 1
278 5 0
279 EOF
280
281         atf_check -o file:in sort -k2.2,2.1 -k2.3,2.4 in
282 }
283
284 atf_test_case kflag_nonmonotone
285 kflag_nonmonotone_head()
286 {
287         atf_set "descr" "Tests the -k flag with apparently nonmonotone" \
288             "field specs"
289 }
290 kflag_nonmonotone_body()
291 {
292         cat >in <<EOF
293 aaaa c
294 x a
295 0 b
296 EOF
297
298         atf_check -o file:in sort -k2,1.3 -k2.5,2.5 in
299 }
300
301 atf_test_case kflag_limits
302 kflag_limits_head()
303 {
304         atf_set "descr" "Tests the -k flag field limits"
305 }
306 kflag_limits_body()
307 {
308         cat >in <<EOF
309 a       2
310 a       1
311 b       2
312 b       1
313 EOF
314
315         cat >out <<EOF
316 b       2
317 b       1
318 a       2
319 a       1
320 EOF
321
322         atf_check -o file:out sort -r -k1,1 -k2n in
323 }
324
325 atf_test_case kflag_alpha
326 kflag_alpha_head()
327 {
328         atf_set "descr" "Tests the -k flag with various alpha fields"
329 }
330 kflag_alpha_body()
331 {
332         sort >in <<EOF
333 01:04:19:01:16:01:21:01 a
334 02:03:13:15:13:19:15:02  a
335 03:02:07:09:07:13:09:03   a
336 04:01:01:03:01:07:03:04    a
337 05:08:20:16:17:02:20:05 aa
338 06:07:14:18:14:20:14:06  aa
339 07:06:08:10:08:14:08:07   aa
340 08:05:02:04:02:08:02:08    aa
341 09:16:22:02:22:04:24:13 b
342 10:15:16:20:19:22:18:14  b
343 11:14:10:12:10:16:12:15   b
344 12:13:04:06:04:10:06:16    b
345 13:24:24:22:24:06:22:21 bb
346 14:23:18:24:21:24:16:22  bb
347 15:22:12:14:12:18:10:23   bb
348 16:21:06:08:06:12:04:24    bb
349 17:12:21:21:18:03:19:09 ab
350 18:11:15:19:15:21:13:10  ab
351 19:10:09:11:09:15:07:11   ab
352 20:09:03:05:03:09:01:12    ab
353 21:20:23:17:23:05:23:17 ba
354 22:19:17:23:20:23:17:18  ba
355 23:18:11:13:11:17:11:19   ba
356 24:17:05:07:05:11:05:20    ba
357 EOF
358
359         atf_check -x "sort -S -k2b -k2 in >xx"
360         atf_check -e ignore sort -c -t: -k2n xx
361
362         atf_check -x "sort -S -k2,2.1b -k2 in >xx"
363         atf_check -e ignore sort -c -t: -k3n xx
364
365         atf_check -x "sort -S -k2.3 -k2 in >xx"
366         atf_check -e ignore sort -c -t: -k4n xx
367
368         atf_check -x "sort -S -k2b,2.3 -k2 in >xx"
369         atf_check -e ignore sort -c -t: -k5n xx
370
371         atf_check -x "sort -S -k2.3,2.1b -k2 in >xx"
372         atf_check -e ignore sort -c -t: -k6n xx
373
374         atf_check -x "sort -S -k2,2.1b -k2r in >xx"
375         atf_check -e ignore sort -c -t: -k7n xx
376
377         atf_check -x "sort -S -b -k2,2 -k2 in >xx"
378         atf_check -e ignore sort -c -t: -k8n xx
379
380         # XXX This test is broken.  The standard is not clear on the behavior.
381         #atf_check -x "sort -S -b -k2,2b -k2 in >xx"
382         #atf_check -e ignore sort -c -t: -k3n xx
383 }
384
385 atf_test_case kflag_no_end
386 kflag_no_end_head()
387 {
388         atf_set "descr" "Tests the -k flag with a field without end"
389 }
390 kflag_no_end_body()
391 {
392         cat >in <<EOF
393 a-B
394 a+b
395 a b
396 A+b
397 a       b
398 EOF
399
400         cat >out <<EOF
401 a       b
402 a b
403 A+b
404 a-B
405 a+b
406 EOF
407
408         atf_check -o file:out sort -df -k 1 -k 1d <in
409 }
410
411 atf_test_case mflag
412 mflag_head()
413 {
414         atf_set "descr" "Tests the -m flag"
415 }
416 mflag_body()
417 {
418         cat >in1 <<EOF
419 a
420 ab
421 ab
422 bc
423 ca
424 EOF
425         cat >in2 <<EOF
426 Z
427 a
428 aa
429 ac
430 c
431 EOF
432         cat >out <<EOF
433 Z
434 a
435 a
436 aa
437 ab
438 ab
439 ac
440 bc
441 c
442 ca
443 EOF
444
445         atf_check -o file:out sort -S -m in1 in2
446 }
447
448 atf_test_case mflag_uflag
449 mflag_uflag_head()
450 {
451         atf_set "descr" "Tests the -m flag together with -u"
452 }
453 mflag_uflag_body()
454 {
455         cat >in <<EOF
456 a
457 b
458 c
459 d
460 EOF
461
462         atf_check -o file:in sort -m -u in
463 }
464
465 atf_test_case mflag_uflag_first
466 mflag_uflag_first_head()
467 {
468         atf_set "descr" "Tests that the -m flag together with -u picks the" \
469             "first among equal"
470 }
471 mflag_uflag_first_body()
472 {
473         cat >in <<EOF
474 3B
475 3b
476 3B2
477 ~3B2
478 4.1
479 41
480 5
481 5.
482 EOF
483
484         cat >out <<EOF
485 3B
486 3B2
487 4.1
488 5
489 EOF
490
491         atf_check -o file:out sort -mudf in
492         atf_check -o file:out sort -mudf -k1 in
493 }
494
495 atf_test_case nflag
496 nflag_head()
497 {
498         atf_set "descr" "Tests the -n flag"
499 }
500 nflag_body()
501 {
502         cat >in <<EOF
503 -99.0
504 -99.1
505 -.0002
506 -10
507 2
508 0010.000000000000000000000000000000000001
509 10
510 3x
511 x
512 EOF
513
514         cat >expout <<EOF
515 -99.1
516 -99.0
517 -10
518 -.0002
519 x
520 2
521 3x
522 10
523 0010.000000000000000000000000000000000001
524 EOF
525
526         atf_check -o file:expout sort -n in
527 }
528
529 atf_test_case nflag_rflag
530 nflag_rflag_head()
531 {
532         atf_set "descr" "Tests the -n and -r flag combination"
533 }
534 nflag_rflag_body()
535 {
536         cat >in <<EOF
537 1
538 123
539 2
540 EOF
541
542         cat >expout <<EOF
543 123
544 2
545 1
546 EOF
547
548         atf_check -o file:expout sort -rn in
549 }
550
551 atf_test_case oflag
552 oflag_head()
553 {
554         atf_set "descr" "Tests the -o flag"
555 }
556 oflag_body()
557 {
558         cat >in <<EOF
559 1
560 1
561 2
562 2
563 3
564 3
565 4
566 4
567 EOF
568
569         atf_check sort -u -o in in
570
571         cat >expout <<EOF
572 1
573 2
574 3
575 4
576 EOF
577
578         atf_check -o file:expout cat in
579 }
580
581 atf_test_case oflag_displaced
582 oflag_displaced_head()
583 {
584         atf_set "descr" "Tests the -o flag after the file names"
585 }
586 oflag_displaced_body()
587 {
588         atf_check sort -S /dev/null -o out
589         test -f out || atf_fail "File not created"
590 }
591
592 atf_test_case rflag
593 rflag_head()
594 {
595         atf_set "descr" "Tests the -r flag"
596 }
597 rflag_body()
598 {
599         cat >in <<EOF
600 z b m f
601 y c o e
602 x a n h
603 x a n g
604 EOF
605
606         cat >expout <<EOF
607 z b m f
608 y c o e
609 x a n h
610 x a n g
611 EOF
612
613         atf_check -o file:expout sort -r in
614 }
615
616 atf_test_case sflag
617 sflag_head()
618 {
619         atf_set "descr" "Tests the -s flag"
620 }
621 sflag_body()
622 {
623         cat >in <<EOF
624 a 2
625 b 1
626 c 2
627 a 1
628 b 2
629 c 1
630 EOF
631
632         cat >out <<EOF
633 a 2
634 a 1
635 b 1
636 b 2
637 c 2
638 c 1
639 EOF
640
641         atf_check -o file:out sort -s -k1,1 in
642 }
643
644 atf_test_case sflag_many_files
645 sflag_many_files_head()
646 {
647         atf_set "descr" "Tests the -s flag with multiple files"
648 }
649 sflag_many_files_body()
650 {
651         cat >in1 <<EOF
652 c 2
653 a 2
654 EOF
655
656         cat >in2 <<EOF
657 c 1
658 b 1
659 a 1
660 EOF
661
662         cat >out <<EOF
663 c 2
664 b 1
665 a 2
666 EOF
667
668         atf_check -o file:out sort -smru -k1,1 in1 in1 in2 in2
669 }
670
671 atf_test_case tflag
672 tflag_head()
673 {
674         atf_set "descr" "Tests the -t flag"
675 }
676 tflag_body()
677 {
678         cat >in <<EOF
679 a:
680 a!
681 EOF
682
683         atf_check -o file:in sort -t : -r +0 in
684         atf_check -o file:in sort -t : +0 -1 in
685         atf_check -o file:in sort -t : -r -k 1 in
686         atf_check -o file:in sort -t : -k 1,1 in
687 }
688
689 atf_test_case tflag_alphabetic
690 tflag_alphabetic_head()
691 {
692         atf_set "descr" "Tests the -t flag with a character as the delimiter"
693 }
694 tflag_alphabetic_body()
695 {
696         cat >in <<EOF
697 zXa
698 yXa
699 zXb
700 EOF
701
702         atf_check -o file:in sort -tX -k2 -k1r,1 in
703 }
704
705 atf_test_case tflag_char_pos
706 tflag_char_pos_head()
707 {
708         atf_set "descr" "Tests the -t flag with character positions in fields"
709 }
710 tflag_char_pos_body()
711 {
712         cat >in <<EOF
713 : ab
714 :bac
715 EOF
716
717         cat >out <<EOF
718 :bac
719 : ab
720 EOF
721
722         atf_check -o file:out sort -b -t: +1.1 in
723         atf_check -o file:out sort -t: +1.1r in
724         atf_check -o file:out sort -b -t: -k 2.2 in
725         atf_check -o file:out sort -t: -k 2.2r in
726 }
727
728 atf_test_case tflag_whitespace
729 tflag_whitespace_head()
730 {
731         atf_set "descr" "Tests the -t flag with spaces and tabs as the" \
732             "delimiter"
733 }
734 tflag_whitespace_body()
735 {
736         cat >in <<EOF
737  b c
738  b      c
739         b c
740 EOF
741
742         atf_check -o file:in sort -t ' ' -k2,2 in
743         atf_check -o file:in sort -t ' ' -k2.1,2.0 in
744
745         cat >out <<EOF
746  b c
747         b c
748  b      c
749 EOF
750
751         atf_check -o file:out sort -t ' ' -k2,2 in
752         atf_check -o file:out sort -t ' ' -k2.1,2.0 in
753
754         cat >out <<EOF
755  b      c
756         b c
757  b c
758 EOF
759
760         atf_check -o file:out sort -S -k2 in
761
762         cat >out <<EOF
763         b c
764  b      c
765  b c
766 EOF
767
768         atf_check -o file:out sort -S -k2b in
769 }
770
771 atf_test_case uflag
772 uflag_head()
773 {
774         atf_set "descr" "Tests the -u flag"
775 }
776 uflag_body()
777 {
778         cat >in <<EOF
779 a
780 aa
781 aaa
782 aa
783 EOF
784
785         cat >expout <<EOF
786 a
787 aa
788 aaa
789 EOF
790
791         atf_check -o file:expout sort -u in
792 }
793
794 atf_test_case uflag_rflag
795 uflag_rflag_head()
796 {
797         atf_set "descr" "Tests the -u and -r flag combination"
798 }
799 uflag_rflag_body()
800 {
801         cat >in <<EOF
802 a
803 aa
804 aaa
805 aa
806 EOF
807
808         cat >expout <<EOF
809 aaa
810 aa
811 a
812 EOF
813
814         atf_check -o file:expout sort -ru in
815 }
816
817 atf_test_case plus_one
818 plus_one_head()
819 {
820         atf_set "descr" "Tests +- addressing: +1 should become -k2.1"
821 }
822 plus_one_body()
823 {
824         cat >in <<EOF
825 z b m f
826 y c o e
827 x a n h
828 x a n g
829 EOF
830
831         cat >expout <<EOF
832 x a n g
833 x a n h
834 z b m f
835 y c o e
836 EOF
837
838         atf_check -o file:expout sort +1 in
839 }
840
841 atf_test_case plus_one_minus_two
842 plus_one_minus_two_head()
843 {
844         atf_set "descr" "Tests +- addressing: +1 -2 should become -k2.1,2.0"
845 }
846 plus_one_minus_two_body()
847 {
848         cat >in <<EOF
849 z b m f
850 y c o e
851 x a n h
852 x a n g
853 EOF
854
855         cat >expout <<EOF
856 x a n h
857 x a n g
858 z b m f
859 y c o e
860 EOF
861
862         atf_check -o file:expout sort +1 -2 in
863 }
864
865 atf_test_case plus_zero
866 plus_zero_head()
867 {
868         atf_set "descr" "Tests +- addressing: '-- +0' raised a '-k1.1: No" \
869             "such file or directory' error"
870 }
871 plus_zero_body()
872 {
873         echo 'good contents' >./+0
874
875         atf_check -o file:+0 sort -- +0
876 }
877
878 atf_test_case plus_nonmonotone
879 plus_nonmonotone_head()
880 {
881         atf_set "descr" "Tests += addressing: apparently nonmonotone field" \
882             "specs"
883 }
884 plus_nonmonotone_body()
885 {
886         cat >in <<EOF
887 aaaa c
888 x a
889 0 b
890 EOF
891
892         atf_check -o file:in sort +1 -0.3 +1.4 -1.5 in
893 }
894
895 atf_test_case plus_as_path
896 plus_as_path_head()
897 {
898         atf_set "descr" "Tests +- addressing: 'file +0' raised a '-k1.1: No" \
899             "such file or directory' error"
900 }
901 plus_as_path_body()
902 {
903         echo 'good contents' >./+0
904         echo 'more contents' >in
905         cat ./+0 in >expout
906
907         atf_check -o file:expout sort in +0
908 }
909
910 atf_test_case plus_bad_tempfile
911 plus_bad_tempfile_head()
912 {
913         atf_set "descr" "Tests +- addressing: intermediate wrong behavior" \
914             "that raised a '+0: No such file or directory' error"
915 }
916 plus_bad_tempfile_body()
917 {
918         echo 'good contents' >in
919         atf_check -o file:in sort -T /tmp +0 in
920 }
921
922 atf_test_case plus_rflag_invalid
923 plus_rflag_invalid_head()
924 {
925         atf_set "descr" "Tests +- addressing: invalid record delimiter"
926 }
927 plus_rflag_invalid_body()
928 {
929         (
930             echo 'z b m f'
931             echo 'y c o e'
932             echo 'x a n h'
933             echo 'x a n g'
934         ) | tr '\n' '+' >in
935
936         atf_check -o inline:'x a n g+x a n h+z b m f+y c o e+' \
937             sort -R + -k2 in
938 }
939
940 atf_test_case plus_tflag
941 plus_tflag_head()
942 {
943         atf_set "descr" "Tests +- addressing: using -T caused a 'No such file" \
944             "or directory' error"
945 }
946 plus_tflag_body()
947 {
948         mkdir ./+
949         yes | sed 200000q | sort -T + >/dev/null || atf_fail "program failed"
950 }
951
952 atf_test_case plus_no_end
953 plus_no_end_head()
954 {
955         atf_set "descr" "Tests +- addressing: field without end"
956 }
957 plus_no_end_body()
958 {
959         cat >in <<EOF
960 a-B
961 a+b
962 a b
963 A+b
964 a       b
965 EOF
966
967         cat >out <<EOF
968 a       b
969 a b
970 A+b
971 a-B
972 a+b
973 EOF
974
975         atf_check -o file:out sort -df +0 +0d in
976 }
977
978 atf_init_test_cases()
979 {
980         atf_add_test_case basic
981         atf_add_test_case empty_file
982         atf_add_test_case end_of_options
983         atf_add_test_case missing_newline
984         atf_add_test_case null_bytes
985         atf_add_test_case long_records
986         atf_add_test_case long_file
987         atf_add_test_case any_char
988         atf_add_test_case bflag
989         atf_add_test_case cflag
990         atf_add_test_case kflag_one_field
991         atf_add_test_case kflag_two_fields
992         atf_add_test_case kflag_many_fields
993         atf_add_test_case kflag_outofbounds
994         atf_add_test_case kflag_nonmonotone
995         atf_add_test_case kflag_limits
996         atf_add_test_case kflag_alpha
997         atf_add_test_case kflag_no_end
998         atf_add_test_case mflag
999         atf_add_test_case mflag_uflag
1000         atf_add_test_case mflag_uflag_first
1001         atf_add_test_case nflag
1002         atf_add_test_case nflag_rflag
1003         atf_add_test_case oflag
1004         atf_add_test_case oflag_displaced
1005         atf_add_test_case rflag
1006         atf_add_test_case sflag
1007         atf_add_test_case sflag_many_files
1008         atf_add_test_case tflag
1009         atf_add_test_case tflag_alphabetic
1010         atf_add_test_case tflag_char_pos
1011         atf_add_test_case tflag_whitespace
1012         atf_add_test_case uflag
1013         atf_add_test_case uflag_rflag
1014         atf_add_test_case plus_one
1015         atf_add_test_case plus_one_minus_two
1016         atf_add_test_case plus_zero
1017         atf_add_test_case plus_nonmonotone
1018         atf_add_test_case plus_as_path
1019         atf_add_test_case plus_bad_tempfile
1020         atf_add_test_case plus_rflag_invalid
1021         atf_add_test_case plus_tflag
1022         atf_add_test_case plus_no_end
1023 }