Add a couple of regression tests for /bin/sh.

This commit is contained in:
stefanf 2005-09-04 11:59:59 +00:00
parent 4f6bd877d3
commit ce5d9c9b6d
36 changed files with 202 additions and 0 deletions

View File

@ -0,0 +1,4 @@
# $FreeBSD$
all:
sh regress.sh

View File

@ -0,0 +1,6 @@
# $FreeBSD$
set -e
unalias -a
alias foo=bar
alias

View File

@ -0,0 +1 @@
foo='bar'

View File

@ -0,0 +1,3 @@
# $FreeBSD$
unalias -a
alias foo

View File

@ -0,0 +1 @@
alias: foo not found

View File

@ -0,0 +1,21 @@
# $FreeBSD$
set -e
alias false=true
false
unalias false
false && exit 1
unalias false && exit 1
alias a1=foo a2=bar
unalias a1 a2
unalias a1 && exit 1
unalias a2 && exit 1
alias a2=bar
unalias a1 a2 && exit 1
alias a1=foo a2=bar
unalias -a
unalias a1 && exit 1
unalias a2 && exit 1
exit 0

View File

@ -0,0 +1,42 @@
# $FreeBSD$
echo '1..31'
COUNTER=1
do_test() {
local c
c=${COUNTER}
COUNTER=$((COUNTER+1))
sh $1 > tmp.stdout 2> tmp.stderr
if [ $? -ne $2 ]; then
echo "not ok ${c} - ${1} # wrong exit status"
rm tmp.stdout tmp.stderr
return
fi
for i in stdout stderr; do
if [ -f ${1}.${i} ]; then
if ! cmp -s tmp.${i} ${1}.${i}; then
echo "not ok ${c} - ${1} # wrong output on ${i}"
rm tmp.stdout tmp.stderr
return
fi
elif [ -s tmp.${i} ]; then
echo "not ok ${c} - ${1} # wrong output on ${i}"
rm tmp.stdout tmp.stderr
return
fi
done
echo "ok ${c} - ${1}"
rm tmp.stdout tmp.stderr
}
SUCCESS=$(find . -name "*.0")
for i in ${SUCCESS} ; do
do_test ${i} 0
done
FAILURE=$(find . -name "*.1")
for i in ${FAILURE} ; do
do_test ${i} 1
done

View File

@ -0,0 +1,6 @@
#!/bin/sh
# $FreeBSD$
cd `dirname $0`
sh regress.sh

View File

@ -0,0 +1,3 @@
# $FreeBSD$
set -e
true && true

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
true && false
exit 0

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
false && true
exit 0

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
false && false
exit 0

View File

@ -0,0 +1,3 @@
# $FreeBSD$
set -e
false &

View File

@ -0,0 +1,3 @@
# $FreeBSD$
set -e
true

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
false
exit 0

View File

@ -0,0 +1,5 @@
# $FreeBSD$
set -e
if false; then
elif false; then
fi

View File

@ -0,0 +1,5 @@
# $FreeBSD$
set -e
if false; then
elif false; false; then
fi

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
if false; then
fi

View File

@ -0,0 +1,7 @@
# $FreeBSD$
set -e
# PR 28852
if true; then
false && true
fi
exit 0

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
if false; false then
fi

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
! true
exit 0

View File

@ -0,0 +1,3 @@
# $FreeBSD$
set -e
! false

View File

@ -0,0 +1,3 @@
# $FreeBSD$
set -e
true || false

View File

@ -0,0 +1,3 @@
# $FreeBSD$
set -e
false || true

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
false || false
exit 0

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
true | false
exit 0

View File

@ -0,0 +1,3 @@
# $FreeBSD$
set -e
false | true

View File

@ -0,0 +1,11 @@
# $FreeBSD$
set -e
# PR 85267
f() {
false || return 1
return 0
}
f || true
exit 0

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
false; true
exit 0

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
true; false
exit 0

View File

@ -0,0 +1,3 @@
# $FreeBSD$
set -e
(true)

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
(false)
exit 0

View File

@ -0,0 +1,5 @@
# $FreeBSD$
set -e
until false; do
break
done

View File

@ -0,0 +1,5 @@
# $FreeBSD$
set -e
until false; false; do
break
done

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
while false; do
done

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -e
while false; false; do
done