| #!/bin/bash |
| set -eu |
| THIS="$(readlink -f "$0")" |
| THISDIR="$(dirname "${THIS}")" |
| SRCDIR="$(dirname "${THISDIR}")" |
| SUT="${SRCDIR}/makeself.sh" |
| |
| # Test that corrupted archives actually fail validation |
| |
| cd "$THISDIR" |
| |
| setupTests() { |
| temp_path="$(mktemp -dt appendtest.XXXXXX)" |
| cd "$temp_path" |
| mkdir -p archive |
| cp -a "$SRCDIR" archive/ |
| "$SUT" "$*" archive makeself-test.run "Test $*" echo Testing --tar-extra="--exclude .git" |
| } |
| |
| testExtraBytes() { |
| setupTests --sha256 |
| |
| ./makeself-test.run --check |
| assertEquals $? 0 |
| |
| echo "Adding a bunch of random characters at the end!!" >> makeself-test.run |
| |
| ./makeself-test.run --check |
| assertNotEquals $? 0 |
| } |
| |
| testTruncated() { |
| setupTests --sha256 |
| |
| ./makeself-test.run --check |
| assertEquals $? 0 |
| |
| dd if=makeself-test.run of=truncated.run bs=1 count=34303 |
| bash truncated.run --check |
| assertNotEquals $? 0 |
| } |
| |
| # Load and run shUnit2. |
| source "./shunit2/shunit2" |
| |