aboutsummaryrefslogtreecommitdiff
path: root/tests/300-incorrect_reference_file.sh
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2022-03-06 05:59:49 +0100
committerJan Sucan <jan@jansucan.com>2022-03-06 05:59:49 +0100
commite1d10bea5d9fc94ba800ade1de430c7f3c0ccacd (patch)
tree8e8a7bcd2a3b5f95463b3cc1480f4c4afa8b6bc3 /tests/300-incorrect_reference_file.sh
parent647880b532b5b4fce42f7a723bf4c01bbe10d44e (diff)
tests: Unify naming of the test files
Diffstat (limited to 'tests/300-incorrect_reference_file.sh')
-rw-r--r--tests/300-incorrect_reference_file.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/300-incorrect_reference_file.sh b/tests/300-incorrect_reference_file.sh
new file mode 100644
index 0000000..b3de8c0
--- /dev/null
+++ b/tests/300-incorrect_reference_file.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+source ./assert.sh
+
+PROGRAM_EXEC="$1"
+
+rm -f ref out
+touch ref out
+assert_error "reference file is empty" $PROGRAM_EXEC ref out
+
+dd if=/dev/zero of=ref bs=513 count=1 1>/dev/null 2>&1
+assert_error "reference file has size that cannot contain valid diff data" \
+ $PROGRAM_EXEC -s 512 ref out
+
+rm -f ref out
+dd if=/dev/zero of=out bs=512 count=2 1>/dev/null 2>&1
+# Create a two-sector backup file
+dd if=/dev/zero of=ref bs=$(( 512 + 8 )) count=2 1>/dev/null 2>&1
+# The first offset will be 2
+printf '\x02' | dd of=ref bs=1 count=1 seek=0 conv=notrunc 1>/dev/null 2>&1
+# The second offset will be 1
+printf '\x01' | dd of=ref bs=1 count=1 seek=520 conv=notrunc 1>/dev/null 2>&1
+assert_error "a sector offset points behind the previous offset" \
+ $PROGRAM_EXEC -s 512 ref out
+
+rm -f ref out
+dd if=/dev/zero of=out bs=512 count=1 1>/dev/null 2>&1
+# Create a one-sector backup file
+dd if=/dev/zero of=ref bs=$(( 512 + 8 )) count=2 1>/dev/null 2>&1
+# The first offset will be 1
+printf '\x01' | dd of=ref bs=1 count=1 seek=0 conv=notrunc 1>/dev/null 2>&1
+assert_error "a sector offset points past the end of the output file" \
+ $PROGRAM_EXEC -s 512 ref out
+
+rm -f ref out
+
+exit 0