Kill off the old 'tests' stuff. Write a ton of new tests for the

'testsuite' dir.  Fix a bunch of broken tests.  Fix the testsuite
'runtest' script so it actually reports all failures and provides
meaningful feedback.
 -Erik
This commit is contained in:
Eric Andersen
2004-04-06 11:10:30 +00:00
parent 39396b95fc
commit 650fe63467
83 changed files with 316 additions and 1570 deletions

View File

@@ -0,0 +1,2 @@
test x$(basename $(pwd)) = x$(busybox basename $(pwd))

View File

@@ -1,3 +1,9 @@
echo foo >foo
echo bar >bar
! busybox cmp -s foo bar
set +e
busybox cmp -s foo bar
if [ $? != 0 ] ; then
exit 0;
fi
exit 1;

View File

@@ -8,7 +8,7 @@ busybox cp -a file1 file2 link1 dir1 there
test -f there/file1
test -f there/file2
test ! -s there/dir1/file3
test -l there/link1
test `readlink there/link1` = "file2"
test ! file3 -ot there/dir1/file3
test ! file3 -nt there/dir1/file3
test -L there/link1
test xfile2 = x`readlink there/link1`
test ! dir1/file3 -ot there/dir1/file3
test ! dir1/file3 -nt there/dir1/file3

View File

@@ -2,4 +2,4 @@ touch foo
ln -s foo bar
busybox cp -a bar baz
test -L baz
test `readlink baz` = "foo"
test xfoo = x`readlink baz`

View File

@@ -7,5 +7,5 @@ busybox cp -d file1 file2 file3 link1 there
test -f there/file1
test -f there/file2
test ! -s there/file3
test -l there/link1
test `readlink there/link1` = "file2"
test -L there/link1
test xfile2 = x`readlink there/link1`

View File

@@ -1,4 +1,6 @@
touch foo
chmod a-r foo
set +e
busybox cp foo bar
set -e
test ! -f bar

View File

@@ -2,4 +2,4 @@ touch foo
ln -s foo bar
busybox cp -d bar baz
test -L baz
test `readlink baz` = "foo"
test xfoo = x`readlink baz`

View File

@@ -0,0 +1,2 @@
test x"`date -R`" = x"`busybox date -R`"

View File

@@ -0,0 +1 @@
test x"`date +%d/%m/%y`" = x"`busybox date +%d/%m/%y`"

View File

@@ -0,0 +1,2 @@
test x"`date -u`" = x"`busybox date -u`"

View File

@@ -0,0 +1,2 @@
test x"`date`" = x"`busybox date`"

View File

@@ -0,0 +1,2 @@
test x$(dirname $(pwd)) = x$(busybox dirname $(pwd))

3
testsuite/du/du-h-works Normal file
View File

@@ -0,0 +1,3 @@
du -h .. > logfile.gnu
busybox du -h .. > logfile.bb
cmp logfile.gnu logfile.bb

3
testsuite/du/du-k-works Normal file
View File

@@ -0,0 +1,3 @@
du -k .. > logfile.gnu
busybox du -k .. > logfile.bb
cmp logfile.gnu logfile.bb

3
testsuite/du/du-l-works Normal file
View File

@@ -0,0 +1,3 @@
du -l .. > logfile.gnu
busybox du -l .. > logfile.bb
cmp logfile.gnu logfile.bb

3
testsuite/du/du-m-works Normal file
View File

@@ -0,0 +1,3 @@
du -m .. > logfile.gnu
busybox du -m .. > logfile.bb
cmp logfile.gnu logfile.bb

3
testsuite/du/du-s-works Normal file
View File

@@ -0,0 +1,3 @@
du -s .. > logfile.gnu
busybox du -s .. > logfile.bb
cmp logfile.gnu logfile.bb

3
testsuite/du/du-works Normal file
View File

@@ -0,0 +1,3 @@
du .. > logfile.gnu
busybox du .. > logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -1 +1 @@
test `busybox echo fubar` = fubar
test xfubar = x`busybox echo fubar`

59
testsuite/expr/expr-works Normal file
View File

@@ -0,0 +1,59 @@
# busybox expr
busybox expr 1 \| 1
busybox expr 1 \| 0
busybox expr 0 \| 1
busybox expr 1 \& 1
busybox expr 0 \< 1
busybox expr 1 \> 0
busybox expr 0 \<= 1
busybox expr 1 \<= 1
busybox expr 1 \>= 0
busybox expr 1 \>= 1
busybox expr 1 + 2
busybox expr 2 - 1
busybox expr 2 \* 3
busybox expr 12 / 2
busybox expr 12 % 5
set +e
busybox expr 0 \| 0
if [ $? != 1 ] ; then
exit 1;
fi;
busybox expr 1 \& 0
if [ $? != 1 ] ; then
exit 1;
fi;
busybox expr 0 \& 1
if [ $? != 1 ] ; then
exit 1;
fi;
busybox expr 0 \& 0
if [ $? != 1 ] ; then
exit 1;
fi;
busybox expr 1 \< 0
if [ $? != 1 ] ; then
exit 1;
fi;
busybox expr 0 \> 1
if [ $? != 1 ] ; then
exit 1;
fi;
busybox expr 1 \<= 0
if [ $? != 1 ] ; then
exit 1;
fi;
busybox expr 0 \>= 1
if [ $? != 1 ] ; then
exit 1;
fi;

View File

@@ -1,2 +1,8 @@
# XFAIL
set +e
echo -e '\0' | busybox grep .
if [ $? != 0 ] ; then
exit 0;
fi
exit 1;

View File

@@ -0,0 +1,3 @@
head -n 2 ../README > logfile.gnu
busybox head -n 2 ../README > logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -0,0 +1,3 @@
head ../README > logfile.gnu
busybox head ../README > logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -0,0 +1,2 @@
test x$(hostid) = x$(busybox hostid)

View File

@@ -0,0 +1,2 @@
test x$(hostname -d) = x$(busybox hostname -d)

View File

@@ -0,0 +1,2 @@
test x$(hostname -i) = x$(busybox hostname -i)

View File

@@ -0,0 +1 @@
test x$(hostname -s) = x$(busybox hostname -s)

View File

@@ -0,0 +1 @@
test x$(hostname) = x$(busybox hostname)

1
testsuite/id/id-g-works Normal file
View File

@@ -0,0 +1 @@
test x$(id -g) = x$(busybox id -g)

1
testsuite/id/id-u-works Normal file
View File

@@ -0,0 +1 @@
test x$(id -u) = x$(busybox id -u)

1
testsuite/id/id-un-works Normal file
View File

@@ -0,0 +1 @@
test x$(id -un) = x$(busybox id -un)

1
testsuite/id/id-ur-works Normal file
View File

@@ -0,0 +1 @@
test x$(id -ur) = x$(busybox id -ur)

View File

@@ -0,0 +1,4 @@
echo file number one > file1
busybox ln file1 link1
test -f file1
test -f link1

View File

@@ -0,0 +1,4 @@
echo file number one > file1
busybox ln -s file1 link1
test -L link1
test xfile1 = x`readlink link1`

View File

@@ -0,0 +1,5 @@
echo file number one > file1
echo file number two > link1
busybox ln -f file1 link1
test -f file1
test -f link1

View File

@@ -0,0 +1,5 @@
echo file number one > file1
echo file number two > link1
busybox ln -f -s file1 link1
test -L link1
test xfile1 = x`readlink link1`

View File

@@ -0,0 +1,8 @@
echo file number one > file1
echo file number two > link1
set +e
busybox ln file1 link1
if [ $? != 0 ] ; then
exit 0;
fi
exit 1;

View File

@@ -0,0 +1,9 @@
echo file number one > file1
echo file number two > link1
set +e
busybox ln -s file1 link1
if [ $? != 0 ] ; then
exit 0;
fi
exit 1;

3
testsuite/ls/ls-1-works Normal file
View File

@@ -0,0 +1,3 @@
ls -1 .. > logfile.gnu
busybox ls -1 .. > logfile.bb
cmp logfile.gnu logfile.bb

3
testsuite/ls/ls-h-works Normal file
View File

@@ -0,0 +1,3 @@
ls -h .. > logfile.gnu
busybox ls -h .. > logfile.bb
cmp logfile.gnu logfile.bb

3
testsuite/ls/ls-l-works Normal file
View File

@@ -0,0 +1,3 @@
ls -l .. > logfile.gnu
busybox ls -l .. > logfile.bb
cmp logfile.gnu logfile.bb

3
testsuite/ls/ls-s-works Normal file
View File

@@ -0,0 +1,3 @@
ls -1s .. > logfile.gnu
busybox ls -1s .. > logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -0,0 +1,16 @@
echo file number one > file1
echo file number two > file2
ln -s file2 link1
mkdir dir1
touch --date='Sat Jan 29 21:24:08 PST 2000' dir1/file3
mkdir there
busybox mv file1 file2 link1 dir1 there
test -f there/file1
test -f there/file2
test -f there/dir1/file3
test -L there/link1
test xfile2 = x`readlink there/link1`
test ! -e file1
test ! -e file2
test ! -e link1
test ! -e dir1/file3

View File

@@ -0,0 +1,4 @@
touch foo
ln -s foo bar
busybox mv bar baz
test -f baz

View File

@@ -0,0 +1,4 @@
touch foo
busybox mv foo bar
test ! -e foo
test -f bar

View File

@@ -0,0 +1,4 @@
touch foo
ln foo bar
busybox mv bar baz
test ! -f bar -a -f baz

View File

@@ -0,0 +1,4 @@
dd if=/dev/zero of=foo seek=10k count=1 2>/dev/null
busybox mv foo bar
test ! -e foo
test -f bar

View File

@@ -0,0 +1,4 @@
echo I WANT > foo
busybox mv foo bar
test ! -e foo
test -f bar

View File

@@ -0,0 +1,6 @@
touch foo
ln -s foo bar
busybox mv bar baz
test -f foo
test ! -e bar
test -L baz

View File

@@ -0,0 +1,5 @@
touch foo
chmod a-r foo
busybox mv foo bar
test ! -e foo
test -f bar

View File

@@ -0,0 +1,6 @@
# FEATURE: CONFIG_FEATURE_PRESERVE_HARDLINKS
touch foo
ln foo bar
mkdir baz
busybox mv foo bar baz
test baz/foo -ef baz/bar

View File

@@ -0,0 +1,5 @@
touch foo
ln -s foo bar
busybox mv bar baz
test -L baz
test xfoo = x`readlink baz`

View File

@@ -0,0 +1,23 @@
echo file number one > file1
echo file number two > file2
ln -s file2 link1
mkdir dir1
touch --date='Sat Jan 29 21:24:08 PST 2000' dir1/file3
mkdir there
busybox mv file1 file2 link1 dir1 there
test -f there/file1
test -f there/file2
test -f there/dir1/file3
test -L there/link1
test xfile2 = x`readlink there/link1`
test ! -e file1
test ! -e file2
test ! -e link1
test ! -e dir1/file3
set +e
busybox mv there there/dir1
if [ $? != 0 ] ; then
exit 0;
fi
exit 1;

View File

@@ -0,0 +1,4 @@
touch foo
busybox mv foo bar
test ! -e foo
test -f bar

View File

@@ -1 +1 @@
test `pwd` = `busybox pwd`
test $(pwd) = $(busybox pwd)

View File

@@ -2,37 +2,19 @@
PATH=$(dirname $(pwd)):$PATH
show_result ()
{
local resolution=$1
local testcase=$2
local status=0
if [ $resolution = XPASS -o $resolution = FAIL ]; then
status=1
fi
if [ "$verbose" -o $status -eq 1 ]; then
echo "$resolution: $testcase"
fi
return $status
}
run_applet_testcase ()
{
local applet=$1
local testcase=$2
local status=0
local X=
local RES=
local uc_applet=$(echo $applet | tr a-z A-Z)
local testname=$(basename $testcase)
if grep -q "^# CONFIG_${uc_applet} is not set$" ../.config; then
show_result UNTESTED $testname
echo UNTESTED: $testname
return 0
fi
@@ -40,15 +22,11 @@ run_applet_testcase ()
local feature=`sed -ne 's/^# FEATURE: //p' $testcase`
if grep -q "^# ${feature} is not set$" ../.config; then
show_result UNTESTED $testname
echo UNTESTED: $testname
return 0
fi
fi
if grep -q "^# XFAIL$" $testcase; then
X=X
fi
rm -rf tmp
mkdir -p tmp
pushd tmp >/dev/null
@@ -56,14 +34,14 @@ run_applet_testcase ()
sh -x -e ../$testcase >.logfile.txt 2>&1
if [ $? != 0 ] ; then
show_result ${X}FAIL $testname
if [ "$verbose" == 1 ]; then
echo FAIL: $testname
if [ "$verbose" = 1 ]; then
cat .logfile.txt
exit 1;
#exit 1;
fi;
status=$?
else
show_result ${X}PASS $testname
echo PASS: $testname
rm -f .logfile.txt
status=$?
fi

View File

@@ -1,10 +1,11 @@
# XFAIL
# 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
@@ -12,3 +13,7 @@ a
b
c
EOF
if [ $? != 0 ] ; then
exit 0;
fi
exit 1;

View File

@@ -0,0 +1,3 @@
sort -n ../README > logfile.gnu
busybox sort -n ../README > logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -0,0 +1,3 @@
sort -r ../README > logfile.gnu
busybox sort -r ../README > logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -0,0 +1,3 @@
sort ../README > logfile.gnu
busybox sort ../README > logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -1,8 +1,9 @@
rm -f foo bar
strings -af ../../busybox > foo
busybox strings -af ../../busybox > bar
set +e
test ! -f foo -a -f bar
if [ $? = 0 ] ; then
diff -q foo bar
fi;
set -e
diff -q foo bar
fi

View File

@@ -0,0 +1,3 @@
tail -n 2 ../README > logfile.gnu
busybox tail -n 2 ../README > logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -0,0 +1,3 @@
tail -n 2 ../README > logfile.gnu
busybox tail -n 2 ../README > logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -1,5 +1,6 @@
touch foo bar
tar cf foo.tar foo bar
rm foo bar
busybox tar xf foo.tar
busybox tar -xf foo.tar
test -f foo -a -f bar
exit 99;

4
testsuite/tr/tr-d-works Normal file
View File

@@ -0,0 +1,4 @@
echo testing | tr -d aeiou > logfile.gnu
echo testing | busybox tr -d aeiou > logfile.bb
cmp logfile.gnu logfile.bb

1
testsuite/tr/tr-non-gnu Normal file
View File

@@ -0,0 +1 @@
echo fdhrnzvfu bffvsentr | busybox tr '[a-z]' '[n-z][a-m]'

9
testsuite/tr/tr-works Normal file
View File

@@ -0,0 +1,9 @@
echo "cbaab" | tr abc zyx > logfile.gnu
echo "TESTING A B C" | tr [A-Z] [a-z] >> logfile.gnu
echo abc[] | tr a[b AXB >> logfile.gnu
echo "cbaab" | busybox tr abc zyx > logfile.bb
echo "TESTING A B C" | busybox tr [A-Z] [a-z] >> logfile.bb
echo abc[] | busybox tr a[b AXB >> logfile.bb
cmp logfile.gnu logfile.bb

View File

@@ -0,0 +1,2 @@
busybox uptime

View File

@@ -1,6 +1,4 @@
saved_umask=$(umask)
umask 0
busybox uuencode foo </dev/null | head -n 1 | grep -q 666
status=$?
umask $saved_umask
return $status

View File

@@ -2,6 +2,3 @@ BUSYBOX=$(type -p busybox)
SAVED_PATH=$PATH
unset PATH
$BUSYBOX which ls
STATUS=$?
export PATH=$SAVED_PATH
return $STATUS

View File

@@ -0,0 +1,3 @@
find -name \*works -type f | xargs md5sum > logfile.gnu
find -name \*works -type f | busybox xargs md5sum > logfile.bb
diff -u logfile.gnu logfile.bb