| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Exit immediately if any command fails. |
| 4 |
# https://stackoverflow.com/a/2871034 |
| 5 |
set -e -u -x |
| 6 |
|
| 7 |
|
| 8 |
# Normal |
| 9 |
./xxhsum ./Makefile > ./.test.xxh |
| 10 |
./xxhsum --check ./.test.xxh |
| 11 |
|
| 12 |
|
| 13 |
# Missing, expect error |
| 14 |
# (1) Create checksum file. |
| 15 |
# (2) Remove one of them. |
| 16 |
# (3) --check it |
| 17 |
# (4) Expect NG (missing file) |
| 18 |
cp Makefile .test.makefile |
| 19 |
./xxhsum ./.test.makefile > ./.test.xxh |
| 20 |
rm ./.test.makefile |
| 21 |
! ./xxhsum --check ./.test.xxh # Put '!' for expecting error |
| 22 |
|
| 23 |
|
| 24 |
# Missing, --ignore-missing |
| 25 |
# (1) Create checksum file. |
| 26 |
# (2) Remove one of them. |
| 27 |
# (3) --check it with --ignore-missing. |
| 28 |
# (4) Expect OK |
| 29 |
|
| 30 |
cp Makefile .test.makefile |
| 31 |
./xxhsum Makefile ./.test.makefile > ./.test.xxh |
| 32 |
rm ./.test.makefile |
| 33 |
./xxhsum --check --ignore-missing ./.test.xxh |
| 34 |
|
| 35 |
|
| 36 |
# Missing, --ignore-missing, expect error |
| 37 |
# (1) Create checksum file. |
| 38 |
# (2) Remove all of them. |
| 39 |
# (3) --check it with --ignore-missing. |
| 40 |
# (4) Expect NG (no file was verified). |
| 41 |
|
| 42 |
cp Makefile .test.makefile |
| 43 |
./xxhsum ./.test.makefile > ./.test.xxh |
| 44 |
rm ./.test.makefile |
| 45 |
! ./xxhsum --check --ignore-missing ./.test.xxh # Put '!' for expecting error |
| 46 |
|
| 47 |
|
| 48 |
# Cleanup |
| 49 |
( rm ./.test.* ) || true |
| 50 |
|
| 51 |
echo OK |