test-bus-marshal.c revision 98a4c30ba117bddad3cd0934042721621a328e9a
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Lennart Poettering
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 <stdlib.h>
#include <math.h>
#ifdef HAVE_GLIB
#endif
#ifdef HAVE_DBUS
#endif
#include "log.h"
#include "util.h"
#include "sd-bus.h"
#include "bus-message.h"
#include "bus-util.h"
#include "bus-dump.h"
#include "bus-label.h"
static void test_bus_path_encode_unique(void) {
assert_se(bus_path_encode_unique(NULL, "/foo/bar", "some.sender", "a.suffix", &a) >= 0 && streq_ptr(a, "/foo/bar/some_2esender/a_2esuffix"));
assert_se(bus_path_decode_unique(a, "/foo/bar", &b, &c) > 0 && streq_ptr(b, "some.sender") && streq_ptr(c, "a.suffix"));
assert_se(bus_path_decode_unique("/foo/bar/_/_", "/foo/bar", &d, &e) > 0 && streq_ptr(d, "") && streq_ptr(e, ""));
}
static void test_bus_path_encode(void) {
}
static void test_bus_label_escape_one(const char *a, const char *b) {
assert_se(t = bus_label_escape(a));
assert_se(x = bus_label_unescape(t));
assert_se(y = bus_label_unescape(b));
}
static void test_bus_label_escape(void) {
}
int r, boolean;
const char *x, *x2, *y, *z, *a, *b, *c, *d, *a_signature;
uint8_t u, v;
char *h;
char *s;
double dbl;
r = sd_bus_default_system(&bus);
if (r < 0)
return EXIT_TEST_SKIP;
assert_se(r >= 0);
r = sd_bus_message_append(m, "");
assert_se(r >= 0);
assert_se(r >= 0);
assert_se(r >= 0);
assert_se(r >= 0);
assert_se(r >= 0);
assert_se(r >= 0);
assert_se(r >= 0);
assert_se(r >= 0);
assert_se(r >= 0);
assert_se(r >= 0);
r = sd_bus_message_close_container(m);
assert_se(r >= 0);
r = sd_bus_message_append_string_space(m, 5, &s);
assert_se(r >= 0);
strcpy(s, "hallo");
assert_se(r >= 0);
assert_se(r >= 0);
assert_se(r >= 0);
r = bus_message_seal(m, 4711, 0);
assert_se(r >= 0);
bus_message_dump(m, ms, 0);
assert_se(r >= 0);
assert_se(h);
free(h);
#ifdef HAVE_GLIB
{
GDBusMessage *g;
char *p;
#if !defined(GLIB_VERSION_2_36)
g_type_init();
#endif
p = g_dbus_message_print(g, 0);
log_info("%s", p);
g_free(p);
g_object_unref(g);
}
#endif
#ifdef HAVE_DBUS
{
DBusMessage *w;
if (!w)
else
}
#endif
m = sd_bus_message_unref(m);
assert_se(r >= 0);
bus_message_dump(m, ms, 0);
assert_se(sd_bus_message_rewind(m, true) >= 0);
assert_se(r > 0);
assert_se(r > 0);
assert_se(r > 0);
assert_se(u == 3);
assert_se(v == 5);
assert_se(r > 0);
assert_se(r > 0);
r = sd_bus_message_read_basic(m, 's', &s);
assert_se(r > 0);
assert_se(r > 0);
assert_se(r > 0);
assert_se(r > 0);
assert_se(r == 0);
assert_se(r >= 0);
r = sd_bus_message_rewind(m, true);
assert_se(r >= 0);
r = sd_bus_message_copy(copy, m, true);
assert_se(r >= 0);
assert_se(r >= 0);
r = sd_bus_message_rewind(m, true);
assert_se(r >= 0);
r = sd_bus_message_skip(m, "ssasg");
assert_se(r > 0);
r = sd_bus_message_skip(m, "sass");
assert_se(r >= 0);
r = sd_bus_message_skip(m, "a{yv}");
assert_se(r >= 0);
assert_se(r > 0);
r = sd_bus_message_enter_container(m, 0, NULL);
assert_se(r > 0);
r = sd_bus_message_read(m, "(ss)", &x, &y);
assert_se(r > 0);
r = sd_bus_message_read(m, "(ss)", &a, &b);
assert_se(r > 0);
r = sd_bus_message_read(m, "(ss)", &c, &d);
assert_se(r > 0);
r = sd_bus_message_read(m, "(ss)", &x, &y);
assert_se(r == 0);
r = sd_bus_message_exit_container(m);
assert_se(r >= 0);
return 0;
}