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

@ -1,16 +0,0 @@
cp
cp_*.bb
cp_*.gnu
cp_tests
date
df
du
ln
ln_*.bb
ln_*.gnu
ln_tests
mv
mv_*.bb
mv_*.gnu
mv_tests
syslog_test

View File

@ -1,36 +0,0 @@
# busybox/tests/Makefile - Run through all defined tests.
# ------------------------
# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> GPL
all:: message_header
message_header:
@echo
@echo BusyBox Test Suite.
@echo
(cd ..; tests/busybox.REGRESS.sh)
clean::
rm -f *.o
rm -f tester.log
distclean: clean
.PHONY: all clean distclean message_header
include $(wildcard *_tests.mk)
BBL := $(shell pushd .. >/dev/null && \
${MAKE} busybox.links >/dev/null && \
popd >/dev/null && \
cat ../busybox.links | \
sed -e 's,.*/\(.*\)$$,\1,')
../busybox:
cd .. && ${MAKE} busybox
${BBL}: ../busybox
rm -f $@
ln ../busybox $@
syslog_test: syslog_test.c

View File

@ -1,360 +0,0 @@
# cp_tests.mk - Set of test cases for busybox cp
# -------------
# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> GPL
#
# GNU `cp'
GCP = /bin/cp
# BusyBox `cp'
BCP = $(shell pwd)/cp
all:: cp_tests
clean:: cp_clean
cp_clean:
- rm -rf cp_tests cp_*.{gnu,bb} cp
# check_cp_dir_to_dir_wo_a removed from this list; see below
cp_tests: cp_clean cp check_exists check_simple_cp check_cp_symlnk \
check_cp_symlink_w_a check_cp_files_to_dir check_cp_files_to_dir_w_d \
check_cp_files_to_dir_w_p check_cp_files_to_dir_w_p_and_d \
check_cp_dir_to_dir_w_a \
check_cp_dir_to_dir_w_a_take_two
check_exists:
@echo;
@echo "No output from diff means busybox cp is functioning properly.";
@echo "Some tests might show timestamp differences that are Ok.";
@echo;
@echo Verify that busybox cp exists;
@echo ------------------------------;
[ -x ${BCP} ] || exit 0
@echo;
mkdir cp_tests;
check_simple_cp:
@echo Copy a file to a copy of the file;
@echo ------------------------------;
cd cp_tests; \
echo A file > afile; \
ls -l afile > ../cp_afile_afilecopy.gnu; \
${GCP} afile afilecopy; \
ls -l afile afilecopy >> ../cp_afile_afilecopy.gnu;
@echo;
rm -rf cp_tests/*;
@echo;
cd cp_tests; \
echo A file > afile; \
ls -l afile > ../cp_afile_afilecopy.bb; \
${BCP} afile afilecopy; \
ls -l afile afilecopy >> ../cp_afile_afilecopy.bb;
@echo;
@echo Might show timestamp differences.
-diff -u cp_afile_afilecopy.gnu cp_afile_afilecopy.bb;
@echo;
rm -rf cp_tests/*;
check_cp_symlnk:
@echo; echo Copy a file pointed to by a symlink;
@echo ------------------------------;
cd cp_tests; \
mkdir here there; \
echo A file > afile; \
cd here; \
ln -s ../afile .; \
@echo;
cd cp_tests; \
ls -lR . > ../cp_symlink.gnu; \
${GCP} here/afile there; \
ls -lR . >> ../cp_symlink.gnu;
@echo;
rm -rf cp_tests/there/*;
sleep 1;
@echo;
cd cp_tests; \
ls -lR . > ../cp_symlink.bb; \
${BCP} here/afile there; \
ls -lR . >> ../cp_symlink.bb;
@echo;
@echo Will show timestamp difference.
-diff -u cp_symlink.gnu cp_symlink.bb;
@echo;
rm -rf cp_tests/*
check_cp_symlink_w_a:
@echo; echo Copy a symlink, useing the -a switch.;
@echo ------------------------------;
cd cp_tests; \
echo A file > afile; \
mkdir here there; \
cd here; \
ln -s ../afile .
cd cp_tests; \
ls -lR . > ../cp_a_symlink.gnu; \
${GCP} -a here/afile there; \
ls -lR . >> ../cp_a_symlink.gnu;
@echo;
rm -rf cp_tests/there/*;
sleep 1;
@echo;
cd cp_tests; \
echo A file > afile; \
ls -lR . > ../cp_a_symlink.bb; \
${BCP} -a here/afile there; \
ls -lR . >> ../cp_a_symlink.bb;
@echo;
diff -u cp_a_symlink.gnu cp_a_symlink.bb;
@echo;
rm -rf cp_tests/*;
check_cp_files_to_dir:
# Copy a set of files to a directory.
@echo; echo Copy a set of files to a directory.;
@echo ------------------------------;
cd cp_tests; \
echo A file number one > afile1; \
echo A file number two, blah. > afile2; \
ln -s afile1 symlink1; \
mkdir there;
cd cp_tests; \
${GCP} afile1 afile2 symlink1 there/; \
ls -lR > ../cp_files_dir.gnu;
@echo;
rm -rf cp_tests/there/*;
@echo;
cd cp_tests; \
${BCP} afile1 afile2 symlink1 there/; \
ls -lR > ../cp_files_dir.bb;
@echo;
diff -u cp_files_dir.gnu cp_files_dir.bb;
@echo;
rm -rf cp_tests/*;
check_cp_files_to_dir_w_d:
# Copy a set of files to a directory with the -d switch.
@echo; echo Copy a set of files to a directory with the -d switch.;
@echo ------------------------------;
cd cp_tests; \
echo A file number one > afile1; \
echo A file number two, blah. > afile2; \
ln -s afile1 symlink1; \
mkdir there1; \
${GCP} -d afile1 afile2 symlink1 there1/; \
ls -lR > ../cp_d_files_dir.gnu;
@echo;
rm -rf cp_tests/{afile{1,2},symlink1,there1};
@echo;
cd cp_tests; \
echo A file number one > afile1; \
echo A file number two, blah. > afile2; \
ln -s afile1 symlink1; \
mkdir there1; \
${BCP} -d afile1 afile2 symlink1 there1/; \
ls -lR > ../cp_d_files_dir.bb;
@echo;
diff -u cp_d_files_dir.gnu cp_d_files_dir.bb;
@echo;
rm -rf cp_tests/{afile{1,2},symlink1,there1};
check_cp_files_to_dir_w_p:
# Copy a set of files to a directory with the -p switch.
@echo; echo Copy a set of files to a directory with the -p switch.;
@echo ------------------------------;
cd cp_tests; \
echo A file number one > afile1; \
echo A file number two, blah. > afile2; \
touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
ln -s afile1 symlink1; \
mkdir there1; \
${GCP} -p afile1 afile2 symlink1 there1/; \
ls -lR > ../cp_p_files_dir.gnu;
@echo;
rm -rf cp_tests/{afile{1,2},symlink1,there1};
@echo;
cd cp_tests; \
echo A file number one > afile1; \
echo A file number two, blah. > afile2; \
touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
ln -s afile1 symlink1; \
mkdir there1; \
${BCP} -p afile1 afile2 symlink1 there1/; \
ls -lR > ../cp_p_files_dir.bb;
@echo;
diff -u cp_p_files_dir.gnu cp_p_files_dir.bb;
@echo;
rm -rf cp_tests/{afile{1,2},symlink1,there1};
check_cp_files_to_dir_w_p_and_d:
@echo; echo Copy a set of files to a directory with -p and -d switches.
@echo ------------------------------;
cd cp_tests; \
echo A file number one > afile1; \
echo A file number two, blah. > afile2; \
touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
ln -s afile1 symlink1; \
mkdir there1; \
${GCP} -p -d afile1 afile2 symlink1 there1/; \
ls -lR > ../cp_pd_files_dir.gnu;
@echo;
rm -rf cp_tests/{afile{1,2},symlink1,there1};
@echo;
cd cp_tests; \
echo A file number one > afile1; \
echo A file number two, blah. > afile2; \
touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
ln -s afile1 symlink1; \
mkdir there1; \
${BCP} -p -d afile1 afile2 symlink1 there1/; \
ls -lR > ../cp_pd_files_dir.bb;
@echo;
diff -u cp_pd_files_dir.gnu cp_pd_files_dir.bb;
@echo;
rm -rf cp_tests/{afile{1,2},symlink1,there1};
# This test doesn't work any more; gnu cp now _does_ copy a directory
# to a subdirectory of itself. What's worse, that "feature" has no
# (documented) way to be disabled with command line switches.
# It's not obvious that busybox cp should mimic this behavior.
# For now, this test is removed from the cp_tests list, above.
check_cp_dir_to_dir_wo_a:
# Copy a directory to another directory, without the -a switch.
@echo; echo Copy a directory to another directory, without the -a switch.
@echo ------------------------------;
@echo There should be an error message about cannot cp a dir to a subdir of itself.
cd cp_tests; \
touch a b c; \
mkdir adir; \
ls -lR . > ../cp_a_star_adir.gnu; \
${GCP} -a * adir; \
ls -lR . >> ../cp_a_star_adir.gnu;
@echo
@echo There should be an error message about cannot cp a dir to a subdir of itself.
cd cp_tests; \
rm -rf adir; \
mkdir adir; \
ls -lR . > ../cp_a_star_adir.bb; \
${BCP} -a * adir; \
ls -lR . >> ../cp_a_star_adir.bb;
@echo;
diff -u cp_a_star_adir.gnu cp_a_star_adir.bb;
# Done
@echo;
rm -rf cp_tests;
@echo; echo Done.
check_cp_dir_to_dir_w_a:
@echo; echo Copy a directory into another directory with the -a switch.
@echo ------------------------------;
cd cp_tests; \
mkdir dir{a,b}; \
echo A file > dira/afile; \
echo A file in dirb > dirb/afileindirb; \
ln -s dira/afile dira/alinktoafile; \
mkdir dira/subdir1; \
echo Another file > dira/subdir1/anotherfile; \
ls -lR . > ../cp_a_dira_dirb.gnu; \
${GCP} -a dira dirb; \
ls -lR . >> ../cp_a_dira_dirb.gnu;
@echo;
rm -rf cp_tests/dir{a,b};
@echo;
cd cp_tests; \
mkdir dir{a,b}; \
echo A file > dira/afile; \
echo A file in dirb > dirb/afileindirb; \
ln -s dira/afile dira/alinktoafile; \
mkdir dira/subdir1; \
echo Another file > dira/subdir1/anotherfile; \
ls -lR . > ../cp_a_dira_dirb.bb; \
${BCP} -a dira dirb; \
ls -lR . >> ../cp_a_dira_dirb.bb;
@echo;
diff -u cp_a_dira_dirb.gnu cp_a_dira_dirb.bb;
@echo;
rm -rf cp_tests/dir{a,b};
check_cp_dir_to_dir_w_a_take_two:
@echo; echo Copy a directory into another directory with the -a switch;
@echo ------------------------------;
mkdir -p cp_tests/gnu; \
mkdir -p cp_tests/bb; \
cd cp_tests; \
mkdir here there; \
echo A file > here/afile; \
mkdir here/adir; \
touch here/adir/afileinadir; \
ln -s $$(pwd) here/alink;
@echo;
cd cp_tests/gnu; \
ls -lR . > ../../cp_a_dir_dir.gnu; \
${GCP} -a here/ there/; \
ls -lR . >> ../../cp_a_dir_dir.gnu;
@echo;
rm -rf cp_tests/there/*;
sleep 1;
@echo;
cd cp_tests/bb; \
ls -lR . > ../../cp_a_dir_dir.bb; \
${BCP} -a here/ there/; \
ls -lR . >> ../../cp_a_dir_dir.bb;
@echo;
echo "Erik 1"
diff -u cp_a_dir_dir.gnu cp_a_dir_dir.bb;
echo "Erik 2"
@echo;
echo "Erik 3"
rm -rf cp_tests/*;

View File

@ -1,71 +0,0 @@
# ln_tests.mk - Set of tests for busybox ln
# -------------
# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> GPL
#
# GNU `ln'
GLN = /bin/ln
# BusyBox `ln'
BLN = $(shell pwd)/ln
all:: ln_tests
clean:: ln_clean
ln_clean:
rm -rf ln_tests ln_*.{gnu,bb} ln
ln_tests: ln_clean ln
@echo;
@echo "No output from diff means busybox ln is functioning properly.";
@echo;
${BLN} || true;
@echo;
mkdir ln_tests;
@echo;
cd ln_tests; \
echo A file > afile; \
ls -l afile > ../ln_afile_newname.gnu; \
${GLN} afile newname; \
ls -l afile newname >> ../ln_afile_newname.gnu;
@echo;
rm -f ln_tests/{afile,newname};
@echo;
cd ln_tests; \
echo A file > afile; \
ls -l afile > ../ln_afile_newname.bb; \
${BLN} afile newname; \
ls -l afile newname >> ../ln_afile_newname.bb;
@echo;
diff -u ln_afile_newname.gnu ln_afile_newname.bb
@echo;
rm -f ln_tests/{afile,newname};
@echo;
cd ln_tests; \
echo A file > afile; \
ls -l afile > ../ln_s_afile_newname.gnu; \
${GLN} -s afile newname; \
ls -l afile newname >> ../ln_s_afile_newname.gnu;
@echo;
rm -f ln_tests/{afile,newname};
@echo;
cd ln_tests; \
echo A file > afile; \
ls -l afile > ../ln_s_afile_newname.bb; \
${BLN} -s afile newname; \
ls -l afile newname >> ../ln_s_afile_newname.bb;
@echo;
diff -u ln_s_afile_newname.gnu ln_s_afile_newname.bb
@echo;
rm -f ln_tests/{afile,newname};

View File

@ -1,73 +0,0 @@
#!/usr/bin/perl
# multibuild.pl
# Tests BusyBox-0.48 (at least) to see if each applet builds
# properly on its own. The most likely problems this will
# flush out are those involving preprocessor instructions in
# utility.c.
#
# TODO: some time it might be nice to list absolute and
# differential object sizes for each option...
#
$logfile = "multibuild.log";
# How to handle all the CONFIG_FEATURE_FOO lines
if ($ARGV[0] eq "-all" ) { shift(@ARGV); $choice="all"; }
if ($ARGV[0] eq "-none") { shift(@ARGV); $choice="none"; }
# neither means, leave that part of Config.h alone
# Support building from pristine source
$make_opt = "-f $ARGV[0]/Makefile CONFIG_SRC_DIR=$ARGV[0]" if ($ARGV[0] ne "");
# Move the config file to a safe place
-e "Config.h.orig" || 0==system("mv -f Config.h Config.h.orig") || die;
# Clear previous log file, if any
unlink($logfile);
# Parse the config file
open(C,"<Config.h.orig") || die;
while (<C>) {
if ($in_trailer) {
if (!$in_olympus) {
s/^\/\/#/#/ if ($choice eq "all" && !/USE_DEVPS_PATCH/);
s/^#/\/\/#/ if ($choice eq "none");
}
$in_olympus=1 if /End of Features List/;
$trailer .= $_;
} else {
$in_trailer=1 if /End of Applications List/;
if (/^\/*#define CONFIG_([A-Z0-9_]*)/) {
push @apps, $1;
}
}
}
close C;
# Do the real work ...
$failed_tests=0;
for $a (@apps) {
# print "Testing build of applet $a ...\n";
open (O, ">Config.h") || die;
print O "#define CONFIG_$a\n", $trailer;
close O;
system("echo -e '\n***\n$a\n***' >>$logfile");
# With a fast computer and 1-second resolution on file timestamps, this
# process pushes beyond the limits of what unix make can understand.
# That's why need to weed out obsolete files before restarting make.
$result{$a} = system("rm -f *.o applet_source_list; make $make_opt busybox >>$logfile 2>&1");
$flag = $result{$a} ? "FAILED!!!" : "ok";
printf("Applet %-20s: %s\n", $a, $flag);
$total_tests++;
$failed_tests++ if $flag eq "FAILED!!!";
# pause long enough to let user stop us with a ^C
select(undef, undef, undef, 0.03);
}
# Clean up our mess
system("mv -f Config.h.orig Config.h");
print "$total_tests applets tested, $failed_tests failures\n";
print "See $logfile for details.\n";

View File

@ -1,83 +0,0 @@
#!/usr/bin/perl
#
# multifeat.pl
#
# Turns on all applets, then tests turning on one feature at a time through
# iterative compilations. Tests if any features depend on each other in any
# weird ways or such-like problems.
#
# Hacked by Mark Whitley, but based *heavily* on multibuild.pl which was
# written by Larry Doolittle.
$logfile = "multifeat.log";
# How to handle all the CONFIG_APPLET lines
# (most thorough testing occurs when you call it with the -all switch)
if ($ARGV[0] eq "-all" ) { shift(@ARGV); $choice="all"; }
if ($ARGV[0] eq "-none") { shift(@ARGV); $choice="none"; }
# neither means, leave that part of Config.h alone
# Support building from pristine source
$make_opt = "-f $ARGV[0]/Makefile CONFIG_SRC_DIR=$ARGV[0]" if ($ARGV[0] ne "");
# Move the config file to a safe place
-e "Config.h.orig" || 0==system("mv -f Config.h Config.h.orig") || die;
# Clear previous log file, if any
unlink($logfile);
# Parse the config file
open(C,"<Config.h.orig") || die;
$in_applist=1;
$in_features=0;
$in_olympus=0;
while (<C>) {
if ($in_applist) {
s/^\/\/#/#/ if ($choice eq "all");
s/^#/\/\/#/ if ($choice eq "none");
$header .= $_;
if (/End of Applications List/) {
$in_applist=0;
$in_features=1
}
}
elsif ($in_features) {
if (/^\/*#define CONFIG_FEATURE_([A-Z0-9_]*)/) {
push @features, $1;
}
if (/End of Features List/) {
$in_features=0;
$in_olympus=1
}
} elsif ($in_olympus) {
$trailer .= $_;
}
}
close C;
# Do the real work ...
$failed_tests=0;
for $f (@features) {
# print "Testing build with feature $f ...\n";
open (O, ">Config.h") || die;
print O $header, "#define CONFIG_FEATURE_$f\n", $trailer;
close O;
system("echo -e '\n***\n$f\n***' >>$logfile");
# With a fast computer and 1-second resolution on file timestamps, this
# process pushes beyond the limits of what unix make can understand.
# That's why need to weed out obsolete files before restarting make.
$result{$f} = system("rm -f *.o applet_source_list; make $make_opt busybox >>$logfile 2>&1");
$flag = $result{$f} ? "FAILED!!!" : "ok";
printf("Feature %-20s: %s\n", $f, $flag);
$total_tests++;
$failed_tests++ if $flag eq "FAILED!!!";
# pause long enough to let user stop us with a ^C
select(undef, undef, undef, 0.03);
}
# Clean up our mess
system("mv -f Config.h.orig Config.h");
print "$total_tests applets tested, $failed_tests failures\n";
print "See $logfile for details.\n";

View File

@ -1,167 +0,0 @@
# mv_tests.mk - Set of tests cases for busybox mv
# -------------
# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> GPL
#
# GNU `mv'
GMV = /bin/mv
# BusyBox `mv'
BMV = $(shell pwd)/mv
all:: mv_tests
clean:: mv_clean
mv_clean:
rm -rf mv_tests mv_*.{gnu,bb} mv
mv_tests: mv_clean mv
@echo;
@echo "No output from diff means busybox mv is functioning properly.";
@echo;
@echo "No such file or directory is good; it means the old file got removed.";
@echo;
${BMV} || true;
@echo;
mkdir mv_tests;
@echo;
cd mv_tests; \
echo A file > afile; \
ls -l afile > ../mv_afile_newname.gnu; \
${GMV} afile newname; \
ls -l newname >> ../mv_afile_newname.gnu;
-ls -l mv_tests/afile;
@echo;
rm -f mv_tests/{afile,newname};
@echo;
cd mv_tests; \
echo A file > afile; \
ls -l afile > ../mv_afile_newname.bb; \
${BMV} afile newname; \
ls -l newname >> ../mv_afile_newname.bb;
-ls -l mv_tests/afile;
@echo;
diff -u mv_afile_newname.gnu mv_afile_newname.bb;
@echo;
rm -f mv_tests/{afile,newname};
@echo; echo ------------------------------;
cd mv_tests; \
echo A file > afile; \
ln -s afile symlink; \
ls -l afile symlink > ../mv_symlink_newname.gnu; \
${GMV} symlink newname; \
ls -l afile newname >> ../mv_symlink_newname.gnu;
-ls -l mv_tests/symlink;
@echo;
rm -f mv_tests/{afile,newname};
@echo;
cd mv_tests; \
echo A file > afile; \
ln -s afile symlink; \
ls -l afile symlink > ../mv_symlink_newname.bb;\
${BMV} symlink newname; \
ls -l afile newname >> ../mv_symlink_newname.bb;
-ls -l mv_tests/symlink;
@echo;
diff -u mv_symlink_newname.gnu mv_symlink_newname.bb;
@echo;
rm -rf mv_tests/*;
@echo; echo ------------------------------;
cd mv_tests; \
echo A file > afile; \
ln -s afile symlink; \
mkdir newdir; \
ls -lR > ../mv_file_symlink_dir.gnu; \
${GMV} symlink afile newdir; \
ls -lR >> ../mv_file_symlink_dir.gnu;
-ls -l mv_tests/{symlink,afile};
@echo;
rm -rf mv_tests/*
@echo; echo ------------------------------;
cd mv_tests; \
echo A file > afile; \
ln -s afile symlink; \
mkdir newdir; \
ls -lR > ../mv_file_symlink_dir.bb; \
${BMV} symlink afile newdir; \
ls -lR >> ../mv_file_symlink_dir.bb;
-ls -l mv_tests/{symlink,afile};
@echo;
diff -u mv_file_symlink_dir.gnu mv_file_symlink_dir.bb;
@echo;
rm -rf mv_tests/*;
@echo; echo ------------------------------;
cd mv_tests; \
mkdir dir{a,b}; \
echo A file > dira/afile; \
echo A file in dirb > dirb/afileindirb; \
ln -s dira/afile dira/alinktoafile; \
mkdir dira/subdir1; \
echo Another file > dira/subdir1/anotherfile; \
ls -lR . > ../mv_dira_dirb.gnu; \
${GMV} dira dirb; \
ls -lR . >> ../mv_dira_dirb.gnu;
# false;
@echo;
rm -rf mv_tests/dir{a,b};
@echo;
cd mv_tests; \
mkdir dir{a,b}; \
echo A file > dira/afile; \
echo A file in dirb > dirb/afileindirb; \
ln -s dira/afile dira/alinktoafile; \
mkdir dira/subdir1; \
echo Another file > dira/subdir1/anotherfile; \
ls -lR . > ../mv_dira_dirb.bb; \
${BMV} dira dirb; \
ls -lR . >> ../mv_dira_dirb.bb;
@echo;
diff -u mv_dira_dirb.gnu mv_dira_dirb.bb;
# false;
@echo;
rm -rf mv_tests/dir{a,b};
@echo; echo ------------------------------;
@echo There should be an error message about cannot mv a dir to a subdir of itself.
cd mv_tests; \
mkdir adir; \
touch -r . a b c adir; \
ls -lR . > ../mv_a_star_adir.gnu; \
${GMV} * adir; \
ls -lR . >> ../mv_a_star_adir.gnu;
@echo
@echo There should be an error message about cannot mv a dir to a subdir of itself.
cd mv_tests; \
rm -rf a b c adir; \
mkdir adir; \
touch -r . a b c adir; \
ls -lR . > ../mv_a_star_adir.bb; \
${BMV} * adir; \
ls -lR . >> ../mv_a_star_adir.bb;
@echo;
diff -u mv_a_star_adir.gnu mv_a_star_adir.bb;
@echo;
rm -rf mv_test/*;

View File

@ -1,89 +0,0 @@
# try running this with bash, ksh, ash, and hush.
# simple quoting rules.
echo a b
echo "a b"
echo a "" b
echo a '' b
echo hello?
echo "hello?"
echo t* hello
echo t\* hello
# quick and painless exit for lash
if false; then true; exit; fi
# fairly simple command substitution
echo `echo -e foo\\\necho bar`
echo THIS IS A TEST >foo
cat $(echo FOO | tr 'A-Z' 'a-z')
cat foo | tr 'A-Z' 'a-z'
cat $(echo FOO | tr 'A-Z' 'a-z') | tr 'A-Z' 'a-z'
cat foo | if true; then tr 'A-Z' 'a-z'; else echo bar1; fi
cat foo | if false; then tr 'A-Z' 'a-z'; else echo bar2; fi
if true; then tr 'A-Z' 'a-z'; else echo bar3; fi <foo
if false; then tr 'A-Z' 'a-z'; else echo bar4; fi <foo
if true || false; then echo foo; else echo bar5; fi
if true && false; then echo bar6; else echo foo; fi
# basic distinction between local and env variables
unset FOO
FOO=bar env | grep FOO
echo "but not here: $FOO"
FOO=bar
env | grep FOO
echo "yes, here: $FOO"
FOO=
echo a $FOO b
echo "a $FOO b"
# not quite so basic variables. Credit to Matt Kraai.
unset FOO
FOO=bar
export FOO
env | grep FOO
unset FOO
export FOO=bar
FOO=baz
env | grep FOO
# interaction between environment variables and if/then and subshells
FOO=default
if true; then FOO=new; fi
echo $FOO
FOO=default
(FOO=bogus)
echo $FOO
# make sure we can duplicate file descriptors properly
echo replacement >foo 2>&1
cat foo
cat doesnt_exist >foo 2>&1
tr 'a-z' 'A-Z' <foo
# fairly simple example of hush expanding variables too early
unset TMP
rm -f fish
TMP=fish && >$TMP
ls fish
# ash, lash, and hush do not create wish; bash and ksh do.
# Thanks to Tapani Tarvainen <tt@mit.jyu.fi> for this stress test.
unset TMP
rm -f wish
TMP=wish >$TMP
ls wish
# The following example shows that hush's parser is
# not _really_ Bourne compatible
echo "echo Hello World" >"a=b"
unset a
chmod a+x "a=b"
PATH=$PATH:.
"a=b"
echo $a
# assuming the shell wasn't too buggy, clean up the mess
rm -f a=b wish fish foo

View File

@ -1,19 +0,0 @@
#include <syslog.h>
int do_log(char* msg, int delay)
{
openlog("testlog", LOG_PID, LOG_DAEMON);
while(1) {
syslog(LOG_ERR, "%s: testing one, two, three\n", msg);
sleep(delay);
}
closelog();
return(0);
};
int main(void)
{
if (fork()==0)
do_log("A", 2);
do_log("B", 3);
}

View File

@ -1,404 +0,0 @@
# testcases
#
# This file should be filled with test cases to test applets that:
#
# - can somehow produce output (we can't test sync or sleep)
# - have a GNU (or other) counterpart
# - are not interactive (don't require a ^C or anything)
# - don't require extensive setup or cleanup (a litte setup is fine)
# - don't have huge and possibly damaging effects (fsck, swapoff)
#
# If possible, a test case should be made that tests each option the applet
# supports. When a new option is added, a new test case should be written for
# it. When somebody reports a bug with a testcase, that testcase should be
# added here as well.
#
# Some other guidelines to follow:
#
# - please try to keep applets alphabetized, it will make life easier
# - use the file tester.sh or testcases when you need to do a non-destructive
# test on a file (i.e., cat, md5sum)
# - try to make the applet you're testing the first thing on the line (this
# not always possible)
# - (???) if you have to create a temporary file, call it TMPFILE
# - pipe symbols that represent real pipes need a space in front of them
# (so the test script can find them and add the "../busybox" after it).
# - pipe symbols that are not used for pipes need to be shell-escaped,
# with a double \. See the expr test cases.
# ar
# basename
basename `pwd`
# cat
cat tester.sh
echo hello there | cat tester.sh -
# chmod
# chown
# chgrp
# chroot
# chvt - can't be tested here
# clear - can't be tested here
# cmp
# cp
# cut
echo "1234" | cut -c1
echo "1234" | cut -c 1
echo "1234567890" | cut -c2-7
echo "1234567890" | cut -c 2-7
echo "f1 f2" | cut -f2
echo "f1 f2" | cut -f 2
echo "f1 f2 f3 f4 f5" | cut -f2-4
echo "f1 f2 f3 f4 f5" | cut -f 2-4
# date
date
date -R
date -u
date +%d/%m/%y
# dc - needs an input file
# dd
# BUG: record count line goes to stdout instead of stderr
dd if=/dev/urandom of=O bs=1k count=1 ; ls -l O ; rm O
# deallocvt
# df
# XXX: minor formatting differences
df
df .
df -k
df -h
df -m
# dirname
dirname `pwd`
# dmesg (XXX: change the silly cmd business in the source)
dmesg
dmesg -n 8
dmesg -s 512
# I really don't want to do this next one
#dmesg -c
# dos2unix - needs an input file
# dpkg
# dpkg_deb
# du
# BUG: rounding behavior differs from GNU du
du
du -s
du -l
du -k
du -h
du -m
# dumpkmap - no counterprt?
# dutmp - no counterprt?
# echo
echo "foo bar baz"
echo -n "no newline"
# expr
expr 1 \\| 1
expr 1 \\| 0
expr 0 \\| 1
expr 0 \\| 0
expr 1 \\& 1
expr 1 \\& 0
expr 0 \\& 1
expr 0 \\& 0
expr 0 \\< 1
expr 1 \\< 0
expr 1 \\> 0
expr 0 \\> 1
expr 0 \\<= 1
expr 1 \\<= 0
expr 1 \\<= 1
expr 1 \\>= 0
expr 0 \\>= 1
expr 1 \\>= 1
expr 1 + 2
expr 2 - 1
expr 2 \\* 3
expr 12 / 2
expr 12 % 5
# somebody else can do all the string stuff
# fbset - can't be tested here
# fdflush
# find
find .
# free
# XXX: minor formatting differences
free
# freeramdisk
# fsck.minix - won't test
# getopt
# grep
grep -l strdup ../*utils/*.c
grep -c strdup ../*utils/*.c
grep -lc strdup ../*utils/*.c
grep -cv strdup ../*utils/*.c
grep -i null ../findutils/grep.c
grep -e strdup -e regcomp -e atexit ../findutils/grep.c
# gunzip
# gzip
# XXX: compressed output differs from gzip-1.2.4, but decompresses fine
echo testing 1 2 3 >tmpfile1; gzip tmpfile1; echo tmpfile*; md5sum tmpfile1.gz; rm tmpfile1.gz
echo testing 1 2 3 | gzip >tmpfile1.gz; md5sum tmpfile1.gz; rm tmpfile1.gz
# halt - won't test, dangerous
# head
head tester.sh
head -n 2 tester.sh
# hostid
hostid
# hostname
# XXX: minor formatting differences
hostname
hostname -s
hostname -i
hostname -d
# not going to do this next one
#hostname -F
# id
# BUG: Busybox id doesn't print supplemental groups
id
id -u
id -g
id -ur
id -un
# ifconfig
# requires CONFIG_FEATURE_IFCONFIG_STATUS
ifconfig
#ifconfig -a
#ifconfig eth0
#ifconfig lo
# init - won't test
# insmod - won't test
# kill
#kill -l
# not going to do any more
# length
# ln - see ln_tests.mk
# loadacm
# loadfont
# loadkmap
# logger
# logname
# ls
# XXX: minor formatting differences
ls ../e*
ls -l ../e*
ls -s ../e*
ls -h ../e*
ls -1 ../e*
# lsmod
lsmod
# makedevs
# md5sum
md5sum tester.sh
# mkdir
mkdir D ; ls -ld D ; rmdir D
# mkfifo
#
# we will test making one. actually testing pushing data through it requires
# more interaction than we can manage here.
# (these lines turn up an existing ls bug)
mkfifo F ; ls -l F ; rm F
mkfifo -m 0600 F ; ls -l F ; rm F
# mkfs.minix - won't test
# mknod
# mkswap - won't test
# mktemp
# more - can't test: interactive
# mount
# BUG: proc line starts with /proc instead of proc
mount
# not going to test mount with any args, can't be done safely or sanely
# mt
# mv - see mv_tests.mk
# nc
# nfsmount
# nslookup
# ping
ping -c 3 yahoo.com
# pivot_root
# poweroff - won't test
# printf
# ps - there's lotsa differences between busybox ps and any other ps
# pwd
pwd
# rdate - won't test
# readlink
ln -sf tester.sh L ; readlink L ; rm -f L
# reboot - won't test
# renice - won't test
# reset - can't test: no output
# rm
touch F ; rm F
# rmdir
# rmmod - won't test: dangerous
# route
# XXX: doesn't DNS resolve
route
# rpm2cpio
# sed - we can do some one-liners here, some testing is a little
# difficult to do in just this space (like a,i,c cmds).
# test ^$ matching
echo foo | sed -ne '/^$/p'
echo -e "foo\\n\\nbar" | sed -ne '/^$/p'
sed -e '/test$/d' testcases
sed -e '/^echo/d' testcases
sed -e '/test/s/dangerous/PELIGROSO/' testcases
sed -ne '1,/getopt/p' ../shellutils/pwd.c
sed -e '/getopt/r ../shellutils/pwd.c' ../editors/sed.c
# setkeycodes
# sh - note that we cannot test the shell interactively here
sh -c "echo a b c"
sh -c ">"
sh -c "a"
sh sh.testcases
# sleep - can't test: produces no output
# sort
sort tester.sh
sort -n tester.sh
sort -r tester.sh
# stty
# swapon - won't test: dangerous
# swapoff - won't test: dangerous
# sync - can't test: no output
# syslogd - won't test: too involved
# tail
tail tester.sh
tail -n 2 tester.sh
# tar
# tee
echo "please tee me!" | tee A B C ; cat A B C
echo "please tee me!" | tee A B C ; echo "tee me too!" | tee -a A B C ; cat A B C ; rm A B C
# telnet - can't test: interactive
# test
# tftp
# touch
touch tmpfile1; ls tmpfile1; rm -f tmpfile1
touch -c tmpfile1; ls tmpfile1; rm -f tmpfile1
# tr
# BUG: Busybox tr range handling minix style [a-z] instead of GNU # style a-z
echo "cbaab" | tr abc zyx
echo "TESTING A B C" | tr [A-Z] [a-z]
# not GNU compatible
echo fdhrnzvfu bffvsentr | tr [a-z] [n-z][a-m]
echo abc[] | tr a[b AXB
echo testing | tr -d aeiou
# true
true ; echo $?
# false
false ; echo $?
# tty
# umount
# uname
# uniq
# unix2dos
# update
# uptime
# BUG: doesn't print number of users
uptime
# usleep
# uudecode
# uuencode
# watchdog
# wc
wc tester.sh
wc -c tester.sh
wc -w tester.sh
wc -l tester.sh
wc -L tester.sh
# wget
# which
which ls
# whoami
whoami
# xargs
# XXX: Busygox xargs divides filenames with '\n' instead of ' '
ls -1 ../e* | xargs
ls -1 ../e* | xargs md5sum
# yes - can't test: interactive (needs ^C)

View File

@ -1,158 +0,0 @@
#!/bin/bash
#
# tester.sh - reads testcases from file and tests busybox applets vs GNU
# counterparts
#
# This should be run from within the tests/ directory. Before you run it, you
# should compile up a busybox that has all applets and all features turned on.
# set up defaults (can be changed with cmd-line options)
BUSYBOX=../busybox
TESTCASES=testcases
LOGFILE=tester.log
CONFIG_OUT=bb.out
GNU_OUT=gnu.out
SETUP=""
CLEANUP=""
KEEPTMPFILES="no"
DEBUG=2
#while getopts 'p:t:l:b:g:s:c:kd:' opt
while getopts 'p:t:l:s:c:kd:' opt
do
case $opt in
p) BUSYBOX=$OPTARG; ;;
t) TESTCASES=$OPTARG; ;;
l) LOGFILE=$OPTARG; ;;
# b) CONFIG_OUT=$OPTARG; ;;
# g) GNU_OUT=$OPTARG; ;;
s) SETUP=$OPTARG; ;;
c) CLEANUP=$OPTARG; ;;
k) KEEPTMPFILES="yes"; ;;
d) DEBUG=$OPTARG; ;;
*)
echo "usage: $0 [-ptlbgsc]"
echo " -p PATH path to busybox executable (default=$BUSYBOX)"
echo " -t FILE run testcases in FILE (default=$TESTCASES)"
echo " -l FILE log test results in FILE (default=$LOGFILE)"
# echo " -b FILE store temporary busybox output in FILE"
# echo " -g FILE store temporary GNU output in FILE"
echo " -s FILE (setup) run commands in FILE before testcases"
echo " -c FILE (cleanup) run commands in FILE after testcases"
echo " -k keep temporary output files (don't delete them)"
echo " -d NUM set level of debugging output"
echo " 0 = no output"
echo " 1 = output failures / whoops lines only"
echo " 2 = (default) output setup / cleanup msgs and testcase lines"
echo " 3+= other debug noise (internal stuff)"
exit 1
;;
esac
done
#shift `expr $OPTIND - 1`
# maybe print some debug output
if [ $DEBUG -ge 3 ]
then
echo "BUSYBOX=$BUSYBOX"
echo "TESTCASES=$TESTCASES"
echo "LOGFILE=$LOGFILE"
echo "CONFIG_OUT=$CONFIG_OUT"
echo "GNU_OUT=$GNU_OUT"
echo "SETUP=$SETUP"
echo "CLEANUP=$CLEANUP"
echo "DEBUG=$DEBUG"
fi
# do sanity checks
if [ ! -e $BUSYBOX ]
then
echo "Busybox executable: $BUSYBOX not found!"
exit 1
fi
if [ ! -e $TESTCASES ]
then
echo "Testcases file: $TESTCASES not found!"
exit 1
fi
# do normal setup
[ -e $LOGFILE ] && rm $LOGFILE
unalias -a # gets rid of aliases that might create different output
# do extra setup (if any)
if [ ! -z "$SETUP" ]
then
[ $DEBUG -ge 2 ] && echo "running setup commands in $SETUP"
source $SETUP
fi
# go through each line in the testcase file
cat $TESTCASES | while read line
do
#echo $line
# only process non-blank lines and non-comment lines
if [ "$line" ]
then
if [ `echo "$line" | cut -c1` != "#" ]
then
# test if the applet was compiled into busybox
# (this only tests the applet at the beginning of the line)
#applet=`echo $line | cut -d' ' -f1`
applet=`echo $line | sed 's/\(^[^ ;]*\)[ ;].*/\1/'`
$BUSYBOX 2>&1 | grep -qw $applet
if [ $? -eq 1 ]
then
echo "WHOOPS: $applet not compiled into busybox" | tee -a $LOGFILE
else
# execute line using gnu / system programs
[ $DEBUG -ge 2 ] && echo "testing: $line" | tee -a $LOGFILE
sh -c "$line" > $GNU_OUT
# change line to include "busybox" before every statement
line="$BUSYBOX $line"
# is this a bash-2-ism?
# line=${line//;/; $BUSYBOX }
# line=${line//|/| $BUSYBOX }
# assume $BUSYBOX has no commas
line=`echo "$line" | sed -e 's,;,; '$BUSYBOX, \
-e 's, |, | '$BUSYBOX,`
# execute line using busybox programs
[ $DEBUG -ge 2 ] && echo "testing: $line" | tee -a $LOGFILE
sh -c "$line" > $CONFIG_OUT
# see if they match
diff -q $CONFIG_OUT $GNU_OUT > /dev/null
if [ $? -eq 1 ]
then
[ $DEBUG -ge 1 ] && echo "FAILED: $line" | tee -a $LOGFILE
diff -u $CONFIG_OUT $GNU_OUT >> $LOGFILE
fi
fi
fi
fi
done
[ $DEBUG -gt 0 ] && echo "Finished. Results are in $LOGFILE"
# do normal cleanup
[ "$KEEPTMPFILES" = "no" ] && rm -f $CONFIG_OUT $GNU_OUT
# do extra cleanup (if any)
if [ ! -z "$CLEANUP" ]
then
[ $DEBUG -ge 2 ] && echo "running cleanup commands in $CLEANUP"
source $CLEANUP
fi

View File

@ -1,44 +0,0 @@
/*
* tst-syslogd.c - tests concurrent threads calling syslog
*
* build with: gcc -Wall tst-syslogd.c -lpthread
*/
#include <stdio.h>
#include <pthread.h>
#include <syslog.h>
#include <unistd.h>
void *log_func(void *arg)
{
int i;
int thrid = (int)arg;
openlog(NULL, LOG_PERROR | LOG_PID, LOG_USER);
for (i = 0; i < 10; i++) {
syslog(LOG_DEBUG, "thread %i iter %i\n", thrid, i);
sleep(thrid); /* this mixes things up a bit */
}
closelog();
return NULL;
}
int main(int argc, char **argv)
{
pthread_t thr1, thr2, thr3;
int id1 = 1;
int id2 = 2;
int id3 = 3;
pthread_create(&thr1, NULL, log_func, (void *)id1);
pthread_create(&thr2, NULL, log_func, (void *)id2);
pthread_create(&thr3, NULL, log_func, (void *)id3);
pthread_join(thr1, NULL);
pthread_join(thr2, NULL);
pthread_join(thr3, NULL);
return 0;
}

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