diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/002-missing_arguments.sh | 4 | ||||
| -rw-r--r-- | tests/003-too_many_arguments.sh | 4 | ||||
| -rw-r--r-- | tests/004-unknown_option.sh | 4 | ||||
| -rw-r--r-- | tests/005-missing_argument_for_option.sh | 8 | ||||
| -rw-r--r-- | tests/006-incorrect_buffer_size.sh | 12 | ||||
| -rw-r--r-- | tests/007-incorrect_sector_size.sh | 12 | ||||
| -rw-r--r-- | tests/100-cannot_open_files.sh | 6 | ||||
| -rw-r--r-- | tests/200-input_and_reference_size_differs.sh | 2 | ||||
| -rw-r--r-- | tests/201-input_or_reference_size_is_not_multiple_of_sector_size.sh | 2 | ||||
| -rw-r--r-- | tests/300-incorrect_reference_file.sh | 8 | ||||
| -rw-r--r-- | tests/400-successful_backup_restore.sh | 4 |
11 files changed, 33 insertions, 33 deletions
diff --git a/tests/002-missing_arguments.sh b/tests/002-missing_arguments.sh index a8cb13c..c3aaa1b 100644 --- a/tests/002-missing_arguments.sh +++ b/tests/002-missing_arguments.sh @@ -4,7 +4,7 @@ source ./assert.sh PROGRAM_EXEC="$1" -assert "Usage" "missing arguments" 1 $PROGRAM_EXEC backup -assert "Usage" "missing arguments" 1 $PROGRAM_EXEC restore +assert "Usage" "missing input file" 1 $PROGRAM_EXEC backup +assert "Usage" "missing diff file" 1 $PROGRAM_EXEC restore exit 0 diff --git a/tests/003-too_many_arguments.sh b/tests/003-too_many_arguments.sh index 3bdc55f..2891afd 100644 --- a/tests/003-too_many_arguments.sh +++ b/tests/003-too_many_arguments.sh @@ -4,7 +4,7 @@ source ./assert.sh PROGRAM_EXEC="$1" -assert "Usage" "too many arguments" 1 $PROGRAM_EXEC backup arg1 arg2 arg3 arg4 -assert "Usage" "too many arguments" 1 $PROGRAM_EXEC restore arg1 arg2 arg3 +assert "Usage" "too many arguments" 1 $PROGRAM_EXEC backup -i arg1 -b arg2 -o arg3 arg4 +assert "Usage" "too many arguments" 1 $PROGRAM_EXEC restore -d arg1 -o arg2 arg3 exit 0 diff --git a/tests/004-unknown_option.sh b/tests/004-unknown_option.sh index 4a03a37..452d904 100644 --- a/tests/004-unknown_option.sh +++ b/tests/004-unknown_option.sh @@ -4,7 +4,7 @@ source ./assert.sh PROGRAM_EXEC="$1" -assert "Usage" "unknown option '-x'" 1 $PROGRAM_EXEC backup -x in base out -assert "Usage" "unknown option '-x'" 1 $PROGRAM_EXEC restore -x diff out +assert "Usage" "unknown option '-x'" 1 $PROGRAM_EXEC backup -x -i in -b base -o out +assert "Usage" "unknown option '-x'" 1 $PROGRAM_EXEC restore -x -d diff -o out exit 0 diff --git a/tests/005-missing_argument_for_option.sh b/tests/005-missing_argument_for_option.sh index aa7a899..b519513 100644 --- a/tests/005-missing_argument_for_option.sh +++ b/tests/005-missing_argument_for_option.sh @@ -4,10 +4,10 @@ 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 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 +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 5e59952..1dfbc24 100644 --- a/tests/006-incorrect_buffer_size.sh +++ b/tests/006-incorrect_buffer_size.sh @@ -4,12 +4,12 @@ source ./assert.sh PROGRAM_EXEC="$1" -assert "Usage" "incorrect sector size" 1 $PROGRAM_EXEC backup -s abc123 in base out -assert "Usage" "sector size cannot be 0" 1 $PROGRAM_EXEC backup -s 0 in base out -assert "Usage" "sector size cannot larger than buffer size" 1 $PROGRAM_EXEC backup -s 2 -b 1 in base out +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 sector size" 1 $PROGRAM_EXEC restore -s abc123 diff out -assert "Usage" "sector size cannot be 0" 1 $PROGRAM_EXEC restore -s 0 diff out -assert "Usage" "sector size cannot larger than buffer size" 1 $PROGRAM_EXEC restore -s 2 -b 1 diff 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 exit 0 diff --git a/tests/007-incorrect_sector_size.sh b/tests/007-incorrect_sector_size.sh index a8dc956..5d8a689 100644 --- a/tests/007-incorrect_sector_size.sh +++ b/tests/007-incorrect_sector_size.sh @@ -4,12 +4,12 @@ source ./assert.sh PROGRAM_EXEC="$1" -assert "Usage" "incorrect buffer size" 1 $PROGRAM_EXEC backup -b abc123 in base out -assert "Usage" "buffer size cannot be 0" 1 $PROGRAM_EXEC backup -b 0 in base out -assert "Usage" "buffer size is not multiple of sector size" 1 $PROGRAM_EXEC backup -b 3 -s 2 in base 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" "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 diff out -assert "Usage" "buffer size cannot be 0" 1 $PROGRAM_EXEC restore -b 0 diff out -assert "Usage" "buffer size is not multiple of sector size" 1 $PROGRAM_EXEC restore -b 3 -s 2 diff 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 64d2a87..34cf3e0 100644 --- a/tests/100-cannot_open_files.sh +++ b/tests/100-cannot_open_files.sh @@ -6,18 +6,18 @@ PROGRAM_EXEC="$1" rm -f input base out touch base out -assert "" "cannot get size of input file" 1 $PROGRAM_EXEC backup input base out +assert "" "cannot get size of 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 input base out +assert "" "cannot get size of base file" 1 $PROGRAM_EXEC backup -i input -b base -o out rm -f input base out rmdir outdir 2>/dev/null touch input base mkdir outdir chmod -w outdir -assert "" "cannot open output file" 1 $PROGRAM_EXEC backup input base outdir/out +assert "" "cannot open output file" 1 $PROGRAM_EXEC backup -i input -b base -o outdir/out rm -f input base out rmdir outdir diff --git a/tests/200-input_and_reference_size_differs.sh b/tests/200-input_and_reference_size_differs.sh index ca0f368..dceb63b 100644 --- a/tests/200-input_and_reference_size_differs.sh +++ b/tests/200-input_and_reference_size_differs.sh @@ -8,7 +8,7 @@ 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 input base out +assert "" "input file and base file differ in size" 1 $PROGRAM_EXEC backup -i input -b base -o out rm -f input base out 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 index abfb3c5..d7c6aa6 100644 --- 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 @@ -9,7 +9,7 @@ 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 input base out + 1 $PROGRAM_EXEC backup -S 512 -i input -b base -o out rm -f input base out diff --git a/tests/300-incorrect_reference_file.sh b/tests/300-incorrect_reference_file.sh index b15ee12..c250541 100644 --- a/tests/300-incorrect_reference_file.sh +++ b/tests/300-incorrect_reference_file.sh @@ -6,11 +6,11 @@ PROGRAM_EXEC="$1" rm -f diff out touch diff out -assert "" "diff file is empty" 1 $PROGRAM_EXEC restore 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 diff out + 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 @@ -21,7 +21,7 @@ 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 diff out + 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 @@ -30,7 +30,7 @@ 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 diff out + 1 $PROGRAM_EXEC restore -S 512 -d diff -o out rm -f diff out diff --git a/tests/400-successful_backup_restore.sh b/tests/400-successful_backup_restore.sh index 8274964..fb44dda 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 input base out +assert "" "" 0 $PROGRAM_EXEC backup -S 512 -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 out input +assert "" "" 0 $PROGRAM_EXEC restore -S 512 -d out -o input if ! files_are_the_same input backedup_input; then echo "assert: Cannot restore the backup" |
