From 4fbb9bb04dd9906c8cc484a0053e1efdff248909 Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 13 Sep 2015 14:24:12 +0000 Subject: [PATCH] MFC r268436,273243,278806,280920,286971: sh: Add various tests. These new tests from head pass with unmodified stable/10 sh. git-svn-id: svn://svn.freebsd.org/base/stable/10@287755 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- bin/sh/tests/expansion/Makefile | 4 ++++ bin/sh/tests/expansion/ifs5.0 | 4 ++++ bin/sh/tests/expansion/ifs6.0 | 6 ++++++ bin/sh/tests/expansion/ifs7.0 | 5 +++++ bin/sh/tests/expansion/pathname5.0 | 3 +++ bin/sh/tests/parameters/Makefile | 1 + bin/sh/tests/parameters/positional3.0 | 4 ++++ bin/sh/tests/parser/Makefile | 4 ++++ bin/sh/tests/parser/dollar-quote12.0 | 7 +++++++ bin/sh/tests/parser/line-cont1.0 | 16 ++++++++++++++++ bin/sh/tests/parser/line-cont2.0 | 4 ++++ bin/sh/tests/parser/line-cont3.0 | 7 +++++++ 12 files changed, 65 insertions(+) create mode 100644 bin/sh/tests/expansion/ifs5.0 create mode 100644 bin/sh/tests/expansion/ifs6.0 create mode 100644 bin/sh/tests/expansion/ifs7.0 create mode 100644 bin/sh/tests/expansion/pathname5.0 create mode 100644 bin/sh/tests/parameters/positional3.0 create mode 100644 bin/sh/tests/parser/dollar-quote12.0 create mode 100644 bin/sh/tests/parser/line-cont1.0 create mode 100644 bin/sh/tests/parser/line-cont2.0 create mode 100644 bin/sh/tests/parser/line-cont3.0 diff --git a/bin/sh/tests/expansion/Makefile b/bin/sh/tests/expansion/Makefile index 5b52efc8a..e62fea4f0 100644 --- a/bin/sh/tests/expansion/Makefile +++ b/bin/sh/tests/expansion/Makefile @@ -45,6 +45,9 @@ FILES+= ifs1.0 FILES+= ifs2.0 FILES+= ifs3.0 FILES+= ifs4.0 +FILES+= ifs5.0 +FILES+= ifs6.0 +FILES+= ifs7.0 FILES+= length1.0 FILES+= length2.0 FILES+= length3.0 @@ -59,6 +62,7 @@ FILES+= pathname1.0 FILES+= pathname2.0 FILES+= pathname3.0 FILES+= pathname4.0 +FILES+= pathname5.0 FILES+= plus-minus1.0 FILES+= plus-minus2.0 FILES+= plus-minus3.0 diff --git a/bin/sh/tests/expansion/ifs5.0 b/bin/sh/tests/expansion/ifs5.0 new file mode 100644 index 000000000..ab0e64662 --- /dev/null +++ b/bin/sh/tests/expansion/ifs5.0 @@ -0,0 +1,4 @@ +# $FreeBSD$ + +set -- $(echo a b c d) +[ "$#" = 4 ] diff --git a/bin/sh/tests/expansion/ifs6.0 b/bin/sh/tests/expansion/ifs6.0 new file mode 100644 index 000000000..be7794563 --- /dev/null +++ b/bin/sh/tests/expansion/ifs6.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +IFS=': ' +x=': :' +set -- $x +[ "$#|$1|$2|$3" = "2|||" ] diff --git a/bin/sh/tests/expansion/ifs7.0 b/bin/sh/tests/expansion/ifs7.0 new file mode 100644 index 000000000..0cc08348c --- /dev/null +++ b/bin/sh/tests/expansion/ifs7.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +IFS=2 +set -- $((123)) +[ "$#|$1|$2|$3" = "2|1|3|" ] diff --git a/bin/sh/tests/expansion/pathname5.0 b/bin/sh/tests/expansion/pathname5.0 new file mode 100644 index 000000000..bc278124d --- /dev/null +++ b/bin/sh/tests/expansion/pathname5.0 @@ -0,0 +1,3 @@ +# $FreeBSD$ + +[ `echo '/[e]tc'` = /etc ] diff --git a/bin/sh/tests/parameters/Makefile b/bin/sh/tests/parameters/Makefile index 982b1331b..e31b78f44 100644 --- a/bin/sh/tests/parameters/Makefile +++ b/bin/sh/tests/parameters/Makefile @@ -13,6 +13,7 @@ FILES+= optind1.0 FILES+= optind2.0 FILES+= positional1.0 FILES+= positional2.0 +FILES+= positional3.0 FILES+= positional5.0 FILES+= pwd1.0 FILES+= pwd2.0 diff --git a/bin/sh/tests/parameters/positional3.0 b/bin/sh/tests/parameters/positional3.0 new file mode 100644 index 000000000..1200469b4 --- /dev/null +++ b/bin/sh/tests/parameters/positional3.0 @@ -0,0 +1,4 @@ +# $FreeBSD$ + +r=$(${SH} -c 'echo ${01:+yes}${010:+yes}' '' a '' '' '' '' '' '' '' '' b) +[ "$r" = yesyes ] diff --git a/bin/sh/tests/parser/Makefile b/bin/sh/tests/parser/Makefile index 03650b1d2..b769a30fe 100644 --- a/bin/sh/tests/parser/Makefile +++ b/bin/sh/tests/parser/Makefile @@ -34,6 +34,7 @@ FILES+= dollar-quote8.0 FILES+= dollar-quote9.0 FILES+= dollar-quote10.0 FILES+= dollar-quote11.0 +FILES+= dollar-quote12.0 FILES+= empty-braces1.0 FILES+= empty-cmd1.0 FILES+= for1.0 @@ -52,6 +53,9 @@ FILES+= heredoc8.0 FILES+= heredoc9.0 FILES+= heredoc10.0 FILES+= heredoc11.0 +FILES+= line-cont1.0 +FILES+= line-cont2.0 +FILES+= line-cont3.0 FILES+= no-space1.0 FILES+= no-space2.0 FILES+= only-redir1.0 diff --git a/bin/sh/tests/parser/dollar-quote12.0 b/bin/sh/tests/parser/dollar-quote12.0 new file mode 100644 index 000000000..838e27cda --- /dev/null +++ b/bin/sh/tests/parser/dollar-quote12.0 @@ -0,0 +1,7 @@ +# $FreeBSD$ + +# \u without any digits at all remains invalid. +# Our choice is a parse error. + +v=$( (eval ": \$'\u'") 2>&1 >/dev/null) +[ $? -ne 0 ] && [ -n "$v" ] diff --git a/bin/sh/tests/parser/line-cont1.0 b/bin/sh/tests/parser/line-cont1.0 new file mode 100644 index 000000000..7ef5eba82 --- /dev/null +++ b/bin/sh/tests/parser/line-cont1.0 @@ -0,0 +1,16 @@ +# $FreeBSD$ + +i\ +f +t\ +r\ +u\ +e +t\ +h\ +e\ +n +: +\ +f\ +i diff --git a/bin/sh/tests/parser/line-cont2.0 b/bin/sh/tests/parser/line-cont2.0 new file mode 100644 index 000000000..9a293faf6 --- /dev/null +++ b/bin/sh/tests/parser/line-cont2.0 @@ -0,0 +1,4 @@ +# $FreeBSD$ + +[ "a\ +b" = ab ] diff --git a/bin/sh/tests/parser/line-cont3.0 b/bin/sh/tests/parser/line-cont3.0 new file mode 100644 index 000000000..09d3aa8bb --- /dev/null +++ b/bin/sh/tests/parser/line-cont3.0 @@ -0,0 +1,7 @@ +# $FreeBSD$ + +v=`printf %s 'a\ +b'` +w="`printf %s 'c\ +d'`" +[ "$v$w" = abcd ] -- 2.45.0