Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/testsuite/sed.tests
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/testsuite/sed.tests
r1765 r2725 3 3 # SUSv3 compliant sed tests. 4 4 # Copyright 2005 by Rob Landley <rob@landley.net> 5 # Licensed under GPL v2, see file LICENSE for details.6 7 . testing.sh5 # Licensed under GPLv2, see file LICENSE in this source tree. 6 7 . ./testing.sh 8 8 9 9 # testing "description" "arguments" "result" "infile" "stdin" … … 52 52 "" "foo\n" 53 53 testing "sed -n s//p" "sed -ne s/abc/def/p" "def\n" "" "abc\n" 54 test x"$SKIP_KNOWN_BUGS" = x"" && { 54 55 testing "sed s//g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5,\n" \ 55 56 "" "12345\n" 57 } 56 58 testing "sed s arbitrary delimiter" "sed -e 's woo boing '" "boing\n" "" "woo\n" 57 59 testing "sed s chains" "sed -e s/foo/bar/ -e s/bar/baz/" "baz\n" "" "foo\n" 58 60 testing "sed s chains2" "sed -e s/foo/bar/ -e s/baz/nee/" "bar\n" "" "foo\n" 59 61 testing "sed s [delimiter]" "sed -e 's@[@]@@'" "onetwo" "" "one@two" 62 testing "sed s with \\t (GNU ext)" "sed 's/\t/ /'" "one two" "" "one\ttwo" 60 63 61 64 # branch … … 72 75 "1\n1\n1\nb\nb\nc\nc\n" "" "a\nb\nc\n" 73 76 77 test x"$SKIP_KNOWN_BUGS" = x"" && { 74 78 # Normal sed end-of-script doesn't print "c" because n flushed the pattern 75 79 # space. If n hits EOF, pattern space is empty when script ends. … … 77 81 testing "sed n (flushes pattern space, terminates early)" "sed -e 'n;p'" \ 78 82 "a\nb\nb\nc\n" "" "a\nb\nc\n" 79 # N does _not_ flush pattern space, therefore c is still in there @ script end. 80 testing "sed N (doesn't flush pattern space when terminating)" "sed -e 'N;p'" \ 83 } 84 # non-GNU sed: N does _not_ flush pattern space, therefore c is eaten @ script end 85 # GNU sed: N flushes pattern space, therefore c is printed too @ script end 86 testing "sed N (flushes pattern space (GNU behavior))" "sed -e 'N;p'" \ 81 87 "a\nb\na\nb\nc\n" "" "a\nb\nc\n" 88 89 testing "sed N test2" "sed ':a;N;s/\n/ /;ta'" \ 90 "a b c\n" "" "a\nb\nc\n" 91 92 testing "sed N test3" "sed 'N;s/\n/ /'" \ 93 "a b\nc\n" "" "a\nb\nc\n" 94 82 95 testing "sed address match newline" 'sed "/b/N;/b\\nc/i woo"' \ 83 96 "a\nwoo\nb\nc\nd\n" "" "a\nb\nc\nd\n" … … 99 112 100 113 # Multiple files, with varying newlines and NUL bytes 114 test x"$SKIP_KNOWN_BUGS" = x"" && { 101 115 testing "sed embedded NUL" "sed -e 's/woo/bang/'" "\0bang\0woo\0" "" \ 102 116 "\0woo\0woo\0" 117 } 103 118 testing "sed embedded NUL g" "sed -e 's/woo/bang/g'" "bang\0bang\0" "" \ 104 119 "woo\0woo\0" 105 echo -e "/woo/a he\0llo" > sed.commands 120 test x"$SKIP_KNOWN_BUGS" = x"" && { 121 $ECHO -e "/woo/a he\0llo" > sed.commands 106 122 testing "sed NUL in command" "sed -f sed.commands" "woo\nhe\0llo\n" "" "woo" 107 123 rm sed.commands 124 } 108 125 109 126 # sed has funky behavior with newlines at the end of file. Test lots of … … 120 137 testing "sed cat plus empty file" "sed -e 's/nohit//' input -" "one\ntwo" \ 121 138 "one\ntwo" "" 139 test x"$SKIP_KNOWN_BUGS" = x"" && { 122 140 testing "sed append autoinserts newline" "sed -e '/woot/a woo' -" \ 123 141 "woot\nwoo\n" "" "woot" 142 } 124 143 testing "sed insert doesn't autoinsert newline" "sed -e '/woot/i woo' -" \ 125 144 "woo\nwoot" "" "woot" … … 137 156 "sed -ne 's/woo/bang/p' input -" "a bang\nb bang" "a woo\nb woo" \ 138 157 "c no\nd no" 158 test x"$SKIP_KNOWN_BUGS" = x"" && { 139 159 testing "sed clusternewline" \ 140 160 "sed -e '/one/a 111' -e '/two/i 222' -e p input -" \ 141 161 "one\none\n111\n222\ntwo\ntwo" "one" "two" 162 } 142 163 testing "sed subst+write" \ 143 "sed -e 's/i/z/' -e 'woutputw' input -; echo-n X; cat outputw" \164 "sed -e 's/i/z/' -e 'woutputw' input -; $ECHO -n X; cat outputw" \ 144 165 "thzngy\nagaznXthzngy\nagazn" "thingy" "again" 145 166 rm outputw … … 163 184 #00000020 6f 75 72 |our| 164 185 # which looks buggy to me. 165 echo-ne "three\nfour" > input2186 $ECHO -ne "three\nfour" > input2 166 187 testing "sed match EOF inline" \ 167 188 "sed -e '"'$i ook'"' -i input input2 && cat input input2" \ … … 175 196 176 197 # Jump to nonexistent label 177 testing "sed nonexistent label" "sed -e 'b walrus' 2> /dev/null || echo yes" \ 198 test x"$SKIP_KNOWN_BUGS" = x"" && { 199 # Incompatibility: illegal jump is not detected if input is "" 200 # (that is, no lines at all). GNU sed 4.1.5 complains even in this case 201 testing "sed nonexistent label" "sed -e 'b walrus' 2>/dev/null || echo yes" \ 178 202 "yes\n" "" "" 203 } 179 204 180 205 testing "sed backref from empty s uses range regex" \ … … 201 226 # "" "12345" 202 227 228 # testing "description" "arguments" "result" "infile" "stdin" 229 230 testing "sed n command must reset 'substituted' bit" \ 231 "sed 's/1/x/;T;n;: next;s/3/y/;t quit;n;b next;: quit;q'" \ 232 "0\nx\n2\ny\n" "" "0\n1\n2\n3\n" 233 234 testing "sed d does not break n,m matching" \ 235 "sed -n '1d;1,3p'" \ 236 "second\nthird\n" "" "first\nsecond\nthird\nfourth\n" 237 238 testing "sed d does not break n,regex matching" \ 239 "sed -n '1d;1,/hir/p'" \ 240 "second\nthird\n" "" "first\nsecond\nthird\nfourth\n" 241 242 testing "sed d does not break n,regex matching #2" \ 243 "sed -n '1,5d;1,/hir/p'" \ 244 "second2\nthird2\n" "" \ 245 "first\nsecond\nthird\nfourth\n""first2\nsecond2\nthird2\nfourth2\n" 246 247 testing "sed 2d;2,1p (gnu compat)" \ 248 "sed -n '2d;2,1p'" \ 249 "third\n" "" \ 250 "first\nsecond\nthird\nfourth\n" 251 252 # Regex means: "match / at BOL or nothing, then one or more not-slashes". 253 # The bug was that second slash in /usr/lib was treated as "at BOL" too. 254 testing "sed beginning (^) matches only once" \ 255 "sed 's,\(^/\|\)[^/][^/]*,>\0<,g'" \ 256 ">/usr</>lib<\n" "" \ 257 "/usr/lib\n" 258 259 testing "sed c" \ 260 "sed 'crepl'" \ 261 "repl\nrepl\n" "" \ 262 "first\nsecond\n" 263 264 testing "sed nested {}s" \ 265 "sed '/asd/ { p; /s/ { s/s/c/ }; p; q }'" \ 266 "qwe\nasd\nacd\nacd\n" "" \ 267 "qwe\nasd\nzxc\n" 268 269 testing "sed a cmd ended by double backslash" \ 270 "sed -e '/| one /a \\ 271 | three \\\\' -e '/| one-/a \\ 272 | three-* \\\\'" \ 273 ' | one \\ 274 | three \\ 275 | two \\ 276 ' '' \ 277 ' | one \\ 278 | two \\ 279 ' 280 281 # first three lines are deleted; 4th line is matched and printed by "2,3" and by "4" ranges 282 testing "sed with N skipping lines past ranges on next cmds" \ 283 "sed -n '1{N;N;d};1p;2,3p;3p;4p'" \ 284 "4\n4\n" "" "1\n2\n3\n4\n" 285 286 testing "sed -i with address modifies all files, not only first" \ 287 "cp input input2; sed -i -e '1s/foo/bar/' input input2 && cat input input2; rm input2" \ 288 "bar\nbar\n" "foo\n" "" 289 290 291 # testing "description" "arguments" "result" "infile" "stdin" 292 203 293 exit $FAILCOUNT
Note:
See TracChangeset
for help on using the changeset viewer.