| 1 | #!/bin/sh |
| 2 | |
| 3 | set -e |
| 4 | at_exit() { |
| 5 | set +x |
| 6 | echo "info: test exiting, removing $WORKDIR" |
| 7 | rm -rf $WORKDIR |
| 8 | } |
| 9 | WORKDIR=$(mktemp -d) |
| 10 | trap at_exit INT TERM EXIT |
| 11 | set -x |
| 12 | |
| 13 | if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then |
| 14 | CROSS_COMPILE="$DEB_HOST_GNU_TYPE-" |
| 15 | else |
| 16 | CROSS_COMPILE= |
| 17 | fi |
| 18 | |
| 19 | cd $WORKDIR |
| 20 | |
| 21 | if type valgrind >/dev/null 2>&1 ; then |
| 22 | VALGRIND=valgrind |
| 23 | fi |
| 24 | |
| 25 | # This is just a simple code example to compile to verify the headers |
| 26 | # exist, are includable and the library is linkable. It should be |
| 27 | # extended to really use the library to test a bit more of the |
| 28 | # package. |
| 29 | cat <<EOF > example.c |
| 30 | #include <string.h> |
| 31 | #include <stdio.h> |
| 32 | #include <theora/theoradec.h> |
| 33 | #include <vorbis/codec.h> |
| 34 | int main(int argc, char *argv[]) |
| 35 | { |
| 36 | static th_info ti; |
| 37 | |
| 38 | /* quiet down compiler about unused arguments */ |
| 39 | if (1 < argc) |
| 40 | return (strlen(argv[1]) != 0); |
| 41 | th_info_init(&ti); |
| 42 | |
| 43 | printf("info: program ran as it should\n"); |
| 44 | return (0); |
| 45 | } |
| 46 | EOF |
| 47 | |
| 48 | ${CROSS_COMPILE}gcc -o test -Wall -Wextra example.c -ltheoradec |
| 49 | |
| 50 | ${VALGRIND} ./test |