#!/bin/sh

set -e
at_exit() {
    set +x
    echo "info: test exiting, removing test files"
    rm -f test-simple-build-link-prog test-simple-build-link.c
}
trap at_exit INT TERM EXIT
set -x

cd $AUTOPKGTEST_TMP

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

# This is just a simple code example to compile to verify the headers
# exist, are includable and the library is linkable.  It should be
# extended to really use the library to test a bit more of the
# package.
cat > test-simple-build-link.c <<EOF
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fishsound/fishsound.h>
int
main (int argc, char ** argv)
{
  FishSound * fsound;

  /* quiet down compiler about unused arguments */
  if (1 < argc)
      return (strlen(argv[1]) != 0);

  fsound = fish_sound_new (FISH_SOUND_DECODE, NULL);
  fish_sound_set_interleave (fsound, 1);
  fish_sound_delete (fsound);

  printf("info: program ran as it should\n");

  exit (0);
}
EOF

gcc -o test-simple-build-link-prog -Wall -Wextra test-simple-build-link.c -lfishsound

${VALGRIND} ./test-simple-build-link-prog
