aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2025-01-18 07:57:57 +0100
committerJán Sučan <jan@jansucan.com>2025-01-18 12:44:04 +0100
commit8b51499900e125a55dcdc425d29550b98a8064b4 (patch)
tree938545b3b612bcacd3599785be3f4a23ec08bea7 /tests
parenta7e8d00f5140d250e339736eb49e20609bffa47f (diff)
Initial implementation of diff file format v2
Diffstat (limited to 'tests')
-rw-r--r--tests/005-missing_argument_for_option.sh2
-rw-r--r--tests/006-incorrect_buffer_size.sh10
-rw-r--r--tests/007-incorrect_sector_size.sh15
-rw-r--r--tests/100-cannot_open_files.sh4
-rw-r--r--tests/200-input_and_reference_size_differs.sh15
-rw-r--r--tests/201-input_or_reference_size_is_not_multiple_of_sector_size.sh16
-rw-r--r--tests/300-incorrect_reference_file.sh37
-rw-r--r--tests/400-expected_backup_output.binbin1560 -> 39 bytes
-rw-r--r--tests/400-successful_backup_restore.sh4
9 files changed, 8 insertions, 95 deletions
diff --git a/tests/005-missing_argument_for_option.sh b/tests/005-missing_argument_for_option.sh
index b519513..26569bc 100644
--- a/tests/005-missing_argument_for_option.sh
+++ b/tests/005-missing_argument_for_option.sh
@@ -5,9 +5,7 @@ source ./assert.sh
PROGRAM_EXEC="$1"
assert "Usage" "missing argument for option '-B'" 1 $PROGRAM_EXEC backup -B
-assert "Usage" "missing argument for option '-S'" 1 $PROGRAM_EXEC backup -S
assert "Usage" "missing argument for option '-B'" 1 $PROGRAM_EXEC restore -B
-assert "Usage" "missing argument for option '-S'" 1 $PROGRAM_EXEC restore -S
exit 0
diff --git a/tests/006-incorrect_buffer_size.sh b/tests/006-incorrect_buffer_size.sh
index 1dfbc24..9c9b4ea 100644
--- a/tests/006-incorrect_buffer_size.sh
+++ b/tests/006-incorrect_buffer_size.sh
@@ -4,12 +4,10 @@ source ./assert.sh
PROGRAM_EXEC="$1"
-assert "Usage" "incorrect sector size" 1 $PROGRAM_EXEC backup -S abc123 -i in -b base -o out
-assert "Usage" "sector size cannot be 0" 1 $PROGRAM_EXEC backup -S 0 -i in -b base -o out
-assert "Usage" "sector size cannot larger than buffer size" 1 $PROGRAM_EXEC backup -S 2 -B 1 -i in -b base -o out
+assert "Usage" "incorrect buffer size" 1 $PROGRAM_EXEC backup -B abc123 -i in -b base -o out
+assert "Usage" "buffer size cannot be 0" 1 $PROGRAM_EXEC backup -B 0 -i in -b base -o out
-assert "Usage" "incorrect sector size" 1 $PROGRAM_EXEC restore -S abc123 -d diff -o out
-assert "Usage" "sector size cannot be 0" 1 $PROGRAM_EXEC restore -S 0 -d diff -o out
-assert "Usage" "sector size cannot larger than buffer size" 1 $PROGRAM_EXEC restore -S 2 -B 1 -d diff -o out
+assert "Usage" "incorrect buffer size" 1 $PROGRAM_EXEC restore -B abc123 -d diff -o out
+assert "Usage" "buffer size cannot be 0" 1 $PROGRAM_EXEC restore -B 0 -d diff -o out
exit 0
diff --git a/tests/007-incorrect_sector_size.sh b/tests/007-incorrect_sector_size.sh
deleted file mode 100644
index 5d8a689..0000000
--- a/tests/007-incorrect_sector_size.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-
-source ./assert.sh
-
-PROGRAM_EXEC="$1"
-
-assert "Usage" "incorrect buffer size" 1 $PROGRAM_EXEC backup -B abc123 -i in -b base -o out
-assert "Usage" "buffer size cannot be 0" 1 $PROGRAM_EXEC backup -B 0 -i in -b base -o out
-assert "Usage" "buffer size is not multiple of sector size" 1 $PROGRAM_EXEC backup -B 3 -S 2 -i in -b base -o out
-
-assert "Usage" "incorrect buffer size" 1 $PROGRAM_EXEC restore -B abc123 -d diff -o out
-assert "Usage" "buffer size cannot be 0" 1 $PROGRAM_EXEC restore -B 0 -d diff -o out
-assert "Usage" "buffer size is not multiple of sector size" 1 $PROGRAM_EXEC restore -B 3 -S 2 -d diff -o out
-
-exit 0
diff --git a/tests/100-cannot_open_files.sh b/tests/100-cannot_open_files.sh
index 34cf3e0..e0a59d3 100644
--- a/tests/100-cannot_open_files.sh
+++ b/tests/100-cannot_open_files.sh
@@ -6,11 +6,11 @@ PROGRAM_EXEC="$1"
rm -f input base out
touch base out
-assert "" "cannot get size of input file" 1 $PROGRAM_EXEC backup -i input -b base -o out
+assert "" "cannot open input file" 1 $PROGRAM_EXEC backup -i input -b base -o out
rm -f input base out
touch input out
-assert "" "cannot get size of base file" 1 $PROGRAM_EXEC backup -i input -b base -o out
+assert "" "cannot open base file" 1 $PROGRAM_EXEC backup -i input -b base -o out
rm -f input base out
rmdir outdir 2>/dev/null
diff --git a/tests/200-input_and_reference_size_differs.sh b/tests/200-input_and_reference_size_differs.sh
deleted file mode 100644
index dceb63b..0000000
--- a/tests/200-input_and_reference_size_differs.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-
-source ./assert.sh
-
-PROGRAM_EXEC="$1"
-
-rm -f input base
-dd if=/dev/zero of=input bs=500 count=1 1>/dev/null 2>&1
-dd if=/dev/zero of=base bs=501 count=1 1>/dev/null 2>&1
-
-assert "" "input file and base file differ in size" 1 $PROGRAM_EXEC backup -i input -b base -o out
-
-rm -f input base out
-
-exit 0
diff --git a/tests/201-input_or_reference_size_is_not_multiple_of_sector_size.sh b/tests/201-input_or_reference_size_is_not_multiple_of_sector_size.sh
deleted file mode 100644
index d7c6aa6..0000000
--- a/tests/201-input_or_reference_size_is_not_multiple_of_sector_size.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-source ./assert.sh
-
-PROGRAM_EXEC="$1"
-
-rm -f input base
-dd if=/dev/zero of=input bs=513 count=1 1>/dev/null 2>&1
-dd if=/dev/zero of=base bs=513 count=1 1>/dev/null 2>&1
-
-assert "" "size of input file and base file is not multiple of [0-9]" \
- 1 $PROGRAM_EXEC backup -S 512 -i input -b base -o out
-
-rm -f input base out
-
-exit 0
diff --git a/tests/300-incorrect_reference_file.sh b/tests/300-incorrect_reference_file.sh
deleted file mode 100644
index c250541..0000000
--- a/tests/300-incorrect_reference_file.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-source ./assert.sh
-
-PROGRAM_EXEC="$1"
-
-rm -f diff out
-touch diff out
-assert "" "diff file is empty" 1 $PROGRAM_EXEC restore -d diff -o out
-
-dd if=/dev/zero of=diff bs=513 count=1 1>/dev/null 2>&1
-assert "" "diff file has size that cannot contain valid diff data" \
- 1 $PROGRAM_EXEC restore -S 512 -d diff -o out
-
-rm -f diff 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=diff bs=$(( 512 + 8 )) count=2 1>/dev/null 2>&1
-# The first offset will be 2
-printf '\x02' | dd of=diff bs=1 count=1 seek=0 conv=notrunc 1>/dev/null 2>&1
-# The second offset will be 1
-printf '\x01' | dd of=diff bs=1 count=1 seek=520 conv=notrunc 1>/dev/null 2>&1
-assert "" "a sector offset points behind the previous offset" \
- 1 $PROGRAM_EXEC restore -S 512 -d diff -o out
-
-rm -f diff 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=diff bs=$(( 512 + 8 )) count=2 1>/dev/null 2>&1
-# The first offset will be 1
-printf '\x01' | dd of=diff bs=1 count=1 seek=0 conv=notrunc 1>/dev/null 2>&1
-assert "" "a sector offset points past the end of the output file" \
- 1 $PROGRAM_EXEC restore -S 512 -d diff -o out
-
-rm -f diff out
-
-exit 0
diff --git a/tests/400-expected_backup_output.bin b/tests/400-expected_backup_output.bin
index 10a3993..3df3237 100644
--- a/tests/400-expected_backup_output.bin
+++ b/tests/400-expected_backup_output.bin
Binary files differ
diff --git a/tests/400-successful_backup_restore.sh b/tests/400-successful_backup_restore.sh
index fb44dda..f1a07c5 100644
--- a/tests/400-successful_backup_restore.sh
+++ b/tests/400-successful_backup_restore.sh
@@ -29,7 +29,7 @@ printf '\xFF' | dd of=input bs=1 count=1 seek=$(( (512 * 3) - 1 )) conv=notrunc
# The fourth sector will have the middle byte changed
printf '\xFF' | dd of=input bs=1 count=1 seek=$(( (512 * 4) - (512 / 2) )) conv=notrunc 1>/dev/null 2>&1
-assert "" "" 0 $PROGRAM_EXEC backup -S 512 -i input -b base -o out
+assert "" "" 0 $PROGRAM_EXEC backup -i input -b base -o out
if ! files_are_the_same out 400-expected_backup_output.bin; then
echo "assert: Backup output file differs from the expected one"
@@ -44,7 +44,7 @@ if ! files_are_the_same base input; then
exit 1
fi
-assert "" "" 0 $PROGRAM_EXEC restore -S 512 -d out -o input
+assert "" "" 0 $PROGRAM_EXEC restore -d out -o input
if ! files_are_the_same input backedup_input; then
echo "assert: Cannot restore the backup"