File: build

package info (click to toggle)
libnotify 0.8.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 844 kB
  • sloc: xml: 8,298; ansic: 3,228; sh: 63; python: 23; makefile: 22; javascript: 6
file content (94 lines) | stat: -rw-r--r-- 2,341 bytes parent folder | download | duplicates (3)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
# autopkgtest check: Build and run a program against libnotify, to verify that
# the headers and pkg-config file are installed correctly
# (C) 2013 Vibhav Pant
# (C) 2022 Marco Trevisan
# Author: Vibhav Pant <vibhavp@ubuntu.com>
# Author: Marco Trevisan <marco@ubuntu.com>

set -e

WORKDIR=$(mktemp -d)
NOTIFICATION_DAEMON_PID=0

trap 'kill "$NOTIFICATION_DAEMON_PID"; rm -rf "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM
cd "$WORKDIR"

if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
    CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
else
    CROSS_COMPILE=
fi

cat <<EOF > libnotify_test.c
#include <libnotify/notify.h>

int main(void)
{
	NotifyNotification *notify;
	GError *error = NULL;
	GList *caps;
	int id, prev_id;

	g_assert_true(notify_init("autopkgtest"));
	g_assert_true(notify_is_initted());

	caps = notify_get_server_caps();
	g_assert_cmpuint(g_list_length(caps), >, 0);
	g_assert_true(g_list_find_custom(caps, "body",
					 (GCompareFunc) g_ascii_strcasecmp));
	g_clear_list(&caps, g_free);

	notify = notify_notification_new("autopkgtest",
					 "Testing libnotify",
					 NULL);
	notify_notification_set_urgency(notify, NOTIFY_URGENCY_NORMAL);

	notify_notification_set_timeout(notify, 500);
	g_object_get(G_OBJECT(notify), "id", &id, NULL);
	g_assert_cmpint(id, ==, 0);

	notify_notification_show(notify, &error);
	g_assert_no_error(error);

	g_object_get(G_OBJECT(notify), "id", &id, NULL);
	g_assert_cmpint(id, >, 0);
	g_object_unref(notify);

	prev_id = id;
	notify = notify_notification_new("autopkgtest2",
					 "Testing libnotify2",
					 NULL);

	notify_notification_show(notify, &error);
	g_object_get(G_OBJECT(notify), "id", &id, NULL);
	g_assert_no_error(error);
	g_assert_cmpint(id, !=, prev_id);
	g_object_unref(notify);

	notify_uninit();
	return 0;
}
EOF

# deliberately word-splitting pkg-config output:
# shellcheck disable=SC2046
"${CROSS_COMPILE}gcc" -o libnotify_test libnotify_test.c \
$("${CROSS_COMPILE}pkg-config" --cflags --libs libnotify) -Wall -Werror
echo "build: OK"

[ -x libnotify_test ]

python3 -m dbusmock -t notification_daemon &
NOTIFICATION_DAEMON_PID=$!

while ! dbus-send --session --print-reply \
	--dest=org.freedesktop.Notifications \
	/org/freedesktop/Notifications \
	org.freedesktop.Notifications.GetCapabilities; do
	sleep 0.5
done

env G_MESSAGES_DEBUG=all ./libnotify_test

echo "run: OK"