Files
makeself/test/corrupttest
Alexandr Reshetnikov a4f40a21ae move from bashunit to shunit2. refactoring tests. (#272)
* move from bashunit to shunit2

move run-tests.sh to test

simplify build.yml

* back shunit2 to submodule
2022-06-11 01:52:34 -07:00

46 lines
941 B
Bash

#!/bin/bash
set -eu
THIS="$(realpath "$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"