first cut at very simple tester

This commit is contained in:
Remzi Arpaci-Dusseau
2019-02-15 04:56:27 -06:00
parent da78e916a1
commit d718e39375
45 changed files with 2000093 additions and 0 deletions

View File

@@ -0,0 +1 @@
basic test: a one-line file

View File

View File

@@ -0,0 +1 @@
simple test

View File

@@ -0,0 +1 @@
simple test

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
./wcat tests/1.in

View File

@@ -0,0 +1 @@
simple multi-file test

View File

View File

@@ -0,0 +1 @@
this line is from one file

View File

@@ -0,0 +1 @@
this line is from another file

View File

@@ -0,0 +1,2 @@
this line is from one file
this line is from another file

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
./wcat tests/2.in.a tests/2.in.b

View File

@@ -0,0 +1 @@
empty file

View File

View File

View File

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
./wcat tests/3.in

View File

@@ -0,0 +1 @@
no input file at all

View File

View File

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
./wcat

View File

@@ -0,0 +1 @@
long file

View File

1000000
initial-utilities/wcat/tests/5.in Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
./wcat tests/5.in

View File

@@ -0,0 +1 @@
bad file on command line (does not exist)

View File

View File

@@ -0,0 +1 @@
wcat: cannot open file

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1 @@
./wcat tests/6.in

View File

@@ -0,0 +1 @@
many files on command line, but one of them does not exist

View File

View File

@@ -0,0 +1,3 @@
this one has stuff in it
this one does too
wcat: cannot open file

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1 @@
./wcat tests/7a.in tests/7b.in tests/7c.in tests/7d.in

View File

@@ -0,0 +1 @@
this one has stuff in it

View File

@@ -0,0 +1 @@
this one does too

View File

@@ -0,0 +1 @@
this one does but should not get printed

View File

@@ -0,0 +1,10 @@
#! /usr/bin/env python
import random
import string
for i in range(1000000):
x = ''
for i in range(40):
x += random.choice(string.letters + ' ')
print(x)

49
tester/run-tests.sh Executable file
View File

@@ -0,0 +1,49 @@
#! /usr/bin/env bash
# run_test test_number
run_test () {
testfile=tests/$1.run
# cat $testfile
$(cat $testfile) > tests-out/$1.out 2> tests-out/$1.err
return 0
}
# check_test test_number out/err
check_test () {
outdiff=$(diff tests/$1.$2 tests-out/$1.$2)
outerr=$?
if (( $outerr != 0 )); then
builtin echo -e "\e[31mtest $testnum: standard $2 incorrect\e[0m"
echo "should be:"
cat tests/$1.$2
echo "is:"
cat tests-out/$1.$2
exit 1
fi
return 0
}
(( testnum = 1 ))
while true; do
if [[ ! -f tests/$testnum.run ]]; then
exit 0
fi
run_test $testnum
check_test $testnum out
check_test $testnum err
builtin echo -e "\e[32mtest $testnum: passed\e[0m"
(( testnum = $testnum + 1 ))
done
exit 0