diff options
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/grep.tests | 4 | ||||
-rwxr-xr-x | testsuite/mdev.tests | 10 | ||||
-rwxr-xr-x | testsuite/patch.tests | 74 | ||||
-rwxr-xr-x | testsuite/sed.tests | 21 |
4 files changed, 94 insertions, 15 deletions
diff --git a/testsuite/grep.tests b/testsuite/grep.tests index d4bf80d..e0135dc 100755 --- a/testsuite/grep.tests +++ b/testsuite/grep.tests @@ -98,5 +98,9 @@ testing "grep -o does not loop forever" \ 'grep -o "[^/]*$"' \ "test\n" \ "" "/var/test\n" +testing "grep -o does not loop forever on zero-length match" \ + 'grep -o "" | head -n1' \ + "" \ + "" "test\n" exit $FAILCOUNT diff --git a/testsuite/mdev.tests b/testsuite/mdev.tests index c375fc7..a46929b 100755 --- a/testsuite/mdev.tests +++ b/testsuite/mdev.tests @@ -38,6 +38,16 @@ brw-rw---- 1 0 0 8,0 sda SKIP= # continuing to use directory structure from prev test +optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME +testing "mdev deletes /block/sda" \ + "env - PATH=$PATH ACTION=remove DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -ln mdev.testdir/dev | $FILTER_LS" \ +"\ +" \ + "" "" +SKIP= + +# continuing to use directory structure from prev test rm -rf mdev.testdir/dev/* echo ".* 1:1 666" >mdev.testdir/etc/mdev.conf echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf diff --git a/testsuite/patch.tests b/testsuite/patch.tests index 749d936..e482304 100755 --- a/testsuite/patch.tests +++ b/testsuite/patch.tests @@ -1,13 +1,13 @@ #!/bin/sh # Copyright 2008 by Denys Vlasenko -# Licensed under GPL v2, see file LICENSE for details. +# Licensed under GPLv2, see file LICENSE in this source tree. . ./testing.sh -# testing "test name" "options" "expected result" "file input" "stdin" +# testing "test name" "command(s)" "expected result" "file input" "stdin" testing "patch with old_file == new_file" \ - 'patch; echo $?; cat input' \ + 'patch 2>&1; echo $?; cat input' \ "\ patching file input 0 @@ -29,7 +29,7 @@ zxc " \ testing "patch with nonexistent old_file" \ - 'patch; echo $?; cat input' \ + 'patch 2>&1; echo $?; cat input' \ "\ patching file input 0 @@ -51,7 +51,7 @@ zxc " \ testing "patch -R with nonexistent old_file" \ - 'patch -R; echo $?; cat input' \ + 'patch -R 2>&1; echo $?; cat input' \ "\ patching file input 0 @@ -75,9 +75,12 @@ zxc testing "patch detects already applied hunk" \ 'patch 2>&1; echo $?; cat input' \ "\ +Possibly reversed hunk 1 at 2 +Hunk 1 FAILED 1/1. + abc ++def + 123 patching file input -patch: hunk #1 FAILED at 1 -patch: 1 out of 1 hunk FAILED 1 abc def @@ -97,13 +100,15 @@ def 123 " \ -# Currently fails (erroneously appends second "456" line): -false && testing "patch detects already applied hunk" \ +testing "patch detects already applied hunk at the EOF" \ 'patch 2>&1; echo $?; cat input' \ "\ +Possibly reversed hunk 1 at 3 +Hunk 1 FAILED 1/1. + abc + 123 ++456 patching file input -patch: hunk #1 FAILED at 2 -patch: 1 out of 1 hunk FAILED 1 abc 123 @@ -123,6 +128,53 @@ abc +456 " \ +# testing "test name" "command(s)" "expected result" "file input" "stdin" +testing "patch -N ignores already applied hunk" \ + 'patch -N 2>&1; echo $?; cat input' \ +"\ +patching file input +0 +abc +def +123 +" \ +"\ +abc +def +123 +" \ +"\ +--- input ++++ input +@@ -1,2 +1,3 @@ + abc ++def + 123 +" \ + +# testing "test name" "command(s)" "expected result" "file input" "stdin" +testing "patch FILE PATCH" \ + 'cat >a.patch; patch input a.patch 2>&1; echo $?; cat input; rm a.patch' \ +"\ +patching file input +0 +abc +def +123 +" \ +"\ +abc +123 +" \ +"\ +--- foo.old ++++ foo +@@ -1,2 +1,3 @@ + abc ++def + 123 +" \ + rm input.orig 2>/dev/null exit $FAILCOUNT diff --git a/testsuite/sed.tests b/testsuite/sed.tests index 3301a25..61551e3 100755 --- a/testsuite/sed.tests +++ b/testsuite/sed.tests @@ -80,10 +80,18 @@ test x"$SKIP_KNOWN_BUGS" = x"" && { # Query: how does this interact with no newline at EOF? testing "sed n (flushes pattern space, terminates early)" "sed -e 'n;p'" \ "a\nb\nb\nc\n" "" "a\nb\nc\n" -# N does _not_ flush pattern space, therefore c is still in there @ script end. -testing "sed N (doesn't flush pattern space when terminating)" "sed -e 'N;p'" \ - "a\nb\na\nb\nc\n" "" "a\nb\nc\n" } +# non-GNU sed: N does _not_ flush pattern space, therefore c is eaten @ script end +# GNU sed: N flushes pattern space, therefore c is printed too @ script end +testing "sed N (flushes pattern space (GNU behavior))" "sed -e 'N;p'" \ + "a\nb\na\nb\nc\n" "" "a\nb\nc\n" + +testing "sed N test2" "sed ':a;N;s/\n/ /;ta'" \ + "a b c\n" "" "a\nb\nc\n" + +testing "sed N test3" "sed 'N;s/\n/ /'" \ + "a b\nc\n" "" "a\nb\nc\n" + testing "sed address match newline" 'sed "/b/N;/b\\nc/i woo"' \ "a\nwoo\nb\nc\nd\n" "" "a\nb\nc\nd\n" @@ -270,11 +278,16 @@ testing "sed a cmd ended by double backslash" \ | two \\ ' -# fisrt three lines are deleted; 4th line is matched and printed by "2,3" and by "4" ranges +# first three lines are deleted; 4th line is matched and printed by "2,3" and by "4" ranges testing "sed with N skipping lines past ranges on next cmds" \ "sed -n '1{N;N;d};1p;2,3p;3p;4p'" \ "4\n4\n" "" "1\n2\n3\n4\n" +testing "sed -i with address modifies all files, not only first" \ + "cp input input2; sed -i -e '1s/foo/bar/' input input2 && cat input input2; rm input2" \ + "bar\nbar\n" "foo\n" "" + + # testing "description" "arguments" "result" "infile" "stdin" exit $FAILCOUNT |