source: MondoRescue/branches/2.2.9/mindi-busybox/testsuite/sort.tests@ 3320

Last change on this file since 3320 was 3320, checked in by Bruno Cornec, 9 years ago
  • Re-add (thanks git BTW) the 2.2.9 branch which had been destroyed in the move to 3.0
  • Property svn:executable set to *
File size: 2.5 KB
Line 
1#!/bin/sh
2
3# SUSv3 compliant sort tests.
4# Copyright 2005 by Rob Landley <rob@landley.net>
5# Licensed under GPLv2, see file LICENSE in this source tree.
6
7. ./testing.sh
8
9# The basic tests. These should work even with the small busybox.
10
11testing "sort" "sort input" "a\nb\nc\n" "c\na\nb\n" ""
12testing "sort #2" "sort input" "010\n1\n3\n" "3\n1\n010\n" ""
13testing "sort stdin" "sort" "a\nb\nc\n" "" "b\na\nc\n"
14testing "sort numeric" "sort -n input" "1\n3\n010\n" "3\n1\n010\n" ""
15testing "sort reverse" "sort -r input" "wook\nwalrus\npoint\npabst\naargh\n" \
16 "point\nwook\npabst\naargh\nwalrus\n" ""
17
18# These tests require the full option set.
19
20optional FEATURE_SORT_BIG
21# Longish chunk of data re-used by the next few tests
22
23data="42 1 3 woot
2442 1 010 zoology
25egg 1 2 papyrus
267 3 42 soup
27999 3 0 algebra
28"
29
30# testing "description" "command(s)" "result" "infile" "stdin"
31
32# Sorting with keys
33
34testing "sort one key" "sort -k4,4 input" \
35"999 3 0 algebra
36egg 1 2 papyrus
377 3 42 soup
3842 1 3 woot
3942 1 010 zoology
40" "$data" ""
41
42testing "sort key range with numeric option" "sort -k2,3n input" \
43"42 1 010 zoology
4442 1 3 woot
45egg 1 2 papyrus
467 3 42 soup
47999 3 0 algebra
48" "$data" ""
49
50test x"$SKIP_KNOWN_BUGS" = x"" && {
51# Busybox is definitely doing these wrong. FIXME
52testing "sort key range with numeric option and global reverse" \
53"sort -k2,3n -r input" \
54"egg 1 2 papyrus
5542 1 3 woot
5642 1 010 zoology
57999 3 0 algebra
587 3 42 soup
59" "$data" ""
60
61testing "sort key range with multiple options" "sort -k2,3rn input" \
62"7 3 42 soup
63999 3 0 algebra
6442 1 010 zoology
6542 1 3 woot
66egg 1 2 papyrus
67" "$data" ""
68}
69
70testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\
71d 2
72b 2
73c 3
74" "\
75c 3
76b 2
77d 2
78" ""
79
80testing "sort with non-default leading delim 1" "sort -n -k2 -t/ input" "\
81/a/2
82/b/1
83" "\
84/a/2
85/b/1
86" ""
87
88testing "sort with non-default leading delim 2" "sort -n -k3 -t/ input" "\
89/b/1
90/a/2
91" "\
92/b/1
93/a/2
94" ""
95
96testing "sort with non-default leading delim 3" "sort -n -k3 -t/ input" "\
97//a/2
98//b/1
99" "\
100//a/2
101//b/1
102" ""
103
104testing "sort -u should consider field only when discarding" "sort -u -k2 input" "\
105a c
106" "\
107a c
108b c
109" ""
110
111testing "sort -z outputs NUL terminated lines" "sort -z input" "\
112one\0three\0two\0\
113" "\
114one\0two\0three\0\
115" ""
116
117testing "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"
119
120testing "sort file in place" \
121"sort -o input input && cat input" "\
122111
123222
124" "\
125222
126111
127" ""
128
129# testing "description" "command(s)" "result" "infile" "stdin"
130
131exit $FAILCOUNT
Note: See TracBrowser for help on using the repository browser.