test-bus-gvariant.c revision 151b9b9662a90455262ce575a8a8ae74bf4ff336
/*-*- 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/>.
***/
#ifdef HAVE_GLIB
#include <glib.h>
#endif
#include "util.h"
#include "sd-bus.h"
#include "bus-gvariant.h"
#include "bus-util.h"
#include "bus-internal.h"
#include "bus-message.h"
#include "bus-dump.h"
static void test_bus_gvariant_is_fixed_size(void) {
}
static void test_bus_gvariant_get_size(void) {
}
static void test_bus_gvariant_get_alignment(void) {
}
static void test_marshal(void) {
_cleanup_free_ void *blob;
assert_se(sd_bus_message_new_method_call(bus, &m, "a.service.name", "/an/object/path/which/is/really/really/long/so/that/we/hit/the/eight/bit/boundary/by/quite/some/margin/to/test/this/stuff/that/it/really/works", "an.interface.name", "AMethodName") >= 0);
"a(usv)", 3,
4712, "second-string-parameter", "(a(si))", 2, "Y", 5, "Z", 6,
4713, "third-string-parameter", "(uu)", 1, 2) >= 0);
#ifdef HAVE_GLIB
{
GVariant *v;
char *t;
#if !defined(GLIB_VERSION_2_36)
g_type_init();
#endif
v = g_variant_new_from_data(G_VARIANT_TYPE("(yyyyuuua(yv))"), m->header, sizeof(struct bus_header) + BUS_MESSAGE_FIELDS_SIZE(m), false, NULL, NULL);
t = g_variant_print(v, TRUE);
printf("%s\n", t);
g_free(t);
g_variant_unref(v);
v = g_variant_new_from_data(G_VARIANT_TYPE("(a(usv))"), m->body.data, BUS_MESSAGE_BODY_SIZE(m), false, NULL, NULL);
t = g_variant_print(v, TRUE);
printf("%s\n", t);
g_free(t);
g_variant_unref(v);
}
#endif
m = sd_bus_message_unref(m);
}
test_marshal();
return 0;
}