1 |
#!/bin/bash |
#!/bin/sh |
2 |
|
|
3 |
# SUSv3 compliant sort tests. |
# SUSv3 compliant sort tests. |
4 |
# Copyright 2005 by Rob Landley <rob@landley.net> |
# Copyright 2005 by Rob Landley <rob@landley.net> |
5 |
# Licensed under GPL v2, see file LICENSE for details. |
# Licensed under GPL v2, see file LICENSE for details. |
6 |
|
|
7 |
. testing.sh |
. ./testing.sh |
8 |
|
|
9 |
# The basic tests. These should work even with the small busybox. |
# The basic tests. These should work even with the small busybox. |
10 |
|
|
27 |
999 3 0 algebra |
999 3 0 algebra |
28 |
" |
" |
29 |
|
|
30 |
|
# testing "description" "command(s)" "result" "infile" "stdin" |
31 |
|
|
32 |
# Sorting with keys |
# Sorting with keys |
33 |
|
|
34 |
testing "sort one key" "sort -k4,4 input" \ |
testing "sort one key" "sort -k4,4 input" \ |
47 |
999 3 0 algebra |
999 3 0 algebra |
48 |
" "$data" "" |
" "$data" "" |
49 |
|
|
50 |
# Busybox is definitely doing this one wrong just now. FIXME |
test x"$SKIP_KNOWN_BUGS" = x"" && { |
51 |
|
# Busybox is definitely doing these wrong. FIXME |
52 |
testing "sort key range with numeric option and global reverse" \ |
testing "sort key range with numeric option and global reverse" \ |
53 |
"sort -k2,3n -r input" \ |
"sort -k2,3n -r input" \ |
54 |
"egg 1 2 papyrus |
"egg 1 2 papyrus |
58 |
7 3 42 soup |
7 3 42 soup |
59 |
" "$data" "" |
" "$data" "" |
60 |
|
|
|
# |
|
|
|
|
61 |
testing "sort key range with multiple options" "sort -k2,3rn input" \ |
testing "sort key range with multiple options" "sort -k2,3rn input" \ |
62 |
"7 3 42 soup |
"7 3 42 soup |
63 |
999 3 0 algebra |
999 3 0 algebra |
65 |
42 1 3 woot |
42 1 3 woot |
66 |
egg 1 2 papyrus |
egg 1 2 papyrus |
67 |
" "$data" "" |
" "$data" "" |
68 |
|
} |
69 |
|
|
70 |
testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\ |
testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\ |
71 |
d 2 |
d 2 |
117 |
testing "sort key doesn't strip leading blanks, disables fallback global sort" \ |
testing "sort key doesn't strip leading blanks, disables fallback global sort" \ |
118 |
"sort -n -k2 -t ' '" " a \n 1 \n 2 \n" "" " 2 \n 1 \n a \n" |
"sort -n -k2 -t ' '" " a \n 1 \n 2 \n" "" " 2 \n 1 \n a \n" |
119 |
|
|
120 |
|
testing "sort file in place" \ |
121 |
|
"strace -oZZZ sort -o input input && cat input" "\ |
122 |
|
111 |
123 |
|
222 |
124 |
|
" "\ |
125 |
|
222 |
126 |
|
111 |
127 |
|
" "" |
128 |
|
|
129 |
|
# testing "description" "command(s)" "result" "infile" "stdin" |
130 |
|
|
131 |
exit $FAILCOUNT |
exit $FAILCOUNT |