chiark / gitweb /
Add some tests.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 24 May 2014 14:00:42 +0000 (15:00 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 24 May 2014 14:00:42 +0000 (15:00 +0100)
.gitignore
Makefile.am
t-both [new file with mode: 0755]
t-corrupt [new file with mode: 0755]
t-extended [new file with mode: 0755]
t-seeded [new file with mode: 0755]
t-separate [new file with mode: 0755]
t-truncated [new file with mode: 0755]

index 117c4ee61aa4b2c770df38cb57acfeb1d2e25a25..4b568409aa00515d1a36e128bc3e434c8de03782 100644 (file)
@@ -14,6 +14,7 @@ configure
 stamp-h1
 vbig
 *~
-debian/*.log
 debian/files
 debian/*substvars
+*.trs
+*.log
index ab3c08a98b31c0fe06cdc57ecb0da65a2d96c3f6..9ba379f4d95689025641275df4d3cde6f6cc8ed1 100644 (file)
@@ -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 (executable)
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 (executable)
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 (executable)
index 0000000..6b10958
--- /dev/null
@@ -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 (executable)
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 (executable)
index 0000000..56efd9d
--- /dev/null
@@ -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 (executable)
index 0000000..0a28a14
--- /dev/null
@@ -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