Browse Source

Fix tests on FreeBSD

Also break them on Linux, heh.
master
Teran McKinney 11 months ago
parent
commit
2b0e9ea621
  1. 20
      test.sh

20
test.sh

@ -36,7 +36,7 @@ cleanup() {
rm -r test_dir
}
trap cleanup $(seq 1 64)
trap cleanup $(seq 1 15)
fail() {
echo "FAIL: $1"
@ -44,8 +44,16 @@ fail() {
exit 1
}
sha256() {
sha256sum "$1" | cut -d ' ' -f 1
sha256file() {
# Linux
# sha256filesum "$1" | cut -d ' ' -f 1
# FreeBSD
if [ "$1" = "-" ]; then
# stdin
sha256 | awk '{print $NF}'
else
sha256 "$1" | awk '{print $NF}'
fi
}
# Be sure we are running.
@ -78,9 +86,9 @@ output=$(curl -s --show-error --fail "http://localhost:2323/read/$pasteid" || tr
pasteid=$(curl -s --show-error --fail --data-urlencode data@- "http://localhost:2323"/write < burnpaste.go)
[ "$pasteid" != "$(sha256 burnpaste.go)" ] && fail 'pasteid does not match for burnpaste.go.'
[ "$pasteid" != "$(sha256file burnpaste.go)" ] && fail 'pasteid does not match for burnpaste.go.'
output_checksum=$(curl -s --show-error --fail "http://localhost:2323/read/$pasteid" | sha256 -)
output_checksum=$(curl -s --show-error --fail "http://localhost:2323/read/$pasteid" | sha256file -)
[ "$pasteid" != "$output_checksum" ] && fail 'output does not match for burnpaste.go.'
@ -94,7 +102,7 @@ yes | head -c 4097 | curl -s --show-error --fail --data-urlencode data@- "http:/
[ "$(wc -l test_dir/309a1668b23adc98b0ec1b67d55bdca1e89e9d81c0930d5baf9b85df85d76ee0)" != "4096" ] || fail "4096 byte file wrong length or checksum???"
output_checksum=$(curl -s --show-error --fail "http://localhost:2323/read/309a1668b23adc98b0ec1b67d55bdca1e89e9d81c0930d5baf9b85df85d76ee0" | sha256 -)
output_checksum=$(curl -s --show-error --fail "http://localhost:2323/read/309a1668b23adc98b0ec1b67d55bdca1e89e9d81c0930d5baf9b85df85d76ee0" | sha256file -)
[ "309a1668b23adc98b0ec1b67d55bdca1e89e9d81c0930d5baf9b85df85d76ee0" != "$output_checksum" ] && fail 'output does not match for 4096 byte paste'

Loading…
Cancel
Save