1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#!/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"
|