#!/bin/sh

set -e

dir=`dirname "$0"`

# change directory to $AUTOPKGTEST_TMP
cd "${AUTOPKGTEST_TMP}"

cleanup() {
  ex=$?
  rm -f testmceliece.bin crypto_uint*.h
  exit "${ex}"
}
trap "cleanup" EXIT TERM INT

CC="cc -O -Wl,-z,noexecstack -I./"
LIBDIR="/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`"

# create crypto_uint*.h files
for x in 8 32 64; do
  (
    echo '#include <stdint.h>'
    echo "typedef uint${x}_t crypto_uint${x};"
  ) > "crypto_uint${x}.h"
done

${CC} -o testmceliece.bin "${dir}/../../command/mceliece-test.c" -lmceliece -lrandombytes
./testmceliece.bin

exit 0
