#!/bin/sh -e

# Smoke test for the Gwyddion libraries.
#
# Compile a small test program against the installed libgwyddion3 headers
# and libraries and run it.  The program exercises field construction and
# statistics, serialization/deserialization round-trips and the dictionary
# container.

testdir=$(mktemp -d /tmp/gwy-test.XXXXXX)
trap 'rm -rf "$testdir"' 0 INT QUIT ABRT PIPE TERM

CC="${CC:-cc}"
if ! command -v "$CC" >/dev/null 2>&1; then
    echo "SKIP: no C compiler ($CC) available" >&2
    exit 77
fi

srcdir=$(dirname "$0")
$CC -o "$testdir/gwy-smoke-test" \
    "$srcdir/gwy-smoke-test.c" \
    $(pkg-config --cflags --libs libgwyddion3)

"$testdir/gwy-smoke-test"
