summaryrefslogtreecommitdiffstats
path: root/tests/base64decode.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/base64decode.sh')
-rwxr-xr-xtests/base64decode.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/base64decode.sh b/tests/base64decode.sh
new file mode 100755
index 0000000..eef96fe
--- /dev/null
+++ b/tests/base64decode.sh
@@ -0,0 +1,38 @@
+#!/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