Branch data Line data Source code
1 : : /* SPDX-License-Identifier: LGPL-2.1+ */
2 : :
3 : : #include <math.h>
4 : : #include <stdlib.h>
5 : :
6 : : #if HAVE_GLIB
7 : : #include <gio/gio.h>
8 : : #endif
9 : :
10 : : #if HAVE_DBUS
11 : : #include <dbus/dbus.h>
12 : : #endif
13 : :
14 : : #include "sd-bus.h"
15 : :
16 : : #include "alloc-util.h"
17 : : #include "bus-dump.h"
18 : : #include "bus-label.h"
19 : : #include "bus-message.h"
20 : : #include "bus-util.h"
21 : : #include "escape.h"
22 : : #include "fd-util.h"
23 : : #include "fileio.h"
24 : : #include "log.h"
25 : : #include "tests.h"
26 : : #include "util.h"
27 : :
28 : 4 : static void test_bus_path_encode_unique(void) {
29 : 4 : _cleanup_free_ char *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
30 : :
31 [ + - - + ]: 4 : assert_se(bus_path_encode_unique(NULL, "/foo/bar", "some.sender", "a.suffix", &a) >= 0 && streq_ptr(a, "/foo/bar/some_2esender/a_2esuffix"));
32 [ + - - + : 4 : assert_se(bus_path_decode_unique(a, "/foo/bar", &b, &c) > 0 && streq_ptr(b, "some.sender") && streq_ptr(c, "a.suffix"));
+ - - + ]
33 [ + - - + ]: 4 : assert_se(bus_path_decode_unique(a, "/bar/foo", &d, &d) == 0 && !d);
34 [ + - - + ]: 4 : assert_se(bus_path_decode_unique("/foo/bar/onlyOneSuffix", "/foo/bar", &d, &d) == 0 && !d);
35 [ + - - + : 4 : assert_se(bus_path_decode_unique("/foo/bar/_/_", "/foo/bar", &d, &e) > 0 && streq_ptr(d, "") && streq_ptr(e, ""));
+ - - + ]
36 : 4 : }
37 : :
38 : 4 : static void test_bus_path_encode(void) {
39 : 4 : _cleanup_free_ char *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *f = NULL;
40 : :
41 [ + - - + ]: 4 : assert_se(sd_bus_path_encode("/foo/bar", "waldo", &a) >= 0 && streq(a, "/foo/bar/waldo"));
42 [ + - - + ]: 4 : assert_se(sd_bus_path_decode(a, "/waldo", &b) == 0 && b == NULL);
43 [ + - - + ]: 4 : assert_se(sd_bus_path_decode(a, "/foo/bar", &b) > 0 && streq(b, "waldo"));
44 : :
45 [ - + ]: 4 : assert_se(sd_bus_path_encode("xxxx", "waldo", &c) < 0);
46 [ - + ]: 4 : assert_se(sd_bus_path_encode("/foo/", "waldo", &c) < 0);
47 : :
48 [ + - - + ]: 4 : assert_se(sd_bus_path_encode("/foo/bar", "", &c) >= 0 && streq(c, "/foo/bar/_"));
49 [ + - - + ]: 4 : assert_se(sd_bus_path_decode(c, "/foo/bar", &d) > 0 && streq(d, ""));
50 : :
51 [ + - - + ]: 4 : assert_se(sd_bus_path_encode("/foo/bar", "foo.bar", &e) >= 0 && streq(e, "/foo/bar/foo_2ebar"));
52 [ + - - + ]: 4 : assert_se(sd_bus_path_decode(e, "/foo/bar", &f) > 0 && streq(f, "foo.bar"));
53 : 4 : }
54 : :
55 : 4 : static void test_bus_path_encode_many(void) {
56 : 4 : _cleanup_free_ char *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *f = NULL;
57 : :
58 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar", "/prefix/%", NULL) == 0);
59 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/prefix/bar", "/prefix/%bar", NULL) == 1);
60 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar", "/prefix/%/suffix", NULL) == 0);
61 [ + - - + ]: 4 : assert_se(sd_bus_path_decode_many("/prefix/foobar/suffix", "/prefix/%/suffix", &a) == 1 && streq_ptr(a, "foobar"));
62 [ + - - + : 4 : assert_se(sd_bus_path_decode_many("/prefix/one_foo_two/mid/three_bar_four/suffix", "/prefix/one_%_two/mid/three_%_four/suffix", &b, &c) == 1 && streq_ptr(b, "foo") && streq_ptr(c, "bar"));
+ - - + ]
63 [ + - - + ]: 4 : assert_se(sd_bus_path_decode_many("/prefix/one_foo_two/mid/three_bar_four/suffix", "/prefix/one_%_two/mid/three_%_four/suffix", NULL, &d) == 1 && streq_ptr(d, "bar"));
64 : :
65 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar", "/foo/bar/%", NULL) == 0);
66 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/foo/bar%", NULL) == 0);
67 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/foo/%/bar", NULL) == 0);
68 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/foo/%bar", NULL) == 0);
69 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/foo/bar/suffix") == 1);
70 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/foo/%%/suffix", NULL, NULL) == 0); /* multiple '%' are treated verbatim */
71 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/foo/%/suffi", NULL) == 0);
72 [ + - - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/foo/%/suffix", &e) == 1 && streq_ptr(e, "bar"));
73 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/foo/%/%", NULL, NULL) == 1);
74 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/%/%/%", NULL, NULL, NULL) == 1);
75 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "%/%/%", NULL, NULL, NULL) == 0);
76 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/%/%", NULL, NULL) == 0);
77 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/%/%/", NULL, NULL) == 0);
78 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/%/", NULL) == 0);
79 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "/%", NULL) == 0);
80 [ - + ]: 4 : assert_se(sd_bus_path_decode_many("/foo/bar/suffix", "%", NULL) == 0);
81 : :
82 [ + - - + ]: 4 : assert_se(sd_bus_path_encode_many(&f, "/prefix/one_%_two/mid/three_%_four/suffix", "foo", "bar") >= 0 && streq_ptr(f, "/prefix/one_foo_two/mid/three_bar_four/suffix"));
83 : 4 : }
84 : :
85 : 28 : static void test_bus_label_escape_one(const char *a, const char *b) {
86 : 28 : _cleanup_free_ char *t = NULL, *x = NULL, *y = NULL;
87 : :
88 [ - + ]: 28 : assert_se(t = bus_label_escape(a));
89 [ - + ]: 28 : assert_se(streq(t, b));
90 : :
91 [ - + ]: 28 : assert_se(x = bus_label_unescape(t));
92 [ - + ]: 28 : assert_se(streq(a, x));
93 : :
94 [ - + ]: 28 : assert_se(y = bus_label_unescape(b));
95 [ - + ]: 28 : assert_se(streq(a, y));
96 : 28 : }
97 : :
98 : 4 : static void test_bus_label_escape(void) {
99 : 4 : test_bus_label_escape_one("foo123bar", "foo123bar");
100 : 4 : test_bus_label_escape_one("foo.bar", "foo_2ebar");
101 : 4 : test_bus_label_escape_one("foo_2ebar", "foo_5f2ebar");
102 : 4 : test_bus_label_escape_one("", "_");
103 : 4 : test_bus_label_escape_one("_", "_5f");
104 : 4 : test_bus_label_escape_one("1", "_31");
105 : 4 : test_bus_label_escape_one(":1", "_3a1");
106 : 4 : }
107 : :
108 : 4 : int main(int argc, char *argv[]) {
109 : 4 : _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *copy = NULL;
110 : : int r, boolean;
111 : : const char *x, *x2, *y, *z, *a, *b, *c, *d, *a_signature;
112 : : uint8_t u, v;
113 : 4 : void *buffer = NULL;
114 : : size_t sz;
115 : 4 : _cleanup_free_ char *h = NULL;
116 : 4 : const int32_t integer_array[] = { -1, -2, 0, 1, 2 }, *return_array;
117 : : char *s;
118 : 4 : _cleanup_free_ char *first = NULL, *second = NULL, *third = NULL;
119 : 4 : _cleanup_fclose_ FILE *ms = NULL;
120 : 4 : size_t first_size = 0, second_size = 0, third_size = 0;
121 : 4 : _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
122 : : double dbl;
123 : : uint64_t u64;
124 : :
125 : 4 : test_setup_logging(LOG_INFO);
126 : :
127 : 4 : r = sd_bus_default_user(&bus);
128 [ - + ]: 4 : if (r < 0)
129 : 0 : r = sd_bus_default_system(&bus);
130 [ - + ]: 4 : if (r < 0)
131 : 0 : return log_tests_skipped("Failed to connect to bus");
132 : :
133 : 4 : r = sd_bus_message_new_method_call(bus, &m, "foobar.waldo", "/", "foobar.waldo", "Piep");
134 [ - + ]: 4 : assert_se(r >= 0);
135 : :
136 : 4 : r = sd_bus_message_append(m, "");
137 [ - + ]: 4 : assert_se(r >= 0);
138 : :
139 : 4 : r = sd_bus_message_append(m, "s", "a string");
140 [ - + ]: 4 : assert_se(r >= 0);
141 : :
142 : 4 : r = sd_bus_message_append(m, "s", NULL);
143 [ - + ]: 4 : assert_se(r >= 0);
144 : :
145 : 4 : r = sd_bus_message_append(m, "asg", 2, "string #1", "string #2", "sba(tt)ss");
146 [ - + ]: 4 : assert_se(r >= 0);
147 : :
148 : 4 : r = sd_bus_message_append(m, "sass", "foobar", 5, "foo", "bar", "waldo", "piep", "pap", "after");
149 [ - + ]: 4 : assert_se(r >= 0);
150 : :
151 : 4 : r = sd_bus_message_append(m, "a{yv}", 2, 3, "s", "foo", 5, "s", "waldo");
152 [ - + ]: 4 : assert_se(r >= 0);
153 : :
154 : 4 : r = sd_bus_message_append(m, "y(ty)y(yt)y", 8, 777ULL, 7, 9, 77, 7777ULL, 10);
155 [ - + ]: 4 : assert_se(r >= 0);
156 : :
157 : 4 : r = sd_bus_message_append(m, "()");
158 [ - + ]: 4 : assert_se(r == -EINVAL);
159 : :
160 : 4 : r = sd_bus_message_append(m, "ba(ss)", 255, 3, "aaa", "1", "bbb", "2", "ccc", "3");
161 [ - + ]: 4 : assert_se(r >= 0);
162 : :
163 : 4 : r = sd_bus_message_open_container(m, 'a', "s");
164 [ - + ]: 4 : assert_se(r >= 0);
165 : :
166 : 4 : r = sd_bus_message_append_basic(m, 's', "foobar");
167 [ - + ]: 4 : assert_se(r >= 0);
168 : :
169 : 4 : r = sd_bus_message_append_basic(m, 's', "waldo");
170 [ - + ]: 4 : assert_se(r >= 0);
171 : :
172 : 4 : r = sd_bus_message_close_container(m);
173 [ - + ]: 4 : assert_se(r >= 0);
174 : :
175 : 4 : r = sd_bus_message_append_string_space(m, 5, &s);
176 [ - + ]: 4 : assert_se(r >= 0);
177 : 4 : strcpy(s, "hallo");
178 : :
179 : 4 : r = sd_bus_message_append_array(m, 'i', integer_array, sizeof(integer_array));
180 [ - + ]: 4 : assert_se(r >= 0);
181 : :
182 : 4 : r = sd_bus_message_append_array(m, 'u', NULL, 0);
183 [ - + ]: 4 : assert_se(r >= 0);
184 : :
185 : 4 : r = sd_bus_message_append(m, "a(stdo)", 1, "foo", 815ULL, 47.0, "/");
186 [ - + ]: 4 : assert_se(r >= 0);
187 : :
188 : 4 : r = sd_bus_message_seal(m, 4711, 0);
189 [ - + ]: 4 : assert_se(r >= 0);
190 : :
191 : 4 : bus_message_dump(m, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
192 : :
193 : 4 : ms = open_memstream_unlocked(&first, &first_size);
194 : 4 : bus_message_dump(m, ms, 0);
195 : 4 : fflush(ms);
196 [ - + ]: 4 : assert_se(!ferror(ms));
197 : :
198 : 4 : r = bus_message_get_blob(m, &buffer, &sz);
199 [ - + ]: 4 : assert_se(r >= 0);
200 : :
201 : 4 : h = cescape_length(buffer, sz);
202 [ - + ]: 4 : assert_se(h);
203 [ + - ]: 4 : log_info("message size = %zu, contents =\n%s", sz, h);
204 : :
205 : : #if HAVE_GLIB
206 : : /* Work-around for asan bug. See c8d980a3e962aba2ea3a4cedf75fa94890a6d746. */
207 : : #if !HAS_FEATURE_ADDRESS_SANITIZER
208 : : {
209 : : GDBusMessage *g;
210 : : char *p;
211 : :
212 : : #if !defined(GLIB_VERSION_2_36)
213 : : g_type_init();
214 : : #endif
215 : :
216 : 4 : g = g_dbus_message_new_from_blob(buffer, sz, 0, NULL);
217 : 4 : p = g_dbus_message_print(g, 0);
218 [ + - ]: 4 : log_info("%s", p);
219 : 4 : g_free(p);
220 : 4 : g_object_unref(g);
221 : : }
222 : : #endif
223 : : #endif
224 : :
225 : : #if HAVE_DBUS
226 : : {
227 : : DBusMessage *w;
228 : : DBusError error;
229 : :
230 : 4 : dbus_error_init(&error);
231 : :
232 : 4 : w = dbus_message_demarshal(buffer, sz, &error);
233 [ - + ]: 4 : if (!w)
234 [ # # ]: 0 : log_error("%s", error.message);
235 : : else
236 : 4 : dbus_message_unref(w);
237 : :
238 : 4 : dbus_error_free(&error);
239 : : }
240 : : #endif
241 : :
242 : 4 : m = sd_bus_message_unref(m);
243 : :
244 : 4 : r = bus_message_from_malloc(bus, buffer, sz, NULL, 0, NULL, &m);
245 [ - + ]: 4 : assert_se(r >= 0);
246 : :
247 : 4 : bus_message_dump(m, stdout, BUS_MESSAGE_DUMP_WITH_HEADER);
248 : :
249 : 4 : fclose(ms);
250 : 4 : ms = open_memstream_unlocked(&second, &second_size);
251 : 4 : bus_message_dump(m, ms, 0);
252 : 4 : fflush(ms);
253 [ - + ]: 4 : assert_se(!ferror(ms));
254 [ - + ]: 4 : assert_se(first_size == second_size);
255 [ - + ]: 4 : assert_se(memcmp(first, second, first_size) == 0);
256 : :
257 [ - + ]: 4 : assert_se(sd_bus_message_rewind(m, true) >= 0);
258 : :
259 : 4 : r = sd_bus_message_read(m, "ssasg", &x, &x2, 2, &y, &z, &a_signature);
260 [ - + ]: 4 : assert_se(r > 0);
261 [ - + ]: 4 : assert_se(streq(x, "a string"));
262 [ - + ]: 4 : assert_se(streq(x2, ""));
263 [ - + ]: 4 : assert_se(streq(y, "string #1"));
264 [ - + ]: 4 : assert_se(streq(z, "string #2"));
265 [ - + ]: 4 : assert_se(streq(a_signature, "sba(tt)ss"));
266 : :
267 : 4 : r = sd_bus_message_read(m, "sass", &x, 5, &y, &z, &a, &b, &c, &d);
268 [ - + ]: 4 : assert_se(r > 0);
269 [ - + ]: 4 : assert_se(streq(x, "foobar"));
270 [ - + ]: 4 : assert_se(streq(y, "foo"));
271 [ - + ]: 4 : assert_se(streq(z, "bar"));
272 [ - + ]: 4 : assert_se(streq(a, "waldo"));
273 [ - + ]: 4 : assert_se(streq(b, "piep"));
274 [ - + ]: 4 : assert_se(streq(c, "pap"));
275 [ - + ]: 4 : assert_se(streq(d, "after"));
276 : :
277 : 4 : r = sd_bus_message_read(m, "a{yv}", 2, &u, "s", &x, &v, "s", &y);
278 [ - + ]: 4 : assert_se(r > 0);
279 [ - + ]: 4 : assert_se(u == 3);
280 [ - + ]: 4 : assert_se(streq(x, "foo"));
281 [ - + ]: 4 : assert_se(v == 5);
282 [ - + ]: 4 : assert_se(streq(y, "waldo"));
283 : :
284 : 4 : r = sd_bus_message_read(m, "y(ty)", &v, &u64, &u);
285 [ - + ]: 4 : assert_se(r > 0);
286 [ - + ]: 4 : assert_se(v == 8);
287 [ - + ]: 4 : assert_se(u64 == 777);
288 [ - + ]: 4 : assert_se(u == 7);
289 : :
290 : 4 : r = sd_bus_message_read(m, "y(yt)", &v, &u, &u64);
291 [ - + ]: 4 : assert_se(r > 0);
292 [ - + ]: 4 : assert_se(v == 9);
293 [ - + ]: 4 : assert_se(u == 77);
294 [ - + ]: 4 : assert_se(u64 == 7777);
295 : :
296 : 4 : r = sd_bus_message_read(m, "y", &v);
297 [ - + ]: 4 : assert_se(r > 0);
298 [ - + ]: 4 : assert_se(v == 10);
299 : :
300 : 4 : r = sd_bus_message_read(m, "()");
301 [ - + ]: 4 : assert_se(r < 0);
302 : :
303 : 4 : r = sd_bus_message_read(m, "ba(ss)", &boolean, 3, &x, &y, &a, &b, &c, &d);
304 [ - + ]: 4 : assert_se(r > 0);
305 [ - + ]: 4 : assert_se(boolean);
306 [ - + ]: 4 : assert_se(streq(x, "aaa"));
307 [ - + ]: 4 : assert_se(streq(y, "1"));
308 [ - + ]: 4 : assert_se(streq(a, "bbb"));
309 [ - + ]: 4 : assert_se(streq(b, "2"));
310 [ - + ]: 4 : assert_se(streq(c, "ccc"));
311 [ - + ]: 4 : assert_se(streq(d, "3"));
312 : :
313 [ - + ]: 4 : assert_se(sd_bus_message_verify_type(m, 'a', "s") > 0);
314 : :
315 : 4 : r = sd_bus_message_read(m, "as", 2, &x, &y);
316 [ - + ]: 4 : assert_se(r > 0);
317 [ - + ]: 4 : assert_se(streq(x, "foobar"));
318 [ - + ]: 4 : assert_se(streq(y, "waldo"));
319 : :
320 : 4 : r = sd_bus_message_read_basic(m, 's', &s);
321 [ - + ]: 4 : assert_se(r > 0);
322 [ - + ]: 4 : assert_se(streq(s, "hallo"));
323 : :
324 : 4 : r = sd_bus_message_read_array(m, 'i', (const void**) &return_array, &sz);
325 [ - + ]: 4 : assert_se(r > 0);
326 [ - + ]: 4 : assert_se(sz == sizeof(integer_array));
327 [ - + ]: 4 : assert_se(memcmp(integer_array, return_array, sz) == 0);
328 : :
329 : 4 : r = sd_bus_message_read_array(m, 'u', (const void**) &return_array, &sz);
330 [ - + ]: 4 : assert_se(r > 0);
331 [ - + ]: 4 : assert_se(sz == 0);
332 : :
333 : 4 : r = sd_bus_message_read(m, "a(stdo)", 1, &x, &u64, &dbl, &y);
334 [ - + ]: 4 : assert_se(r > 0);
335 [ - + ]: 4 : assert_se(streq(x, "foo"));
336 [ - + ]: 4 : assert_se(u64 == 815ULL);
337 [ - + ]: 4 : assert_se(fabs(dbl - 47.0) < 0.1);
338 [ - + ]: 4 : assert_se(streq(y, "/"));
339 : :
340 : 4 : r = sd_bus_message_peek_type(m, NULL, NULL);
341 [ - + ]: 4 : assert_se(r == 0);
342 : :
343 : 4 : r = sd_bus_message_new_method_call(bus, ©, "foobar.waldo", "/", "foobar.waldo", "Piep");
344 [ - + ]: 4 : assert_se(r >= 0);
345 : :
346 : 4 : r = sd_bus_message_rewind(m, true);
347 [ - + ]: 4 : assert_se(r >= 0);
348 : :
349 : 4 : r = sd_bus_message_copy(copy, m, true);
350 [ - + ]: 4 : assert_se(r >= 0);
351 : :
352 : 4 : r = sd_bus_message_seal(copy, 4712, 0);
353 [ - + ]: 4 : assert_se(r >= 0);
354 : :
355 : 4 : fclose(ms);
356 : 4 : ms = open_memstream_unlocked(&third, &third_size);
357 : 4 : bus_message_dump(copy, ms, 0);
358 : 4 : fflush(ms);
359 [ - + ]: 4 : assert_se(!ferror(ms));
360 : :
361 : 4 : printf("<%.*s>\n", (int) first_size, first);
362 : 4 : printf("<%.*s>\n", (int) third_size, third);
363 : :
364 [ - + ]: 4 : assert_se(first_size == third_size);
365 [ - + ]: 4 : assert_se(memcmp(first, third, third_size) == 0);
366 : :
367 : 4 : r = sd_bus_message_rewind(m, true);
368 [ - + ]: 4 : assert_se(r >= 0);
369 : :
370 [ - + ]: 4 : assert_se(sd_bus_message_verify_type(m, 's', NULL) > 0);
371 : :
372 : 4 : r = sd_bus_message_skip(m, "ssasg");
373 [ - + ]: 4 : assert_se(r > 0);
374 : :
375 [ - + ]: 4 : assert_se(sd_bus_message_verify_type(m, 's', NULL) > 0);
376 : :
377 : 4 : r = sd_bus_message_skip(m, "sass");
378 [ - + ]: 4 : assert_se(r >= 0);
379 : :
380 [ - + ]: 4 : assert_se(sd_bus_message_verify_type(m, 'a', "{yv}") > 0);
381 : :
382 : 4 : r = sd_bus_message_skip(m, "a{yv}y(ty)y(yt)y");
383 [ - + ]: 4 : assert_se(r >= 0);
384 : :
385 [ - + ]: 4 : assert_se(sd_bus_message_verify_type(m, 'b', NULL) > 0);
386 : :
387 : 4 : r = sd_bus_message_read(m, "b", &boolean);
388 [ - + ]: 4 : assert_se(r > 0);
389 [ - + ]: 4 : assert_se(boolean);
390 : :
391 : 4 : r = sd_bus_message_enter_container(m, 0, NULL);
392 [ - + ]: 4 : assert_se(r > 0);
393 : :
394 : 4 : r = sd_bus_message_read(m, "(ss)", &x, &y);
395 [ - + ]: 4 : assert_se(r > 0);
396 : :
397 : 4 : r = sd_bus_message_read(m, "(ss)", &a, &b);
398 [ - + ]: 4 : assert_se(r > 0);
399 : :
400 : 4 : r = sd_bus_message_read(m, "(ss)", &c, &d);
401 [ - + ]: 4 : assert_se(r > 0);
402 : :
403 : 4 : r = sd_bus_message_read(m, "(ss)", &x, &y);
404 [ - + ]: 4 : assert_se(r == 0);
405 : :
406 : 4 : r = sd_bus_message_exit_container(m);
407 [ - + ]: 4 : assert_se(r >= 0);
408 : :
409 [ - + ]: 4 : assert_se(streq(x, "aaa"));
410 [ - + ]: 4 : assert_se(streq(y, "1"));
411 [ - + ]: 4 : assert_se(streq(a, "bbb"));
412 [ - + ]: 4 : assert_se(streq(b, "2"));
413 [ - + ]: 4 : assert_se(streq(c, "ccc"));
414 [ - + ]: 4 : assert_se(streq(d, "3"));
415 : :
416 : 4 : test_bus_label_escape();
417 : 4 : test_bus_path_encode();
418 : 4 : test_bus_path_encode_unique();
419 : 4 : test_bus_path_encode_many();
420 : :
421 : 4 : return 0;
422 : : }
|