#!/bin/sh
#

# Some simple tests of pev against gzip-win32 PE executable

set -e

retval=0

# 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 hash"
else
    echo "error: pehash did not report hash"
    retval=1
fi

exit $retval
