#!/bin/sh
TMP=${AUTOPKGTEST_TMP:-.}

cat <<EOF > test.dat
1 4 0 0 0 1 0 0 0 1 0 0 0 1 44728.dat
EOF

xvfb-run leocad test.dat -i -w 100 -h 100 2> $TMP/stderr
retval=$?
cat $TMP/stderr

if [ $retval -ne 0 ]; then
    echo "failure: exit code should be 0, not $retval"
    exit 1
fi

if grep 'could not find a compatible Parts Library' $TMP/stderr; then
    echo "failure: part library not found"
    exit 1
fi

if [ -f test.png ]; then
    echo "success: rendering part worked"
    exit 0
else
    echo "failure: rendering part failed"
    exit 1
fi
