From: Richard Kettlewell Date: Sat, 24 May 2014 14:00:42 +0000 (+0100) Subject: Add some tests. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=44eee7003c50e0317f96d3a97e24cc99810aab5d;p=vbig.git Add some tests. --- diff --git a/.gitignore b/.gitignore index 117c4ee..4b56840 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ configure stamp-h1 vbig *~ -debian/*.log debian/files debian/*substvars +*.trs +*.log diff --git a/Makefile.am b/Makefile.am index ab3c08a..9ba379f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,5 @@ bin_PROGRAMS=vbig vbig_SOURCES=vbig.cc Arcfour.h Arcfour.cc man_MANS=vbig.1 -EXTRA_DIST=${man_MANS} README.md +TESTS=t-both t-seeded t-separate t-corrupt t-truncated t-extended +EXTRA_DIST=${man_MANS} README.md ${TESTS} diff --git a/t-both b/t-both new file mode 100755 index 0000000..c0203e6 --- /dev/null +++ b/t-both @@ -0,0 +1,5 @@ +#! /bin/sh +set -e +rm -f testfile +./vbig --both testfile 65536 +rm -f testfile diff --git a/t-corrupt b/t-corrupt new file mode 100755 index 0000000..35599bd --- /dev/null +++ b/t-corrupt @@ -0,0 +1,12 @@ +#! /bin/sh +set -e +rm -f testfile +./vbig --seed chahthaiquiyouto --create testfile 65536 +dd if=/dev/zero of=testfile bs=256 count=1 seek=1 conv=nocreat,notrunc status=none +if ./vbig --seed chahthaiquiyouto --verify testfile 65536 2>testoutput; then + echo >&2 ERROR: verify unexpectedly succeeded + exit 1 +fi +echo 'ERROR: testfile: corrupted at 256/65536 bytes (expected 132 got 0)' > testexpect +diff -u testexpect testoutput +rm -f testfile testoutput testexpect diff --git a/t-extended b/t-extended new file mode 100755 index 0000000..6b10958 --- /dev/null +++ b/t-extended @@ -0,0 +1,12 @@ +#! /bin/sh +set -e +rm -f testfile +./vbig --seed chahthaiquiyouto --create testfile 65536 +dd if=/dev/zero of=testfile bs=256 count=1 seek=1 conv=nocreat,notrunc oflag=append status=none +if ./vbig --seed chahthaiquiyouto --verify testfile 65536 2>testoutput; then + echo >&2 ERROR: verify unexpectedly succeeded + exit 1 +fi +echo 'ERROR: testfile: extended beyond 65536 bytes' > testexpect +diff -u testexpect testoutput +rm -f testfile testoutput testexpect diff --git a/t-seeded b/t-seeded new file mode 100755 index 0000000..50d4e68 --- /dev/null +++ b/t-seeded @@ -0,0 +1,6 @@ +#! /bin/sh +set -e +rm -f testfile +./vbig --seed chahthaiquiyouto --create testfile 65536 +./vbig --seed chahthaiquiyouto --verify testfile 65536 +rm -f testfile diff --git a/t-separate b/t-separate new file mode 100755 index 0000000..56efd9d --- /dev/null +++ b/t-separate @@ -0,0 +1,6 @@ +#! /bin/sh +set -e +rm -f testfile +./vbig --create testfile 65536 +./vbig --verify testfile 65536 +rm -f testfile diff --git a/t-truncated b/t-truncated new file mode 100755 index 0000000..0a28a14 --- /dev/null +++ b/t-truncated @@ -0,0 +1,12 @@ +#! /bin/sh +set -e +rm -f testfile +./vbig --seed chahthaiquiyouto --create testfile 65536 +truncate --size=32768 testfile +if ./vbig --seed chahthaiquiyouto --verify testfile 65536 2>testoutput; then + echo >&2 ERROR: verify unexpectedly succeeded + exit 1 +fi +echo 'ERROR: testfile: truncated at 32768/65536 bytes' > testexpect +diff -u testexpect testoutput +rm -f testfile testoutput testexpect