#!/bin/sh

set -e

# Switch to the test directory
cd $(dirname $0)

at_exit() {
    echo "info: test exiting"
}
trap at_exit INT TERM EXIT

PROG="$AUTOPKGTEST_TMP/test-example-code-program"
c++ -Wall -Werror test-example-code.cc  -lmstch -o "$PROG" 2>&1

if type valgrind > /dev/null 2>&1 ; then
    VALGRIND="valgrind"
fi

if $VALGRIND "$PROG" | diff - test-example-code-expected.out; then
  echo "success: program produced expected output"
else
  echo "failure: program did not produce expected output"
fi

rm -f "$PROG"
