#!/bin/sh

set -e

dir=`dirname "$0"`

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

cleanup() {
  ex=$?
  rm -f lib25519-test 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 lib25519-test "${dir}/../../command/lib25519-test.c" "${LIBDIR}/lib25519.a" -lrandombytes
./lib25519-test

exit 0
