| 1 |
#!/bin/sh |
| 2 |
# autopkgtest check: Build and run a program against libsecret, to verify |
| 3 |
# that the headers and pkg-config file are installed correctly |
| 4 |
# (C) 2012 Canonical Ltd. |
| 5 |
# (C) 2018-2019 Simon McVittie |
| 6 |
# Authors: Martin Pitt, Simon McVittie |
| 7 |
|
| 8 |
set -eux |
| 9 |
|
| 10 |
WORKDIR="$(mktemp -d)" |
| 11 |
export HOME="$WORKDIR" |
| 12 |
export XDG_RUNTIME_DIR="$WORKDIR" |
| 13 |
trap 'cd /; rm -rf "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM |
| 14 |
|
| 15 |
if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then |
| 16 |
CROSS_COMPILE="$DEB_HOST_GNU_TYPE-" |
| 17 |
else |
| 18 |
CROSS_COMPILE= |
| 19 |
fi |
| 20 |
|
| 21 |
cd "$WORKDIR" |
| 22 |
cat <<EOF > test.c |
| 23 |
#include <libsecret/secret.h> |
| 24 |
|
| 25 |
int main(void) |
| 26 |
{ |
| 27 |
g_assert_cmpuint(SECRET_TYPE_ITEM, !=, G_TYPE_INVALID); |
| 28 |
return 0; |
| 29 |
} |
| 30 |
EOF |
| 31 |
|
| 32 |
for package in libsecret-1 libsecret-unstable; do |
| 33 |
case "$package" in |
| 34 |
(libsecret-unstable) |
| 35 |
cflags=-DSECRET_API_SUBJECT_TO_CHANGE |
| 36 |
;; |
| 37 |
(*) |
| 38 |
cflags= |
| 39 |
;; |
| 40 |
esac |
| 41 |
|
| 42 |
# Deliberately word-splitting pkg-config's output and $cflags: |
| 43 |
# shellcheck disable=SC2046 |
| 44 |
${CROSS_COMPILE}gcc $cflags -o "${package}-test" test.c $(${CROSS_COMPILE}pkg-config --cflags --libs "$package") |
| 45 |
echo "build ($package): OK" |
| 46 |
[ -x "${package}-test" ] |
| 47 |
dbus-run-session -- "./${package}-test" |
| 48 |
echo "run ($package): OK" |
| 49 |
done |