#!/bin/sh

rm tests/A
rm tests/A.key

times=$1
fail=0
ulimit -c unlimited

while [ $times -ne 0 -a $fail -eq 0 ]
do
    dd if=/dev/urandom count=$2 bs=1 >> tests/A 2>/dev/null
    times=$((times-1))
#rm tests/A.*
    ./rsyncrypto tests/A tests/A.enc tests/A.key tests/cert.crt
    ./rsyncrypto -d tests/A.dec tests/A.enc tests/A.key tests/cert.crt
    diff tests/A tests/A.dec
    fail=$?
done

if [ $fail -ne 0 ]
then
    echo "Test failed on length $(( ($1-$times)*$2 ))"
fi
