Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/testsuite/sed.tests

    r1765 r2725  
    33# SUSv3 compliant sed tests.
    44# Copyright 2005 by Rob Landley <rob@landley.net>
    5 # Licensed under GPL v2, see file LICENSE for details.
    6 
    7 . testing.sh
     5# Licensed under GPLv2, see file LICENSE in this source tree.
     6
     7. ./testing.sh
    88
    99# testing "description" "arguments" "result" "infile" "stdin"
     
    5252    "" "foo\n"
    5353testing "sed -n s//p" "sed -ne s/abc/def/p" "def\n" "" "abc\n"
     54test x"$SKIP_KNOWN_BUGS" = x"" && {
    5455testing "sed s//g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5,\n" \
    5556    "" "12345\n"
     57}
    5658testing "sed s arbitrary delimiter" "sed -e 's woo boing '" "boing\n" "" "woo\n"
    5759testing "sed s chains" "sed -e s/foo/bar/ -e s/bar/baz/" "baz\n" "" "foo\n"
    5860testing "sed s chains2" "sed -e s/foo/bar/ -e s/baz/nee/" "bar\n" "" "foo\n"
    5961testing "sed s [delimiter]" "sed -e 's@[@]@@'" "onetwo" "" "one@two"
     62testing "sed s with \\t (GNU ext)" "sed 's/\t/ /'" "one two" "" "one\ttwo"
    6063
    6164# branch
     
    7275    "1\n1\n1\nb\nb\nc\nc\n" "" "a\nb\nc\n"
    7376
     77test x"$SKIP_KNOWN_BUGS" = x"" && {
    7478# Normal sed end-of-script doesn't print "c" because n flushed the pattern
    7579# space.  If n hits EOF, pattern space is empty when script ends.
     
    7781testing "sed n (flushes pattern space, terminates early)" "sed -e 'n;p'" \
    7882    "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
     86testing "sed N (flushes pattern space (GNU behavior))" "sed -e 'N;p'" \
    8187    "a\nb\na\nb\nc\n" "" "a\nb\nc\n"
     88
     89testing "sed N test2" "sed ':a;N;s/\n/ /;ta'" \
     90    "a b c\n" "" "a\nb\nc\n"
     91
     92testing "sed N test3" "sed 'N;s/\n/ /'" \
     93    "a b\nc\n" "" "a\nb\nc\n"
     94
    8295testing "sed address match newline" 'sed "/b/N;/b\\nc/i woo"' \
    8396    "a\nwoo\nb\nc\nd\n" "" "a\nb\nc\nd\n"
     
    99112
    100113# Multiple files, with varying newlines and NUL bytes
     114test x"$SKIP_KNOWN_BUGS" = x"" && {
    101115testing "sed embedded NUL" "sed -e 's/woo/bang/'" "\0bang\0woo\0" "" \
    102116    "\0woo\0woo\0"
     117}
    103118testing "sed embedded NUL g" "sed -e 's/woo/bang/g'" "bang\0bang\0" "" \
    104119    "woo\0woo\0"
    105 echo -e "/woo/a he\0llo" > sed.commands
     120test x"$SKIP_KNOWN_BUGS" = x"" && {
     121$ECHO -e "/woo/a he\0llo" > sed.commands
    106122testing "sed NUL in command" "sed -f sed.commands" "woo\nhe\0llo\n" "" "woo"
    107123rm sed.commands
     124}
    108125
    109126# sed has funky behavior with newlines at the end of file.  Test lots of
     
    120137testing "sed cat plus empty file" "sed -e 's/nohit//' input -" "one\ntwo" \
    121138    "one\ntwo" ""
     139test x"$SKIP_KNOWN_BUGS" = x"" && {
    122140testing "sed append autoinserts newline" "sed -e '/woot/a woo' -" \
    123141    "woot\nwoo\n" "" "woot"
     142}
    124143testing "sed insert doesn't autoinsert newline" "sed -e '/woot/i woo' -" \
    125144    "woo\nwoot" "" "woot"
     
    137156    "sed -ne 's/woo/bang/p' input -" "a bang\nb bang" "a woo\nb woo" \
    138157    "c no\nd no"
     158test x"$SKIP_KNOWN_BUGS" = x"" && {
    139159testing "sed clusternewline" \
    140160    "sed -e '/one/a 111' -e '/two/i 222' -e p input -" \
    141161    "one\none\n111\n222\ntwo\ntwo" "one" "two"
     162}
    142163testing "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" \
    144165    "thzngy\nagaznXthzngy\nagazn" "thingy" "again"
    145166rm outputw
     
    163184#00000020  6f 75 72                                          |our|
    164185# which looks buggy to me.
    165 echo -ne "three\nfour" > input2
     186$ECHO -ne "three\nfour" > input2
    166187testing "sed match EOF inline" \
    167188    "sed -e '"'$i ook'"' -i input input2 && cat input input2" \
     
    175196
    176197# Jump to nonexistent label
    177 testing "sed nonexistent label" "sed -e 'b walrus' 2> /dev/null || echo yes" \
     198test 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
     201testing "sed nonexistent label" "sed -e 'b walrus' 2>/dev/null || echo yes" \
    178202    "yes\n" "" ""
     203}
    179204
    180205testing "sed backref from empty s uses range regex" \
     
    201226#   "" "12345"
    202227
     228# testing "description" "arguments" "result" "infile" "stdin"
     229
     230testing "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
     234testing "sed d does not break n,m matching" \
     235    "sed -n '1d;1,3p'" \
     236    "second\nthird\n" "" "first\nsecond\nthird\nfourth\n"
     237
     238testing "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
     242testing "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
     247testing "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.
     254testing "sed beginning (^) matches only once" \
     255    "sed 's,\(^/\|\)[^/][^/]*,>\0<,g'" \
     256    ">/usr</>lib<\n" "" \
     257    "/usr/lib\n"
     258
     259testing "sed c" \
     260    "sed 'crepl'" \
     261    "repl\nrepl\n" "" \
     262    "first\nsecond\n"
     263
     264testing "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
     269testing "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
     282testing "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
     286testing "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
    203293exit $FAILCOUNT
Note: See TracChangeset for help on using the changeset viewer.