libtpms/tests/base64decode.sh
Stefan Berger 04971a0fb9 tests: run a lot less tests in base64decode.sh
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-05-07 16:01:48 -04:00

39 lines
678 B
Bash
Executable File

#!/usr/bin/env bash
input=$(mktemp)
binary=$(mktemp)
trap "rm -f $input $binary" EXIT
function sseq()
{
for ((i = $1; i < $2; i=i<<1)); do
echo $i
done
}
function do_base64()
{
if [ -n "$(type -p base64)" ]; then
base64 $1
elif [ -n "$(type -p uuencode)" ]; then
uuencode -m $1 data | sed 1d | sed '$d'
else
echo "No tool found for base64 encoding." >&2
exit 1
fi
}
for i in $(sseq 1 1024) 2048 10240;
do
echo $i
dd if=/dev/urandom of=$binary bs=1 count=$i &>/dev/null
echo "-----BEGIN INITSTATE-----" > $input
do_base64 $binary >> $input
echo "-----END INITSTATE-----" >> $input
./base64decode $input $binary
if [ $? -ne 0 ]; then
exit 1
fi
done