#!/bin/sh
# autopkgtest check: Build and run a program against libupower-glib, to verify
# that the headers and pkg-config file are installed correctly
# (C) 2013 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > libupowertest.c
#include <string.h>
#include <upower.h>

int main()
{
    UpClient *client = up_client_new ();
    g_assert_cmpint (strlen (up_client_get_daemon_version (client)), >, 4);
    /* note, this is marked as deprecated upstream */
    up_client_get_can_suspend (client);
    return 0;
}
EOF

gcc -o libupowertest libupowertest.c `pkg-config --cflags --libs upower-glib` -Wall -Werror
echo "build: OK"
[ -x libupowertest ]
env G_DEBUG="fatal-warnings fatal-criticals" ./libupowertest
echo "run: OK"
