#!/bin/sh
#
# Try to build and run the example code.  Provide input on both stdin
# and as first argument as the programs seem to handle either or both.
# The goal is to verify that it is possible to link with the libvorbis
# library and run the resulting binaries.

set -e

retval=0
#cd $AUTOPKGTEST_TMP

# We don't want plugins from the build directory for the
# installed package.
rm -f pev.conf

if type valgrind ; then
    VALGRIND=valgrind
else
    VALGRIND=
fi

TESTEXE="/usr/share/win32/gzip.exe"

# Detect problem on s390x
if [ ! -e "$TESTEXE" ] ; then
    echo "error: missing gzip.exe.  No such file in gzip-win32?"
    dpkg -L gzip-win32
    exit 1
fi

if $VALGRIND pesec "$TESTEXE" | grep ASLR; then
    echo "success: pesec reported ASLR status"
else
    echo "error: pesec did not report ASLR status"
    retval=1
fi

if $VALGRIND pehash "$TESTEXE" | grep sha256:; then
    echo "success: pehash reported ASLR status"
else
    echo "error: pehash did not report ASLR status"
    retval=1
fi

exit $retval
