summaryrefslogtreecommitdiff
path: root/busybox/testsuite/sed
diff options
context:
space:
mode:
Diffstat (limited to 'busybox/testsuite/sed')
-rw-r--r--busybox/testsuite/sed/sed-accepts-blanks-before-command1
-rw-r--r--busybox/testsuite/sed/sed-aic-commands134
-rw-r--r--busybox/testsuite/sed/sed-append-hold-space-to-pattern-space13
-rw-r--r--busybox/testsuite/sed/sed-append-next-line19
-rw-r--r--busybox/testsuite/sed/sed-branch1
-rw-r--r--busybox/testsuite/sed/sed-branch-conditional15
-rw-r--r--busybox/testsuite/sed/sed-branch-conditional211
-rw-r--r--busybox/testsuite/sed/sed-branch-no-label1
-rw-r--r--busybox/testsuite/sed/sed-chains-substs1
-rw-r--r--busybox/testsuite/sed/sed-chains-substs21
-rw-r--r--busybox/testsuite/sed/sed-does-not-substitute-in-deleted-line2
-rw-r--r--busybox/testsuite/sed/sed-handles-embedded-slashes1
-rw-r--r--busybox/testsuite/sed/sed-handles-empty-lines1
-rw-r--r--busybox/testsuite/sed/sed-handles-unsatisfied-backrefs6
-rw-r--r--busybox/testsuite/sed/sed-next-line12
-rw-r--r--busybox/testsuite/sed/sed-prints-line-once-for-multiple-substs4
-rw-r--r--busybox/testsuite/sed/sed-recurses-properly1
-rw-r--r--busybox/testsuite/sed/sed-regex-match-newline10
-rw-r--r--busybox/testsuite/sed/sed-splits-edit-commands-on-command-line9
-rw-r--r--busybox/testsuite/sed/sed-subst-subprint9
-rw-r--r--busybox/testsuite/sed/sed-write-to-stdout10
21 files changed, 262 insertions, 0 deletions
diff --git a/busybox/testsuite/sed/sed-accepts-blanks-before-command b/busybox/testsuite/sed/sed-accepts-blanks-before-command
new file mode 100644
index 0000000..9597c2f
--- /dev/null
+++ b/busybox/testsuite/sed/sed-accepts-blanks-before-command
@@ -0,0 +1 @@
+busybox sed -e '1 d' </dev/null
diff --git a/busybox/testsuite/sed/sed-aic-commands b/busybox/testsuite/sed/sed-aic-commands
new file mode 100644
index 0000000..b41c14a
--- /dev/null
+++ b/busybox/testsuite/sed/sed-aic-commands
@@ -0,0 +1,134 @@
+cat - >input <<EOF
+2i\\
+before 2
+5c\\
+Change 5
+10a\\
+After 10
+22i\\
+before 22\\
+Continued
+25c\\
+Change 25\\
+Continued
+20a\\
+After 20\\
+Continued
+ 32i\\
+before 32\\
+Continued 1\\
+Continued 2\\
+Continued 3
+ 35c\\
+Change 35\\
+Continued 1\\
+Continued 2\\
+Continued 3
+ 30a\\
+After 30\\
+Continued 1\\
+Continued 2\\
+Continued 3
+EOF
+busybox sed -f input >output <<EOF
+ 1 y
+ 2 y
+ 3 y
+ 4 y
+ 5 y
+ 6 y
+ 7 y
+ 8 y
+ 9 y
+ 10 y
+ 11 y
+ 12 y
+ 13 y
+ 14 y
+ 15 y
+ 16 y
+ 17 y
+ 18 y
+ 19 y
+ 20 y
+ 21 y
+ 22 y
+ 23 y
+ 24 y
+ 25 y
+ 26 y
+ 27 y
+ 28 y
+ 29 y
+ 30 y
+ 31 y
+ 32 y
+ 33 y
+ 34 y
+ 35 y
+ 36 y
+ 37 y
+ 38 y
+ 39 y
+ 40 y
+EOF
+cmp -s output - <<EOF
+ 1 y
+before 2
+ 2 y
+ 3 y
+ 4 y
+Change 5
+ 6 y
+ 7 y
+ 8 y
+ 9 y
+ 10 y
+After 10
+ 11 y
+ 12 y
+ 13 y
+ 14 y
+ 15 y
+ 16 y
+ 17 y
+ 18 y
+ 19 y
+ 20 y
+After 20
+Continued
+ 21 y
+before 22
+Continued
+ 22 y
+ 23 y
+ 24 y
+Change 25
+Continued
+ 26 y
+ 27 y
+ 28 y
+ 29 y
+ 30 y
+After 30
+Continued 1
+Continued 2
+Continued 3
+ 31 y
+before 32
+Continued 1
+Continued 2
+Continued 3
+ 32 y
+ 33 y
+ 34 y
+Change 35
+Continued 1
+Continued 2
+Continued 3
+ 36 y
+ 37 y
+ 38 y
+ 39 y
+ 40 y
+EOF
diff --git a/busybox/testsuite/sed/sed-append-hold-space-to-pattern-space b/busybox/testsuite/sed/sed-append-hold-space-to-pattern-space
new file mode 100644
index 0000000..6dda80f
--- /dev/null
+++ b/busybox/testsuite/sed/sed-append-hold-space-to-pattern-space
@@ -0,0 +1,13 @@
+busybox sed 'G'>output <<EOF
+a
+b
+c
+EOF
+cmp -s output - <<EOF
+a
+
+b
+
+c
+
+EOF
diff --git a/busybox/testsuite/sed/sed-append-next-line b/busybox/testsuite/sed/sed-append-next-line
new file mode 100644
index 0000000..0621a31
--- /dev/null
+++ b/busybox/testsuite/sed/sed-append-next-line
@@ -0,0 +1,19 @@
+# This will fail if CONFIG_FEATURE_SED_GNU_COMPATABILITY is defined
+busybox sed 'N;p'>output <<EOF
+a
+b
+c
+EOF
+
+set +e
+cmp -s output - <<EOF
+a
+b
+a
+b
+c
+EOF
+if [ $? != 0 ] ; then
+ exit 0;
+fi
+exit 1;
diff --git a/busybox/testsuite/sed/sed-branch b/busybox/testsuite/sed/sed-branch
new file mode 100644
index 0000000..4167569
--- /dev/null
+++ b/busybox/testsuite/sed/sed-branch
@@ -0,0 +1 @@
+test "$(echo foo | busybox sed 'b one;p;: one')" = foo
diff --git a/busybox/testsuite/sed/sed-branch-conditional b/busybox/testsuite/sed/sed-branch-conditional
new file mode 100644
index 0000000..47d0a5f
--- /dev/null
+++ b/busybox/testsuite/sed/sed-branch-conditional
@@ -0,0 +1,15 @@
+busybox sed 's/a/1/;t one;p;: one;p'>output <<EOF
+a
+b
+c
+EOF
+cmp -s output - <<EOF
+1
+1
+b
+b
+b
+c
+c
+c
+EOF
diff --git a/busybox/testsuite/sed/sed-branch-conditional2 b/busybox/testsuite/sed/sed-branch-conditional2
new file mode 100644
index 0000000..f4b11f0
--- /dev/null
+++ b/busybox/testsuite/sed/sed-branch-conditional2
@@ -0,0 +1,11 @@
+#XFAIL
+busybox sed 's/a/b/;:loop;t loop'>output <<EOF
+a
+b
+c
+EOF
+cmp -s output - <<EOF
+b
+b
+c
+EOF
diff --git a/busybox/testsuite/sed/sed-branch-no-label b/busybox/testsuite/sed/sed-branch-no-label
new file mode 100644
index 0000000..446c1bc
--- /dev/null
+++ b/busybox/testsuite/sed/sed-branch-no-label
@@ -0,0 +1 @@
+test "$(echo foo | busybox sed 'b;p')" = foo
diff --git a/busybox/testsuite/sed/sed-chains-substs b/busybox/testsuite/sed/sed-chains-substs
new file mode 100644
index 0000000..266936a
--- /dev/null
+++ b/busybox/testsuite/sed/sed-chains-substs
@@ -0,0 +1 @@
+test "$(echo foo | busybox sed -e s/foo/bar/ -e s/bar/baz/)" = baz
diff --git a/busybox/testsuite/sed/sed-chains-substs2 b/busybox/testsuite/sed/sed-chains-substs2
new file mode 100644
index 0000000..90568f6
--- /dev/null
+++ b/busybox/testsuite/sed/sed-chains-substs2
@@ -0,0 +1 @@
+test x"$(echo foo | busybox -n sed -e s/foo/bar/ -e s/foo/baz/)" = x
diff --git a/busybox/testsuite/sed/sed-does-not-substitute-in-deleted-line b/busybox/testsuite/sed/sed-does-not-substitute-in-deleted-line
new file mode 100644
index 0000000..6f106e1
--- /dev/null
+++ b/busybox/testsuite/sed/sed-does-not-substitute-in-deleted-line
@@ -0,0 +1,2 @@
+echo foo | busybox sed -e /foo/d -e s/foo/bar/ >foo
+cmp foo /dev/null
diff --git a/busybox/testsuite/sed/sed-handles-embedded-slashes b/busybox/testsuite/sed/sed-handles-embedded-slashes
new file mode 100644
index 0000000..cc28761
--- /dev/null
+++ b/busybox/testsuite/sed/sed-handles-embedded-slashes
@@ -0,0 +1 @@
+test "$(echo fu/bar | busybox sed -e 's/[/]//')" = fubar
diff --git a/busybox/testsuite/sed/sed-handles-empty-lines b/busybox/testsuite/sed/sed-handles-empty-lines
new file mode 100644
index 0000000..2bb8f04
--- /dev/null
+++ b/busybox/testsuite/sed/sed-handles-empty-lines
@@ -0,0 +1 @@
+test `echo | busybox sed -e 's/$/@/'` = @
diff --git a/busybox/testsuite/sed/sed-handles-unsatisfied-backrefs b/busybox/testsuite/sed/sed-handles-unsatisfied-backrefs
new file mode 100644
index 0000000..61bff88
--- /dev/null
+++ b/busybox/testsuite/sed/sed-handles-unsatisfied-backrefs
@@ -0,0 +1,6 @@
+busybox sed -e 's/.*root=/\1/' >output <<EOF
+BOOT_IMAGE=vmlinuz root=/dev/hda5 initrd=init1
+EOF
+cmp -s output - <<EOF
+/dev/hda5 initrd=init1
+EOF
diff --git a/busybox/testsuite/sed/sed-next-line b/busybox/testsuite/sed/sed-next-line
new file mode 100644
index 0000000..38fe20c
--- /dev/null
+++ b/busybox/testsuite/sed/sed-next-line
@@ -0,0 +1,12 @@
+busybox sed 'n;p'>output <<EOF
+a
+b
+c
+EOF
+cmp -s output - <<EOF
+a
+b
+b
+c
+c
+EOF
diff --git a/busybox/testsuite/sed/sed-prints-line-once-for-multiple-substs b/busybox/testsuite/sed/sed-prints-line-once-for-multiple-substs
new file mode 100644
index 0000000..ba8955d
--- /dev/null
+++ b/busybox/testsuite/sed/sed-prints-line-once-for-multiple-substs
@@ -0,0 +1,4 @@
+busybox sed -e s/1/2/g -e s/3/4/g >output <<EOF
+1
+EOF
+echo 2 | cmp -s output -
diff --git a/busybox/testsuite/sed/sed-recurses-properly b/busybox/testsuite/sed/sed-recurses-properly
new file mode 100644
index 0000000..a02667b
--- /dev/null
+++ b/busybox/testsuite/sed/sed-recurses-properly
@@ -0,0 +1 @@
+test "`echo '12345' | busybox sed -e 's/[[:space:]]*/,/g')` = ',1,2,3,4,5,'"
diff --git a/busybox/testsuite/sed/sed-regex-match-newline b/busybox/testsuite/sed/sed-regex-match-newline
new file mode 100644
index 0000000..1057e17
--- /dev/null
+++ b/busybox/testsuite/sed/sed-regex-match-newline
@@ -0,0 +1,10 @@
+# FEATURE: CONFIG_FEATURE_SED_EMBEDED_NEWLINE
+busybox sed -n 'N;/a\nb/p'>output <<EOF
+a
+b
+c
+EOF
+cmp -s output - <<EOF
+a
+b
+EOF
diff --git a/busybox/testsuite/sed/sed-splits-edit-commands-on-command-line b/busybox/testsuite/sed/sed-splits-edit-commands-on-command-line
new file mode 100644
index 0000000..6421fa5
--- /dev/null
+++ b/busybox/testsuite/sed/sed-splits-edit-commands-on-command-line
@@ -0,0 +1,9 @@
+echo 2 | busybox sed -e 'i\
+1
+a\
+3' > output
+cmp output - <<EOF
+1
+2
+3
+EOF
diff --git a/busybox/testsuite/sed/sed-subst-subprint b/busybox/testsuite/sed/sed-subst-subprint
new file mode 100644
index 0000000..24f8bad
--- /dev/null
+++ b/busybox/testsuite/sed/sed-subst-subprint
@@ -0,0 +1,9 @@
+busybox sed 's/foo/bar/p'>output <<EOF
+foo
+bar
+EOF
+cmp -s output - <<EOF
+bar
+bar
+bar
+EOF
diff --git a/busybox/testsuite/sed/sed-write-to-stdout b/busybox/testsuite/sed/sed-write-to-stdout
new file mode 100644
index 0000000..95b4d72
--- /dev/null
+++ b/busybox/testsuite/sed/sed-write-to-stdout
@@ -0,0 +1,10 @@
+busybox sed -n 'N;P;p'>output <<EOF
+a
+b
+c
+EOF
+cmp -s output - <<EOF
+a
+a
+b
+EOF