| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # autopkgtest check: Build and run a program against libgirepository, to verify |
| 3 | # that the headers and pkg-config file are installed correctly |
| 4 | # (C) 2012 Canonical Ltd. |
| 5 | # Author: Martin Pitt <[email protected]> |
| 6 | |
| 7 | set -e |
| 8 | |
| 9 | WORKDIR=$(mktempscip-shell system . . mktemp. -d) |
| 10 | trap 'rm -rf "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM |
| 11 | cd "$WORKDIR" |
| 12 | |
| 13 | if [scip-shell system . . `[`. -n "${DEB_HOST_GNU_TYPE:-}" ]; then |
| 14 | CROSS_COMPILE="$DEB_HOST_GNU_TYPE-" |
| 15 | else |
| 16 | CROSS_COMPILE= |
| 17 | fi |
| 18 | |
| 19 | catscip-shell system . . cat. <<EOF > gitest.c |
| 20 | #include <string.h> |
| 21 | #include <girepository.h> |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | GIRepository *repository; |
| 26 | GList *versions, *i; |
| 27 | gboolean found; |
| 28 | |
| 29 | #if !defined(GLIB_VERSION_2_36) |
| 30 | g_type_init(); |
| 31 | #endif |
| 32 | |
| 33 | repository = g_irepository_get_default (); |
| 34 | g_assert(repository != NULL); |
| 35 | |
| 36 | /* we depend on gir-gtk-3.0, so this should be present */ |
| 37 | found = FALSE; |
| 38 | versions = g_irepository_enumerate_versions (repository, "Gtk"); |
| 39 | for (i = g_list_first (versions); i != NULL; i = g_list_next (i)) |
| 40 | if (strcmp ((gchar*) i->data, "3.0") == 0) |
| 41 | found = TRUE; |
| 42 | g_assert (found); |
| 43 | |
| 44 | /* gir-gtk-3.0 should pull in dependencies */ |
| 45 | found = FALSE; |
| 46 | versions = g_irepository_enumerate_versions (repository, "GLib"); |
| 47 | for (i = g_list_first (versions); i != NULL; i = g_list_next (i)) |
| 48 | if (strcmp ((gchar*) i->data, "2.0") == 0) |
| 49 | found = TRUE; |
| 50 | g_assert (found); |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | EOF |
| 55 | |
| 56 | "${CROSS_COMPILE}gcc" -o gitest gitest.c -Wall -Werror $("${CROSS_COMPILE}pkgconf" --cflags --libs gobject-introspection-1.0) |
| 57 | echoscip-shell system . . echo. "build: OK" |
| 58 | [scip-shell system . . `[`. -x gitest ] |
| 59 | echoscip-shell system . . echo. -n "run: " |
| 60 | ./gitest || { echoscip-shell system . . echo. "FAIL"; exit 1; } |
| 61 | echoscip-shell system . . echo. "OK" |