diff options
23 files changed, 109 insertions, 276 deletions
diff --git a/testsuite/sed.tests b/testsuite/sed.tests new file mode 100755 index 000000000..479dd9ae7 --- /dev/null +++ b/testsuite/sed.tests | |||
@@ -0,0 +1,109 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # SUSv3 compliant sed tests. | ||
4 | # Copyright 2005 by Rob Landley <rob@landley.net> | ||
5 | # Licensed under GPL v2, see file LICENSE for details. | ||
6 | |||
7 | [ -z "$COMMAND" ] && COMMAND=sed | ||
8 | . testing.sh | ||
9 | |||
10 | # testing "description" "arguments" "result" "infile" "stdin" | ||
11 | |||
12 | # Corner cases | ||
13 | testing "sed as cat" '"" -' "hello\n" "" "hello\n" | ||
14 | testing "sed handles empty lines" "-e 's/\$/@/'" "@\n" "" "\n" | ||
15 | |||
16 | # no files (stdin) | ||
17 | # explicit stdin | ||
18 | # mix files and stdin (various orders) | ||
19 | # list stdin twice | ||
20 | # Trailing EOF. | ||
21 | # Multiple files: first no EOF, second length 0. | ||
22 | # Match $, at end of each file or all files? | ||
23 | # First no EOF, second no matches at all. | ||
24 | # -e corner cases | ||
25 | # without -e | ||
26 | # multiple -e | ||
27 | # interact with a | ||
28 | # -eee arg1 arg2 arg3 | ||
29 | # -f corner cases | ||
30 | # -e -f -e | ||
31 | # -n corner cases | ||
32 | # no newline at EOF? | ||
33 | # -r corner cases | ||
34 | # Just make sure it works. | ||
35 | # -i corner cases: | ||
36 | # sed -i - | ||
37 | # permissions | ||
38 | # -i on a symlink | ||
39 | # on a directory | ||
40 | |||
41 | # command list | ||
42 | testing "sed accepts blanks before command" "-e '1 d'" "" "" "" | ||
43 | testing "sed accepts newlines in -e" "-e 'i\ | ||
44 | 1 | ||
45 | a\ | ||
46 | 3'" "1\n2\n3\n" "" "2\n" | ||
47 | testing "sed accepts multiple -e" "-e 'i\' -e '1' -e 'a\' -e '3'" \ | ||
48 | "1\n2\n3\n" "" "2\n" | ||
49 | |||
50 | # substitutions | ||
51 | testing "sed -n" "-n -e s/foo/bar/ -e s/bar/baz/" "" "" "foo\n" | ||
52 | testing "sed s//p" "-e s/foo/bar/p -e s/bar/baz/p" "bar\nbaz\nbaz\n" \ | ||
53 | "" "foo\n" | ||
54 | testing "sed -n s//p" "-ne s/abc/def/p" "def\n" "" "abc\n" | ||
55 | testing "sed s//g (exhaustive)" "-e 's/[[:space:]]*/,/g'" ",1,2,3,4,5,\n" \ | ||
56 | "" "12345\n" | ||
57 | testing "sed s arbitrary delimiter" "-e 's woo boing '" "boing\n" "" "woo\n" | ||
58 | testing "sed s chains" "-e s/foo/bar/ -e s/bar/baz/" "baz\n" "" "foo\n" | ||
59 | testing "sed s chains2" "-e s/foo/bar/ -e s/baz/nee/" "bar\n" "" "foo\n" | ||
60 | testing "sed s [delimiter]" "-e 's@[@]@@'" "onetwo" "" "one@two" | ||
61 | |||
62 | # branch | ||
63 | testing "sed b (branch)" "-e 'b one;p;: one'" "foo\n" "" "foo\n" | ||
64 | testing "sed b (branch with no label jumps to end)" "-e 'b;p'" \ | ||
65 | "foo\n" "" "foo\n" | ||
66 | |||
67 | # test and branch | ||
68 | testing "sed t (test/branch)" "-e 's/a/1/;t one;p;: one;p'" \ | ||
69 | "1\n1\nb\nb\nb\nc\nc\nc\n" "" "a\nb\nc\n" | ||
70 | testing "sed t (test/branch clears test bit)" "-e 's/a/b/;:loop;t loop'" \ | ||
71 | "b\nb\nc\n" "" "a\nb\nc\n" | ||
72 | testing "sed T (!test/branch)" "-e 's/a/1/;T notone;p;: notone;p'" \ | ||
73 | "1\n1\n1\nb\nb\nc\nc\n" "" "a\nb\nc\n" | ||
74 | |||
75 | # Normal sed end-of-script doesn't print "c" because n flushed the pattern | ||
76 | # space. If n hits EOF, pattern space is empty when script ends. | ||
77 | # Query: how does this interact with no newline at EOF? | ||
78 | testing "sed n (flushes pattern space, terminates early)" "-e 'n;p'" \ | ||
79 | "a\nb\nb\nc\n" "" "a\nb\nc\n" | ||
80 | # N does _not_ flush pattern space, therefore c is still in there @ script end. | ||
81 | testing "sed N (doesn't flush pattern space when terminating)" "-e 'N;p'" \ | ||
82 | "a\nb\na\nb\nc\n" "" "a\nb\nc\n" | ||
83 | testing "sed address match newline" '"/b/N;/b\\nc/i woo"' "a\nwoo\nb\nc\nd\n" \ | ||
84 | "" "a\nb\nc\nd\n" | ||
85 | |||
86 | # Multiple lines in pattern space | ||
87 | testing "sed N (stops at end of input) and P (prints to first newline only)" \ | ||
88 | "-n 'N;P;p'" "a\na\nb\n" "" "a\nb\nc\n" | ||
89 | |||
90 | # Hold space | ||
91 | testing "sed G (append hold space to pattern space)" 'G' "a\n\nb\n\nc\n\n" \ | ||
92 | "" "a\nb\nc\n" | ||
93 | #testing "sed g/G (swap/append hold and patter space)" | ||
94 | #testing "sed g (swap hold/pattern space)" | ||
95 | |||
96 | testing "sed d ends script iteration" \ | ||
97 | "-e '/ook/d;s/ook/ping/p;i woot'" "" "" "ook\n" | ||
98 | testing "sed d ends script iteration (2)" \ | ||
99 | "-e '/ook/d;a\' -e 'bang'" "woot\nbang\n" "" "ook\nwoot\n" | ||
100 | |||
101 | # Ponder this a bit more, why "woo not found" from gnu version? | ||
102 | #testing "sed doesn't substitute in deleted line" \ | ||
103 | # "-e '/ook/d;s/ook//;t woo;a bang;'" "bang" "" "ook\n" | ||
104 | |||
105 | # This makes both seds very unhappy. Why? | ||
106 | #testing "sed -g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5," \ | ||
107 | # "" "12345" | ||
108 | |||
109 | exit $FAILCOUNT | ||
diff --git a/testsuite/sed/sed-accepts-blanks-before-command b/testsuite/sed/sed-accepts-blanks-before-command deleted file mode 100644 index 9597c2f8b..000000000 --- a/testsuite/sed/sed-accepts-blanks-before-command +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | busybox sed -e '1 d' </dev/null | ||
diff --git a/testsuite/sed/sed-aic-commands b/testsuite/sed/sed-aic-commands deleted file mode 100644 index b41c14ab8..000000000 --- a/testsuite/sed/sed-aic-commands +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
1 | cat - >input <<EOF | ||
2 | 2i\\ | ||
3 | before 2 | ||
4 | 5c\\ | ||
5 | Change 5 | ||
6 | 10a\\ | ||
7 | After 10 | ||
8 | 22i\\ | ||
9 | before 22\\ | ||
10 | Continued | ||
11 | 25c\\ | ||
12 | Change 25\\ | ||
13 | Continued | ||
14 | 20a\\ | ||
15 | After 20\\ | ||
16 | Continued | ||
17 | 32i\\ | ||
18 | before 32\\ | ||
19 | Continued 1\\ | ||
20 | Continued 2\\ | ||
21 | Continued 3 | ||
22 | 35c\\ | ||
23 | Change 35\\ | ||
24 | Continued 1\\ | ||
25 | Continued 2\\ | ||
26 | Continued 3 | ||
27 | 30a\\ | ||
28 | After 30\\ | ||
29 | Continued 1\\ | ||
30 | Continued 2\\ | ||
31 | Continued 3 | ||
32 | EOF | ||
33 | busybox sed -f input >output <<EOF | ||
34 | 1 y | ||
35 | 2 y | ||
36 | 3 y | ||
37 | 4 y | ||
38 | 5 y | ||
39 | 6 y | ||
40 | 7 y | ||
41 | 8 y | ||
42 | 9 y | ||
43 | 10 y | ||
44 | 11 y | ||
45 | 12 y | ||
46 | 13 y | ||
47 | 14 y | ||
48 | 15 y | ||
49 | 16 y | ||
50 | 17 y | ||
51 | 18 y | ||
52 | 19 y | ||
53 | 20 y | ||
54 | 21 y | ||
55 | 22 y | ||
56 | 23 y | ||
57 | 24 y | ||
58 | 25 y | ||
59 | 26 y | ||
60 | 27 y | ||
61 | 28 y | ||
62 | 29 y | ||
63 | 30 y | ||
64 | 31 y | ||
65 | 32 y | ||
66 | 33 y | ||
67 | 34 y | ||
68 | 35 y | ||
69 | 36 y | ||
70 | 37 y | ||
71 | 38 y | ||
72 | 39 y | ||
73 | 40 y | ||
74 | EOF | ||
75 | cmp -s output - <<EOF | ||
76 | 1 y | ||
77 | before 2 | ||
78 | 2 y | ||
79 | 3 y | ||
80 | 4 y | ||
81 | Change 5 | ||
82 | 6 y | ||
83 | 7 y | ||
84 | 8 y | ||
85 | 9 y | ||
86 | 10 y | ||
87 | After 10 | ||
88 | 11 y | ||
89 | 12 y | ||
90 | 13 y | ||
91 | 14 y | ||
92 | 15 y | ||
93 | 16 y | ||
94 | 17 y | ||
95 | 18 y | ||
96 | 19 y | ||
97 | 20 y | ||
98 | After 20 | ||
99 | Continued | ||
100 | 21 y | ||
101 | before 22 | ||
102 | Continued | ||
103 | 22 y | ||
104 | 23 y | ||
105 | 24 y | ||
106 | Change 25 | ||
107 | Continued | ||
108 | 26 y | ||
109 | 27 y | ||
110 | 28 y | ||
111 | 29 y | ||
112 | 30 y | ||
113 | After 30 | ||
114 | Continued 1 | ||
115 | Continued 2 | ||
116 | Continued 3 | ||
117 | 31 y | ||
118 | before 32 | ||
119 | Continued 1 | ||
120 | Continued 2 | ||
121 | Continued 3 | ||
122 | 32 y | ||
123 | 33 y | ||
124 | 34 y | ||
125 | Change 35 | ||
126 | Continued 1 | ||
127 | Continued 2 | ||
128 | Continued 3 | ||
129 | 36 y | ||
130 | 37 y | ||
131 | 38 y | ||
132 | 39 y | ||
133 | 40 y | ||
134 | EOF | ||
diff --git a/testsuite/sed/sed-append-hold-space-to-pattern-space b/testsuite/sed/sed-append-hold-space-to-pattern-space deleted file mode 100644 index 6dda80fee..000000000 --- a/testsuite/sed/sed-append-hold-space-to-pattern-space +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | busybox sed 'G'>output <<EOF | ||
2 | a | ||
3 | b | ||
4 | c | ||
5 | EOF | ||
6 | cmp -s output - <<EOF | ||
7 | a | ||
8 | |||
9 | b | ||
10 | |||
11 | c | ||
12 | |||
13 | EOF | ||
diff --git a/testsuite/sed/sed-append-next-line b/testsuite/sed/sed-append-next-line deleted file mode 100644 index 0621a319f..000000000 --- a/testsuite/sed/sed-append-next-line +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | # This will fail if CONFIG_FEATURE_SED_GNU_COMPATABILITY is defined | ||
2 | busybox sed 'N;p'>output <<EOF | ||
3 | a | ||
4 | b | ||
5 | c | ||
6 | EOF | ||
7 | |||
8 | set +e | ||
9 | cmp -s output - <<EOF | ||
10 | a | ||
11 | b | ||
12 | a | ||
13 | b | ||
14 | c | ||
15 | EOF | ||
16 | if [ $? != 0 ] ; then | ||
17 | exit 0; | ||
18 | fi | ||
19 | exit 1; | ||
diff --git a/testsuite/sed/sed-branch b/testsuite/sed/sed-branch deleted file mode 100644 index 4167569ad..000000000 --- a/testsuite/sed/sed-branch +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | test "$(echo foo | busybox sed 'b one;p;: one')" = foo | ||
diff --git a/testsuite/sed/sed-branch-conditional b/testsuite/sed/sed-branch-conditional deleted file mode 100644 index 47d0a5ff2..000000000 --- a/testsuite/sed/sed-branch-conditional +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | busybox sed 's/a/1/;t one;p;: one;p'>output <<EOF | ||
2 | a | ||
3 | b | ||
4 | c | ||
5 | EOF | ||
6 | cmp -s output - <<EOF | ||
7 | 1 | ||
8 | 1 | ||
9 | b | ||
10 | b | ||
11 | b | ||
12 | c | ||
13 | c | ||
14 | c | ||
15 | EOF | ||
diff --git a/testsuite/sed/sed-branch-conditional-inverted b/testsuite/sed/sed-branch-conditional-inverted deleted file mode 100755 index f4df84b3e..000000000 --- a/testsuite/sed/sed-branch-conditional-inverted +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | busybox sed 's/a/1/;T notone;p;: notone;p'>output <<EOF | ||
2 | a | ||
3 | b | ||
4 | c | ||
5 | EOF | ||
6 | cmp -s output - <<EOF | ||
7 | 1 | ||
8 | 1 | ||
9 | 1 | ||
10 | b | ||
11 | b | ||
12 | c | ||
13 | c | ||
14 | EOF | ||
diff --git a/testsuite/sed/sed-branch-conditional2 b/testsuite/sed/sed-branch-conditional2 deleted file mode 100644 index f4b11f0f8..000000000 --- a/testsuite/sed/sed-branch-conditional2 +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | #XFAIL | ||
2 | busybox sed 's/a/b/;:loop;t loop'>output <<EOF | ||
3 | a | ||
4 | b | ||
5 | c | ||
6 | EOF | ||
7 | cmp -s output - <<EOF | ||
8 | b | ||
9 | b | ||
10 | c | ||
11 | EOF | ||
diff --git a/testsuite/sed/sed-branch-no-label b/testsuite/sed/sed-branch-no-label deleted file mode 100644 index 446c1bcd9..000000000 --- a/testsuite/sed/sed-branch-no-label +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | test "$(echo foo | busybox sed 'b;p')" = foo | ||
diff --git a/testsuite/sed/sed-chains-substs b/testsuite/sed/sed-chains-substs deleted file mode 100644 index 266936ac4..000000000 --- a/testsuite/sed/sed-chains-substs +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | test "$(echo foo | busybox sed -e s/foo/bar/ -e s/bar/baz/)" = baz | ||
diff --git a/testsuite/sed/sed-chains-substs2 b/testsuite/sed/sed-chains-substs2 deleted file mode 100644 index 90568f6e6..000000000 --- a/testsuite/sed/sed-chains-substs2 +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | test x"$(echo foo | busybox -n sed -e s/foo/bar/ -e s/foo/baz/)" = x | ||
diff --git a/testsuite/sed/sed-does-not-substitute-in-deleted-line b/testsuite/sed/sed-does-not-substitute-in-deleted-line deleted file mode 100644 index 6f106e104..000000000 --- a/testsuite/sed/sed-does-not-substitute-in-deleted-line +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | echo foo | busybox sed -e /foo/d -e s/foo/bar/ >foo | ||
2 | cmp foo /dev/null | ||
diff --git a/testsuite/sed/sed-handles-embedded-slashes b/testsuite/sed/sed-handles-embedded-slashes deleted file mode 100644 index cc287613d..000000000 --- a/testsuite/sed/sed-handles-embedded-slashes +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | test "$(echo fu/bar | busybox sed -e 's/[/]//')" = fubar | ||
diff --git a/testsuite/sed/sed-handles-empty-lines b/testsuite/sed/sed-handles-empty-lines deleted file mode 100644 index 2bb8f045a..000000000 --- a/testsuite/sed/sed-handles-empty-lines +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | test `echo | busybox sed -e 's/$/@/'` = @ | ||
diff --git a/testsuite/sed/sed-handles-unsatisfied-backrefs b/testsuite/sed/sed-handles-unsatisfied-backrefs deleted file mode 100644 index 61bff8837..000000000 --- a/testsuite/sed/sed-handles-unsatisfied-backrefs +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | busybox sed -e 's/.*root=/\1/' >output <<EOF | ||
2 | BOOT_IMAGE=vmlinuz root=/dev/hda5 initrd=init1 | ||
3 | EOF | ||
4 | cmp -s output - <<EOF | ||
5 | /dev/hda5 initrd=init1 | ||
6 | EOF | ||
diff --git a/testsuite/sed/sed-next-line b/testsuite/sed/sed-next-line deleted file mode 100644 index 38fe20cf2..000000000 --- a/testsuite/sed/sed-next-line +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | busybox sed 'n;p'>output <<EOF | ||
2 | a | ||
3 | b | ||
4 | c | ||
5 | EOF | ||
6 | cmp -s output - <<EOF | ||
7 | a | ||
8 | b | ||
9 | b | ||
10 | c | ||
11 | c | ||
12 | EOF | ||
diff --git a/testsuite/sed/sed-prints-line-once-for-multiple-substs b/testsuite/sed/sed-prints-line-once-for-multiple-substs deleted file mode 100644 index ba8955d6e..000000000 --- a/testsuite/sed/sed-prints-line-once-for-multiple-substs +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | busybox sed -e s/1/2/g -e s/3/4/g >output <<EOF | ||
2 | 1 | ||
3 | EOF | ||
4 | echo 2 | cmp -s output - | ||
diff --git a/testsuite/sed/sed-recurses-properly b/testsuite/sed/sed-recurses-properly deleted file mode 100644 index a02667b41..000000000 --- a/testsuite/sed/sed-recurses-properly +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | test "`echo '12345' | busybox sed -e 's/[[:space:]]*/,/g')` = ',1,2,3,4,5,'" | ||
diff --git a/testsuite/sed/sed-regex-match-newline b/testsuite/sed/sed-regex-match-newline deleted file mode 100644 index 1057e1718..000000000 --- a/testsuite/sed/sed-regex-match-newline +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | # FEATURE: CONFIG_FEATURE_SED_EMBEDED_NEWLINE | ||
2 | busybox sed -n 'N;/a\nb/p'>output <<EOF | ||
3 | a | ||
4 | b | ||
5 | c | ||
6 | EOF | ||
7 | cmp -s output - <<EOF | ||
8 | a | ||
9 | b | ||
10 | EOF | ||
diff --git a/testsuite/sed/sed-splits-edit-commands-on-command-line b/testsuite/sed/sed-splits-edit-commands-on-command-line deleted file mode 100644 index 6421fa552..000000000 --- a/testsuite/sed/sed-splits-edit-commands-on-command-line +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | echo 2 | busybox sed -e 'i\ | ||
2 | 1 | ||
3 | a\ | ||
4 | 3' > output | ||
5 | cmp output - <<EOF | ||
6 | 1 | ||
7 | 2 | ||
8 | 3 | ||
9 | EOF | ||
diff --git a/testsuite/sed/sed-subst-subprint b/testsuite/sed/sed-subst-subprint deleted file mode 100644 index 24f8bad7d..000000000 --- a/testsuite/sed/sed-subst-subprint +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | busybox sed 's/foo/bar/p'>output <<EOF | ||
2 | foo | ||
3 | bar | ||
4 | EOF | ||
5 | cmp -s output - <<EOF | ||
6 | bar | ||
7 | bar | ||
8 | bar | ||
9 | EOF | ||
diff --git a/testsuite/sed/sed-write-to-stdout b/testsuite/sed/sed-write-to-stdout deleted file mode 100644 index 95b4d724b..000000000 --- a/testsuite/sed/sed-write-to-stdout +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | busybox sed -n 'N;P;p'>output <<EOF | ||
2 | a | ||
3 | b | ||
4 | c | ||
5 | EOF | ||
6 | cmp -s output - <<EOF | ||
7 | a | ||
8 | a | ||
9 | b | ||
10 | EOF | ||