Gerbera/tests/test.sh
2026-06-23 09:56:21 +09:00

20 lines
627 B
Bash

#!/bin/sh
set -eu
bin="${GERBERA_BIN:-./build/gerbera}"
work="${TMPDIR:-/tmp}/gerbera-test-$$"
mkdir "$work"
trap 'rm -rf "$work"' EXIT HUP INT TERM
printf 'Array-based encryption test\n\000\001\377' > "$work/plain.bin"
"$bin" encrypt "$work/plain.bin" "$work/encrypted.gerbera" 'test-password'
"$bin" decrypt "$work/encrypted.gerbera" "$work/decrypted.bin" 'test-password'
cmp "$work/plain.bin" "$work/decrypted.bin"
if "$bin" decrypt "$work/encrypted.gerbera" "$work/wrong.bin" 'wrong-password'; then
echo "wrong password unexpectedly succeeded" >&2
exit 1
fi
test ! -e "$work/wrong.bin"
echo "All tests passed."