aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-03-01 16:32:01 +0000
committerRob Landley <rob@landley.net>2006-03-01 16:32:01 +0000
commite8e7811fb471ae11868db8f715c06960bba8637b (patch)
tree8443f180fcbaab438b53a306e79a2de3fc6f2a19
parent325da7b509e25cbb26bfc77418b27d397cbc0e4d (diff)
downloadbusybox-w32-e8e7811fb471ae11868db8f715c06960bba8637b.tar.gz
busybox-w32-e8e7811fb471ae11868db8f715c06960bba8637b.tar.bz2
busybox-w32-e8e7811fb471ae11868db8f715c06960bba8637b.zip
Yet more sed tests. Passing these is a to-do item for 1.1.2 or 1.2, not a
1.1.1 issue.
-rwxr-xr-xtestsuite/sed.tests54
1 files changed, 45 insertions, 9 deletions
diff --git a/testsuite/sed.tests b/testsuite/sed.tests
index 1f2208200..6fcaa19df 100755
--- a/testsuite/sed.tests
+++ b/testsuite/sed.tests
@@ -10,17 +10,14 @@
10# testing "description" "arguments" "result" "infile" "stdin" 10# testing "description" "arguments" "result" "infile" "stdin"
11 11
12# Corner cases 12# Corner cases
13testing "sed as cat" '"" -' "hello\n" "" "hello\n" 13testing "sed no files (stdin)" '""' "hello\n" "" "hello\n"
14testing "sed explicit stdin" '"" -' "hello\n" "" "hello\n"
14testing "sed handles empty lines" "-e 's/\$/@/'" "@\n" "" "\n" 15testing "sed handles empty lines" "-e 's/\$/@/'" "@\n" "" "\n"
16testing "sed stdin twice" '"" - -' "hello" "" "hello"
15 17
16# no files (stdin)
17# explicit stdin
18# mix files and stdin (various orders)
19# list stdin twice
20# Trailing EOF. 18# Trailing EOF.
21# Multiple files: first no EOF, second length 0.
22# Match $, at end of each file or all files? 19# Match $, at end of each file or all files?
23# First no EOF, second no matches at all. 20
24# -e corner cases 21# -e corner cases
25# without -e 22# without -e
26# multiple -e 23# multiple -e
@@ -37,6 +34,9 @@ testing "sed handles empty lines" "-e 's/\$/@/'" "@\n" "" "\n"
37# permissions 34# permissions
38# -i on a symlink 35# -i on a symlink
39# on a directory 36# on a directory
37# With $ last-line test
38# Continue with \
39# End of script with trailing \
40 40
41# command list 41# command list
42testing "sed accepts blanks before command" "-e '1 d'" "" "" "" 42testing "sed accepts blanks before command" "-e '1 d'" "" "" ""
@@ -100,6 +100,10 @@ testing "sed d ends script iteration (2)" \
100 100
101# Multiple files, with varying newlines and NUL bytes 101# Multiple files, with varying newlines and NUL bytes
102testing "sed embedded NUL" "-e 's/woo/bang/'" "\0bang\0woo\0" "" "\0woo\0woo\0" 102testing "sed embedded NUL" "-e 's/woo/bang/'" "\0bang\0woo\0" "" "\0woo\0woo\0"
103testing "sed embedded NUL g" "-e 's/woo/bang/g'" "bang\0bang\0" "" "woo\0woo\0"
104echo -e "/woo/a he\0llo" > sed.commands
105testing "sed NUL in command" "-f sed.commands" "woo\nhe\0llo\n" "" "woo"
106rm sed.commands
103 107
104# sed has funky behavior with newlines at the end of file. Test lots of 108# sed has funky behavior with newlines at the end of file. Test lots of
105# corner cases with the optional newline appending behavior. 109# corner cases with the optional newline appending behavior.
@@ -121,10 +125,9 @@ testing "sed insert doesn't autoinsert newline" "-e '/woot/i woo' -" \
121testing "sed print autoinsert newlines" "-e 'p' -" "one\none" "" "one" 125testing "sed print autoinsert newlines" "-e 'p' -" "one\none" "" "one"
122testing "sed print autoinsert newlines two files" "-e 'p' input -" \ 126testing "sed print autoinsert newlines two files" "-e 'p' input -" \
123 "one\none\ntwo\ntwo" "one" "two" 127 "one\none\ntwo\ntwo" "one" "two"
124
125testing "sed noprint, no match, no newline" "-ne 's/woo/bang/' input" \ 128testing "sed noprint, no match, no newline" "-ne 's/woo/bang/' input" \
126 "" "no\n" "" 129 "" "no\n" ""
127testing "sed selective matches with nl" "-ne 's/woo/bang/p' input -" \ 130testing "sed selective matches with one nl" "-ne 's/woo/bang/p' input -" \
128 "a bang\nc bang\n" "a woo\nb no" "c woo\nd no" 131 "a bang\nc bang\n" "a woo\nb no" "c woo\nd no"
129testing "sed selective matches insert newline" "-ne 's/woo/bang/p' input -" \ 132testing "sed selective matches insert newline" "-ne 's/woo/bang/p' input -" \
130 "a bang\nb bang\nd bang" "a woo\nb woo" "c no\nd woo" 133 "a bang\nb bang\nd bang" "a woo\nb woo" "c no\nd woo"
@@ -133,6 +136,39 @@ testing "sed selective matches noinsert newline" "-ne 's/woo/bang/p' input -" \
133testing "sed clusternewline" "-e '/one/a 111' -e '/two/i 222' -e p input -" \ 136testing "sed clusternewline" "-e '/one/a 111' -e '/two/i 222' -e p input -" \
134 "one\none\n111\n222\ntwo\ntwo" "one" "two" 137 "one\none\n111\n222\ntwo\ntwo" "one" "two"
135 138
139# Test end-of-file matching behavior
140
141testing "sed match EOF" " -e '"'$p'"'" "hello\nthere\nthere" "" "hello\nthere"
142testing "sed match EOF two files" " -e '"'$p'"' input -" \
143 "one\ntwo\nthree\nfour\nfour" "one\ntwo" "three\nfour"
144echo -ne "three\nfour" > input2
145testing "sed match EOF inline" \
146 " -e '"'$i ook'"' -i input input2 && cat input input2" \
147 "one\nook\ntwothree\nook\nfour" "one\ntwo" ""
148rm input2
149
150# Test lie-to-autoconf
151
152testing "sed lie-to-autoconf" "--version | grep -o 'GNU sed version '" \
153 "GNU sed version \n" "" ""
154
155# Jump to nonexistent label
156testing "sed nonexistent label" "-e 'b walrus' 2> /dev/null || echo yes" \
157 "yes\n" "" ""
158
159testing "sed backref from empty s uses range regex" \
160 "-e '/woot/s//eep \0 eep/'" "eep woot eep" "" "woot"
161
162testing "sed backref from empty s uses range regex with newline" \
163 "-e '/woot/s//eep \0 eep/'" "eep woot eep\n" "" "woot\n"
164
165# -i with no filename
166
167touch ./- # Detect gnu failure mode here.
168testing "sed -i with no arg [GNUFAIL]" "-e '' -i 2> /dev/null || echo yes" \
169 "yes\n" "" ""
170rm ./- # Clean up
171
136# Ponder this a bit more, why "woo not found" from gnu version? 172# Ponder this a bit more, why "woo not found" from gnu version?
137#testing "sed doesn't substitute in deleted line" \ 173#testing "sed doesn't substitute in deleted line" \
138# "-e '/ook/d;s/ook//;t woo;a bang;'" "bang" "" "ook\n" 174# "-e '/ook/d;s/ook//;t woo;a bang;'" "bang" "" "ook\n"