test-bus-proxy.c revision 4afd3348c7506dd1d36305b7bcb9feb8952b9d6b
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2015 David Herrmann <dh.herrmann@gmail.com>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include "sd-bus.h"
#include "alloc-util.h"
#include "bus-dump.h"
#include "bus-kernel.h"
#include "bus-util.h"
#include "log.h"
#include "util.h"
typedef struct {
const char *sender;
int matched_acquired;
const char *name;
int r;
assert_se(r >= 0);
return 0;
return 1;
}
static void test_proxy_matched(void) {
TestProxyMatch match = {};
const char *me;
int r;
/* open bus 'a' */
r = sd_bus_new(&a);
assert_se(r >= 0);
r = sd_bus_set_address(a, "unix:path=/var/run/dbus/system_bus_socket");
assert_se(r >= 0);
r = sd_bus_set_bus_client(a, true);
assert_se(r >= 0);
r = sd_bus_start(a);
assert_se(r >= 0);
r = sd_bus_get_unique_name(a, &me);
assert_se(r >= 0);
"member='NameAcquired',"
"destination='",
me,
"'",
NULL);
assert_se(r >= 0);
assert_se(r >= 0);
/* barrier to guarantee proxy/dbus-daemon handled the previous data */
r = sd_bus_call_method(a,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"GetId",
assert_se(r >= 0);
/* now we can be sure the Name* signals were sent */
do {
r = sd_bus_process(a, NULL);
} while (r > 0);
assert_se(r == 0);
}
return EXIT_TEST_SKIP;
return EXIT_SUCCESS;
}