diff options
author | Rob Landley <rob@landley.net> | 2005-09-04 11:10:37 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-09-04 11:10:37 +0000 |
commit | b766c394569cce356fceb63d83da79581c0997b9 (patch) | |
tree | a1c4cd18cede88c2e18a6e22f0b59924d5838682 /testsuite/busybox.tests | |
parent | 9754b91c16288fd0f4d6301fd6d01aa8b3c3b1d9 (diff) | |
download | busybox-w32-b766c394569cce356fceb63d83da79581c0997b9.tar.gz busybox-w32-b766c394569cce356fceb63d83da79581c0997b9.tar.bz2 busybox-w32-b766c394569cce356fceb63d83da79581c0997b9.zip |
General cleanup of command line parsing to allow "busybox" to work as a prefix.
(I.E. any argv[0] that starts with "busybox" winds up in busybox_main().)
Added testing/busybox.tests which tests the following permutations:
./busybox
./busybox-suffix
./busybox cat
./busybox-suffix cat
./busybox --help
./busybox-suffix --help
./busybox --help cat
./busybox-suffix --help cat
./busybox --help unknown
./busybox-suffix --help unknown
./unknown
Also repair the test suite so ./runtest calls the ".tests" scripts properly.
Note: you can now go "busybox busybox busbox ls -l" and it'll take it. The
new code is pretty generic. I can block that if anybody can come up with a
good reason to...
Diffstat (limited to 'testsuite/busybox.tests')
-rwxr-xr-x | testsuite/busybox.tests | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/testsuite/busybox.tests b/testsuite/busybox.tests new file mode 100755 index 000000000..f26f01b0c --- /dev/null +++ b/testsuite/busybox.tests | |||
@@ -0,0 +1,123 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Tests for busybox applet itself. | ||
4 | # Copyright 2005 by Rob Landley <rob@landley.net> | ||
5 | # Licensed under GPL v2, see file LICENSE for details. | ||
6 | |||
7 | if [ ${#COMMAND} -eq 0 ]; then COMMAND=busybox; fi | ||
8 | . testing.sh | ||
9 | |||
10 | # We'll assume "cat" is built in, because we need some other command to test. | ||
11 | |||
12 | HELPDUMP=`$COMMAND` | ||
13 | |||
14 | # The gratuitous "\n"s are due to a shell idiosyncrasy: environment variables | ||
15 | # seem to strip trailing whitespace, which makes cmp and diff unhappy. | ||
16 | |||
17 | ln -s `which "$COMMAND"` busybox-suffix | ||
18 | ln -s `which "$COMMAND"` unknown | ||
19 | |||
20 | for i in busybox busybox-suffix | ||
21 | do | ||
22 | # The gratuitous "\n"s are due to a shell idiosyncrasy: | ||
23 | # environment variables seem to strip trailing whitespace. | ||
24 | |||
25 | testing "$i" "" "$HELPDUMP\n\n" "" "" | ||
26 | |||
27 | testing "$i cat" "cat" "moo" "" "moo" | ||
28 | |||
29 | testing "$i unknown" "unknown 2>&1" \ | ||
30 | "unknown: applet not found\n" "" "" | ||
31 | |||
32 | testing "$i --help" "--help 2>&1" "$HELPDUMP\n\n" "" "" | ||
33 | |||
34 | testing "$i --help cat" "--help cat 2>&1 | grep prints" \ | ||
35 | "Concatenates FILE(s) and prints them to stdout.\n" "" "" | ||
36 | |||
37 | testing "$i --help unknown" "--help unknown 2>&1" \ | ||
38 | "unknown: applet not found\n" "" "" | ||
39 | |||
40 | COMMAND=./busybox-suffix | ||
41 | done | ||
42 | |||
43 | COMMAND="./unknown" | ||
44 | testing "busybox as unknown name" "2>&1" "unknown: applet not found\n" "" "" | ||
45 | |||
46 | rm -f busybox-suffix unknown | ||
47 | |||
48 | exit | ||
49 | |||
50 | General cleanup of command line parsing to allow "busybox" to work as a prefix. | ||
51 | (I.E. any argv[0] that starts with "busybox" winds up in busybox_main().) | ||
52 | |||
53 | Tests: | ||
54 | ./busybox | ||
55 | ./busybox-walrus | ||
56 | ./busybox ls | ||
57 | ./busybox-walrus ls | ||
58 | ./busybox --help | ||
59 | ./busybox-walrus --help | ||
60 | ./busybox --help ls | ||
61 | ./busybox-walrus --help ls | ||
62 | ./busybox --help walrus | ||
63 | ./busybox-walrus --help walrus | ||
64 | |||
65 | |||
66 | |||
67 | |||
68 | |||
69 | |||
70 | |||
71 | |||
72 | |||
73 | # These tests require the full option set. | ||
74 | |||
75 | # Longish chunk of data re-used by the next few tests | ||
76 | |||
77 | data="42 1 3 woot | ||
78 | 42 1 010 zoology | ||
79 | egg 1 2 papyrus | ||
80 | 7 3 42 soup | ||
81 | 999 3 0 algebra | ||
82 | " | ||
83 | |||
84 | # Sorting with keys | ||
85 | |||
86 | testing "sort one key" "-k4,4 input" \ | ||
87 | "999 3 0 algebra | ||
88 | egg 1 2 papyrus | ||
89 | 7 3 42 soup | ||
90 | 42 1 3 woot | ||
91 | 42 1 010 zoology | ||
92 | " "$data" "" | ||
93 | |||
94 | testing "sort key range with numeric option" "-k2,3n input" \ | ||
95 | "42 1 010 zoology | ||
96 | 42 1 3 woot | ||
97 | egg 1 2 papyrus | ||
98 | 7 3 42 soup | ||
99 | 999 3 0 algebra | ||
100 | " "$data" "" | ||
101 | |||
102 | # Busybox is definitely doing this one wrong just now... | ||
103 | |||
104 | testing "sort key range with numeric option and global reverse" \ | ||
105 | "-k2,3n -r input" \ | ||
106 | "egg 1 2 papyrus | ||
107 | 42 1 3 woot | ||
108 | 42 1 010 zoology | ||
109 | 999 3 0 algebra | ||
110 | 7 3 42 soup | ||
111 | " "$data" "" | ||
112 | |||
113 | # | ||
114 | |||
115 | testing "sort key range with multiple options" "-k2,3rn input" \ | ||
116 | "7 3 42 soup | ||
117 | 999 3 0 algebra | ||
118 | 42 1 010 zoology | ||
119 | 42 1 3 woot | ||
120 | egg 1 2 papyrus | ||
121 | " "$data" "" | ||
122 | |||
123 | exit $FAILCOUNT | ||