test-bus-zero-copy.c revision f2769777c8e8ad32b0b19cd540d2f742bda4457f
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering This file is part of systemd.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering Copyright 2013 Lennart Poettering
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering systemd is free software; you can redistribute it and/or modify it
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering under the terms of the GNU Lesser General Public License as published by
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering (at your option) any later version.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering systemd is distributed in the hope that it will be useful, but
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering Lesser General Public License for more details.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering You should have received a copy of the GNU Lesser General Public License
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering _cleanup_free_ char *bus_name = NULL, *address = NULL;
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering bus_ref = bus_kernel_create_bus("deine-mutter", false, &bus_name);
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering address = strappend("kernel:path=", bus_name);
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers r = sd_bus_message_new_method_call(b, ":1.1", "/a/path", "an.inter.face", "AMethod", &m);
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers r = sd_bus_message_open_container(m, 'r', "aysay");
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers r = sd_bus_message_append_array_space(m, 'y', FIRST_ARRAY, (void**) &p);
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers r = sd_memfd_new_and_map(&f, STRING_SIZE, (void**) &s);
599659860c770058f2eb04d578c521c16e0b1853Lennart Poettering r = sd_bus_message_append_string_memfd(m, f);
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay Sievers r = sd_memfd_new_and_map(&f, SECOND_ARRAY, (void**) &p);
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden r = sd_bus_message_append_array_memfd(m, 'y', f);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen r = sd_bus_message_enter_container(m, 'r', "aysay");
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen r = sd_bus_message_read_array(m, 'y', (const void**) &p, &l);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen for (i = 1; i < STRING_SIZE-2; i++)
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen assert_se(s[i] == (char) ('0' + (i % 10)));
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen assert_se(s[STRING_SIZE-2] == '>');
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen assert_se(s[STRING_SIZE-1] == 0);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen r = sd_bus_message_read_array(m, 'y', (const void**) &p, &l);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen assert_se(l == SECOND_ARRAY);
2667cc25896a15f82f9f1583e80d416beb1316e1Thomas Hindoe Paaboel Andersen r = sd_bus_message_exit_container(m);