From 44eee7003c50e0317f96d3a97e24cc99810aab5d Mon Sep 17 00:00:00 2001 From: Richard Kettlewell Date: Sat, 24 May 2014 15:00:42 +0100 Subject: [PATCH] Add some tests. --- .gitignore | 3 ++- Makefile.am | 3 ++- t-both | 5 +++++ t-corrupt | 12 ++++++++++++ t-extended | 12 ++++++++++++ t-seeded | 6 ++++++ t-separate | 6 ++++++ t-truncated | 12 ++++++++++++ 8 files changed, 57 insertions(+), 2 deletions(-) create mode 100755 t-both create mode 100755 t-corrupt create mode 100755 t-extended create mode 100755 t-seeded create mode 100755 t-separate create mode 100755 t-truncated 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 -- 2.30.2