1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#!/bin/sh
set -e
exec 2>&1
set -u
if [ -z "${HOME-}" ] || ! [ -w "${HOME}" ]; then
export HOME="${AUTOPKGTEST_TMP}"
fi
cd "$AUTOPKGTEST_TMP"
if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
else
CROSS_COMPILE=
fi
echo "1..2"
cat > connect.c <<'EOF'
#include <stdio.h>
#include <dbus/dbus-glib.h>
int main (void)
{
GError *error = NULL;
DBusGConnection *connection;
connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (connection == NULL) {
g_printerr("%s #%d: %s",
g_quark_to_string(error->domain),
error->code,
error->message);
g_clear_error(&error);
return 1;
}
dbus_g_connection_unref(connection);
return 0;
}
EOF
# Deliberately word-splitting, that's how pkg-config works:
# shellcheck disable=SC2046
"${CROSS_COMPILE}gcc" -o connect connect.c $("${CROSS_COMPILE}pkg-config" --cflags --libs dbus-glib-1)
test -x connect
dbus-run-session -- ./connect
echo "ok 1"
echo "# everything seems OK"
|