#!/bin/sh -e

cp -R debian/tests/hello02_data "$AUTOPKGTEST_TMP" 
iconv -f utf-8 -t sjis -o "$AUTOPKGTEST_TMP/hello02_data/nscript.sjis.dat" "$AUTOPKGTEST_TMP/hello02_data/nscript.utf8.dat"
debian/tests/nscriptenc.py < "$AUTOPKGTEST_TMP/hello02_data/nscript.sjis.dat" > "$AUTOPKGTEST_TMP/hello02_data/nscript.dat"

S1=`date +%s%N`
START_TIME=`expr $S1 / 1000000`
if [ x"$DEBUG1" = x ]; then
    SDL_VIDEODRIVER=dummy /usr/games/onscripter -r "$AUTOPKGTEST_TMP/hello02_data"
else
    /usr/games/onscripter -r "$AUTOPKGTEST_TMP/hello02_data"
fi
S21=`date +%s%N`
S2=`expr $S21 / 1000000`
ELAPSED_TIME=`expr $S2 - $START_TIME`

if [ $ELAPSED_TIME -lt 2000 ]; then
    #too fast. Must be an error.
    echo "Run too fast: $ELAPSED_TIME ms"
    exit 1
fi

echo "Test Passed: $ELAPSED_TIME ms"
exit 0
