updated tester to add post-exec state for clean-up; added a few more tests for reverse

This commit is contained in:
Remzi Arpaci-Dusseau
2019-02-22 04:26:54 -06:00
parent e922fc3763
commit 8c23f82154
18 changed files with 48 additions and 13 deletions

View File

@@ -1 +1 @@
First simple test of reversing
input and output are actually the same file (hardlinked)

View File

@@ -0,0 +1 @@
reverse: input and output file must differ

View File

@@ -0,0 +1 @@
rm -f tests-out/5.in

View File

@@ -0,0 +1 @@
rm -f tests-out/5.in; ln tests/5.in tests-out/5.in

View File

@@ -1 +1 @@
0
1

View File

@@ -1,2 +1 @@
./reverse tests/5.in tests-out/5.other
./reverse tests/5.in tests-out/5.in

View File

@@ -1,2 +1 @@
Standard input test
First simple test of reversing

View File

@@ -0,0 +1,5 @@
hello
this
is
a
test

View File

@@ -1,5 +0,0 @@
test
a
is
this
hello

View File

@@ -1 +1 @@
./reverse < tests/5.in
./reverse tests/6.in tests-out/6.other

View File

@@ -0,0 +1 @@
standard input test

View File

View File

@@ -0,0 +1,5 @@
hello
this
is
a
test

View File

@@ -0,0 +1,5 @@
test
a
is
this
hello

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
./reverse < tests/7.in

View File

@@ -4,13 +4,34 @@
run_test () {
local testdir=$1
local testnum=$2
local verbose=$3
# pre: execute this after before the test is done, to set up
local prefile=$testdir/$testnum.pre
if [[ -f $prefile ]]; then
eval $(cat $prefile)
if (( $verbose == 1 )); then
echo -n "pre-test: "
cat $prefile
fi
fi
local testfile=$testdir/$testnum.run
if (( $verbose == 1 )); then
echo -n "test: "
cat $testfile
fi
eval $(cat $testfile) > tests-out/$testnum.out 2> tests-out/$testnum.err
echo $? > tests-out/$testnum.rc
# post: execute this after the test is done, to clean up
local postfile=$testdir/$testnum.post
if [[ -f $postfile ]]; then
eval $(cat $postfile)
if (( $verbose == 1 )); then
echo -n "post-test: "
cat $postfile
fi
fi
return
}
@@ -64,7 +85,7 @@ run_and_check () {
echo "running test $testnum"
cat $testdir/$testnum.desc
fi
run_test $testdir $testnum
run_test $testdir $testnum $verbose
rccheck=$(check_test $testdir $testnum $contrunning rc)
outcheck=$(check_test $testdir $testnum $contrunning out)
errcheck=$(check_test $testdir $testnum $contrunning err)