1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-message-util.c Would be in dbus-message.c, but only used by bus/tests
3 *
4 * Copyright (C) 2002, 2003, 2004, 2005 Red Hat Inc.
5 * Copyright (C) 2002, 2003 CodeFactory AB
6 *
7 * Licensed under the Academic Free License version 2.1
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25 #include "dbus-internals.h"
26 #include "dbus-test.h"
27 #include "dbus-message-private.h"
28 #include "dbus-marshal-recursive.h"
29 #include "dbus-string.h"
30
31 /**
32 * @addtogroup DBusMessage
33 * @{
34 */
35
36 #ifdef DBUS_BUILD_TESTS
37 /**
38 * Reads arguments from a message iterator given a variable argument
39 * list. Only arguments of basic type and arrays of fixed-length
40 * basic type may be read with this function. See
41 * dbus_message_get_args() for more details.
42 *
43 * @param iter the message iterator
44 * @param error error to be filled in on failure
45 * @param first_arg_type the first argument type
46 * @param ... location for first argument value, then list of type-location pairs
47 * @returns #FALSE if the error was set
48 */
49 static dbus_bool_t
dbus_message_iter_get_args(DBusMessageIter * iter,DBusError * error,int first_arg_type,...)50 dbus_message_iter_get_args (DBusMessageIter *iter,
51 DBusError *error,
52 int first_arg_type,
53 ...)
54 {
55 dbus_bool_t retval;
56 va_list var_args;
57
58 _dbus_return_val_if_fail (iter != NULL, FALSE);
59 _dbus_return_val_if_error_is_set (error, FALSE);
60
61 va_start (var_args, first_arg_type);
62 retval = _dbus_message_iter_get_args_valist (iter, error, first_arg_type, var_args);
63 va_end (var_args);
64
65 return retval;
66 }
67 #endif /* DBUS_BUILD_TESTS */
68
69 /** @} */
70
71 #ifdef DBUS_BUILD_TESTS
72 #include "dbus-test.h"
73 #include "dbus-message-factory.h"
74 #include <stdio.h>
75 #include <stdlib.h>
76
77 static int validities_seen[DBUS_VALIDITY_LAST + _DBUS_NEGATIVE_VALIDITY_COUNT];
78
79 static void
reset_validities_seen(void)80 reset_validities_seen (void)
81 {
82 int i;
83 i = 0;
84 while (i < _DBUS_N_ELEMENTS (validities_seen))
85 {
86 validities_seen[i] = 0;
87 ++i;
88 }
89 }
90
91 static void
record_validity_seen(DBusValidity validity)92 record_validity_seen (DBusValidity validity)
93 {
94 validities_seen[validity + _DBUS_NEGATIVE_VALIDITY_COUNT] += 1;
95 }
96
97 static void
print_validities_seen(dbus_bool_t not_seen)98 print_validities_seen (dbus_bool_t not_seen)
99 {
100 int i;
101 i = 0;
102 while (i < _DBUS_N_ELEMENTS (validities_seen))
103 {
104 if ((i - _DBUS_NEGATIVE_VALIDITY_COUNT) == DBUS_VALIDITY_UNKNOWN ||
105 (i - _DBUS_NEGATIVE_VALIDITY_COUNT) == DBUS_INVALID_FOR_UNKNOWN_REASON)
106 ;
107 else if ((not_seen && validities_seen[i] == 0) ||
108 (!not_seen && validities_seen[i] > 0))
109 printf ("validity %3d seen %d times\n",
110 i - _DBUS_NEGATIVE_VALIDITY_COUNT,
111 validities_seen[i]);
112 ++i;
113 }
114 }
115
116 static void
check_memleaks(void)117 check_memleaks (void)
118 {
119 dbus_shutdown ();
120
121 if (_dbus_get_malloc_blocks_outstanding () != 0)
122 {
123 _dbus_warn ("%d dbus_malloc blocks were not freed in %s\n",
124 _dbus_get_malloc_blocks_outstanding (), __FILE__);
125 _dbus_assert_not_reached ("memleaks");
126 }
127 }
128
129 static dbus_bool_t
check_have_valid_message(DBusMessageLoader * loader)130 check_have_valid_message (DBusMessageLoader *loader)
131 {
132 DBusMessage *message;
133 dbus_bool_t retval;
134
135 message = NULL;
136 retval = FALSE;
137
138 if (_dbus_message_loader_get_is_corrupted (loader))
139 {
140 _dbus_warn ("loader corrupted on message that was expected to be valid; invalid reason %d\n",
141 loader->corruption_reason);
142 goto failed;
143 }
144
145 message = _dbus_message_loader_pop_message (loader);
146 if (message == NULL)
147 {
148 _dbus_warn ("didn't load message that was expected to be valid (message not popped)\n");
149 goto failed;
150 }
151
152 if (_dbus_string_get_length (&loader->data) > 0)
153 {
154 _dbus_warn ("had leftover bytes from expected-to-be-valid single message\n");
155 goto failed;
156 }
157
158 #if 0
159 /* FIXME */
160 /* Verify that we're able to properly deal with the message.
161 * For example, this would detect improper handling of messages
162 * in nonstandard byte order.
163 */
164 if (!check_message_handling (message))
165 goto failed;
166 #endif
167
168 record_validity_seen (DBUS_VALID);
169
170 retval = TRUE;
171
172 failed:
173 if (message)
174 dbus_message_unref (message);
175
176 return retval;
177 }
178
179 static dbus_bool_t
check_invalid_message(DBusMessageLoader * loader,DBusValidity expected_validity)180 check_invalid_message (DBusMessageLoader *loader,
181 DBusValidity expected_validity)
182 {
183 dbus_bool_t retval;
184
185 retval = FALSE;
186
187 if (!_dbus_message_loader_get_is_corrupted (loader))
188 {
189 _dbus_warn ("loader not corrupted on message that was expected to be invalid\n");
190 goto failed;
191 }
192
193 record_validity_seen (loader->corruption_reason);
194
195 if (expected_validity != DBUS_INVALID_FOR_UNKNOWN_REASON &&
196 loader->corruption_reason != expected_validity)
197 {
198 _dbus_warn ("expected message to be corrupted for reason %d and was corrupted for %d instead\n",
199 expected_validity, loader->corruption_reason);
200 goto failed;
201 }
202
203 retval = TRUE;
204
205 failed:
206 return retval;
207 }
208
209 static dbus_bool_t
check_incomplete_message(DBusMessageLoader * loader)210 check_incomplete_message (DBusMessageLoader *loader)
211 {
212 DBusMessage *message;
213 dbus_bool_t retval;
214
215 message = NULL;
216 retval = FALSE;
217
218 if (_dbus_message_loader_get_is_corrupted (loader))
219 {
220 _dbus_warn ("loader corrupted on message that was expected to be valid (but incomplete), corruption reason %d\n",
221 loader->corruption_reason);
222 goto failed;
223 }
224
225 message = _dbus_message_loader_pop_message (loader);
226 if (message != NULL)
227 {
228 _dbus_warn ("loaded message that was expected to be incomplete\n");
229 goto failed;
230 }
231
232 record_validity_seen (DBUS_VALID_BUT_INCOMPLETE);
233 retval = TRUE;
234
235 failed:
236 if (message)
237 dbus_message_unref (message);
238 return retval;
239 }
240
241 static dbus_bool_t
check_loader_results(DBusMessageLoader * loader,DBusValidity expected_validity)242 check_loader_results (DBusMessageLoader *loader,
243 DBusValidity expected_validity)
244 {
245 if (!_dbus_message_loader_queue_messages (loader))
246 _dbus_assert_not_reached ("no memory to queue messages");
247
248 if (expected_validity == DBUS_VALID)
249 return check_have_valid_message (loader);
250 else if (expected_validity == DBUS_VALID_BUT_INCOMPLETE)
251 return check_incomplete_message (loader);
252 else if (expected_validity == DBUS_VALIDITY_UNKNOWN)
253 {
254 /* here we just know we didn't segfault and that was the
255 * only test. Also, we record that we got coverage
256 * for the validity reason.
257 */
258 if (_dbus_message_loader_get_is_corrupted (loader))
259 record_validity_seen (loader->corruption_reason);
260
261 return TRUE;
262 }
263 else
264 return check_invalid_message (loader, expected_validity);
265 }
266
267 /**
268 * Loads the message in the given message file.
269 *
270 * @param filename filename to load
271 * @param data string to load message into
272 * @returns #TRUE if the message was loaded
273 */
274 dbus_bool_t
dbus_internal_do_not_use_load_message_file(const DBusString * filename,DBusString * data)275 dbus_internal_do_not_use_load_message_file (const DBusString *filename,
276 DBusString *data)
277 {
278 dbus_bool_t retval;
279 DBusError error;
280
281 retval = FALSE;
282
283 _dbus_verbose ("Loading raw %s\n", _dbus_string_get_const_data (filename));
284 dbus_error_init (&error);
285 if (!_dbus_file_get_contents (data, filename, &error))
286 {
287 _dbus_warn ("Could not load message file %s: %s\n",
288 _dbus_string_get_const_data (filename),
289 error.message);
290 dbus_error_free (&error);
291 goto failed;
292 }
293
294 retval = TRUE;
295
296 failed:
297
298 return retval;
299 }
300
301 /**
302 * Tries loading the message in the given message file
303 * and verifies that DBusMessageLoader can handle it.
304 *
305 * @param filename filename to load
306 * @param expected_validity what the message has to be like to return #TRUE
307 * @returns #TRUE if the message has the expected validity
308 */
309 dbus_bool_t
dbus_internal_do_not_use_try_message_file(const DBusString * filename,DBusValidity expected_validity)310 dbus_internal_do_not_use_try_message_file (const DBusString *filename,
311 DBusValidity expected_validity)
312 {
313 DBusString data;
314 dbus_bool_t retval;
315
316 retval = FALSE;
317
318 if (!_dbus_string_init (&data))
319 _dbus_assert_not_reached ("could not allocate string\n");
320
321 if (!dbus_internal_do_not_use_load_message_file (filename, &data))
322 goto failed;
323
324 retval = dbus_internal_do_not_use_try_message_data (&data, expected_validity);
325
326 failed:
327
328 if (!retval)
329 {
330 if (_dbus_string_get_length (&data) > 0)
331 _dbus_verbose_bytes_of_string (&data, 0,
332 _dbus_string_get_length (&data));
333
334 _dbus_warn ("Failed message loader test on %s\n",
335 _dbus_string_get_const_data (filename));
336 }
337
338 _dbus_string_free (&data);
339
340 return retval;
341 }
342
343 /**
344 * Tries loading the given message data.
345 *
346 *
347 * @param data the message data
348 * @param expected_validity what the message has to be like to return #TRUE
349 * @returns #TRUE if the message has the expected validity
350 */
351 dbus_bool_t
dbus_internal_do_not_use_try_message_data(const DBusString * data,DBusValidity expected_validity)352 dbus_internal_do_not_use_try_message_data (const DBusString *data,
353 DBusValidity expected_validity)
354 {
355 DBusMessageLoader *loader;
356 dbus_bool_t retval;
357 int len;
358 int i;
359
360 loader = NULL;
361 retval = FALSE;
362
363 /* Write the data one byte at a time */
364
365 loader = _dbus_message_loader_new ();
366
367 /* check some trivial loader functions */
368 _dbus_message_loader_ref (loader);
369 _dbus_message_loader_unref (loader);
370 _dbus_message_loader_get_max_message_size (loader);
371
372 len = _dbus_string_get_length (data);
373 for (i = 0; i < len; i++)
374 {
375 DBusString *buffer;
376
377 _dbus_message_loader_get_buffer (loader, &buffer);
378 _dbus_string_append_byte (buffer,
379 _dbus_string_get_byte (data, i));
380 _dbus_message_loader_return_buffer (loader, buffer, 1);
381 }
382
383 if (!check_loader_results (loader, expected_validity))
384 goto failed;
385
386 _dbus_message_loader_unref (loader);
387 loader = NULL;
388
389 /* Write the data all at once */
390
391 loader = _dbus_message_loader_new ();
392
393 {
394 DBusString *buffer;
395
396 _dbus_message_loader_get_buffer (loader, &buffer);
397 _dbus_string_copy (data, 0, buffer,
398 _dbus_string_get_length (buffer));
399 _dbus_message_loader_return_buffer (loader, buffer, 1);
400 }
401
402 if (!check_loader_results (loader, expected_validity))
403 goto failed;
404
405 _dbus_message_loader_unref (loader);
406 loader = NULL;
407
408 /* Write the data 2 bytes at a time */
409
410 loader = _dbus_message_loader_new ();
411
412 len = _dbus_string_get_length (data);
413 for (i = 0; i < len; i += 2)
414 {
415 DBusString *buffer;
416
417 _dbus_message_loader_get_buffer (loader, &buffer);
418 _dbus_string_append_byte (buffer,
419 _dbus_string_get_byte (data, i));
420 if ((i+1) < len)
421 _dbus_string_append_byte (buffer,
422 _dbus_string_get_byte (data, i+1));
423 _dbus_message_loader_return_buffer (loader, buffer, 1);
424 }
425
426 if (!check_loader_results (loader, expected_validity))
427 goto failed;
428
429 _dbus_message_loader_unref (loader);
430 loader = NULL;
431
432 retval = TRUE;
433
434 failed:
435
436 if (loader)
437 _dbus_message_loader_unref (loader);
438
439 return retval;
440 }
441
442 static dbus_bool_t
process_test_subdir(const DBusString * test_base_dir,const char * subdir,DBusValidity expected_validity,DBusForeachMessageFileFunc function,void * user_data)443 process_test_subdir (const DBusString *test_base_dir,
444 const char *subdir,
445 DBusValidity expected_validity,
446 DBusForeachMessageFileFunc function,
447 void *user_data)
448 {
449 DBusString test_directory;
450 DBusString filename;
451 DBusDirIter *dir;
452 dbus_bool_t retval;
453 DBusError error;
454
455 retval = FALSE;
456 dir = NULL;
457
458 if (!_dbus_string_init (&test_directory))
459 _dbus_assert_not_reached ("didn't allocate test_directory\n");
460
461 _dbus_string_init_const (&filename, subdir);
462
463 if (!_dbus_string_copy (test_base_dir, 0,
464 &test_directory, 0))
465 _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
466
467 if (!_dbus_concat_dir_and_file (&test_directory, &filename))
468 _dbus_assert_not_reached ("couldn't allocate full path");
469
470 _dbus_string_free (&filename);
471 if (!_dbus_string_init (&filename))
472 _dbus_assert_not_reached ("didn't allocate filename string\n");
473
474 dbus_error_init (&error);
475 dir = _dbus_directory_open (&test_directory, &error);
476 if (dir == NULL)
477 {
478 _dbus_warn ("Could not open %s: %s\n",
479 _dbus_string_get_const_data (&test_directory),
480 error.message);
481 dbus_error_free (&error);
482 goto failed;
483 }
484
485 printf ("Testing %s:\n", subdir);
486
487 next:
488 while (_dbus_directory_get_next_file (dir, &filename, &error))
489 {
490 DBusString full_path;
491
492 if (!_dbus_string_init (&full_path))
493 _dbus_assert_not_reached ("couldn't init string");
494
495 if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
496 _dbus_assert_not_reached ("couldn't copy dir to full_path");
497
498 if (!_dbus_concat_dir_and_file (&full_path, &filename))
499 _dbus_assert_not_reached ("couldn't concat file to dir");
500
501 if (_dbus_string_ends_with_c_str (&filename, ".message-raw"))
502 ;
503 else
504 {
505 if (_dbus_string_ends_with_c_str (&filename, ".message"))
506 {
507 _dbus_warn ("Could not load %s, message builder language no longer supported\n",
508 _dbus_string_get_const_data (&filename));
509 }
510
511 _dbus_verbose ("Skipping non-.message file %s\n",
512 _dbus_string_get_const_data (&filename));
513 _dbus_string_free (&full_path);
514 goto next;
515 }
516
517 printf (" %s\n",
518 _dbus_string_get_const_data (&filename));
519
520 if (! (*function) (&full_path,
521 expected_validity, user_data))
522 {
523 _dbus_string_free (&full_path);
524 goto failed;
525 }
526 else
527 _dbus_string_free (&full_path);
528 }
529
530 if (dbus_error_is_set (&error))
531 {
532 _dbus_warn ("Could not get next file in %s: %s\n",
533 _dbus_string_get_const_data (&test_directory),
534 error.message);
535 dbus_error_free (&error);
536 goto failed;
537 }
538
539 retval = TRUE;
540
541 failed:
542
543 if (dir)
544 _dbus_directory_close (dir);
545 _dbus_string_free (&test_directory);
546 _dbus_string_free (&filename);
547
548 return retval;
549 }
550
551 /**
552 * Runs the given function on every message file in the test suite.
553 * The function should return #FALSE on test failure or fatal error.
554 *
555 * @param test_data_dir root dir of the test suite data files (top_srcdir/test/data)
556 * @param func the function to run
557 * @param user_data data for function
558 * @returns #FALSE if there's a failure
559 */
560 dbus_bool_t
dbus_internal_do_not_use_foreach_message_file(const char * test_data_dir,DBusForeachMessageFileFunc func,void * user_data)561 dbus_internal_do_not_use_foreach_message_file (const char *test_data_dir,
562 DBusForeachMessageFileFunc func,
563 void *user_data)
564 {
565 DBusString test_directory;
566 dbus_bool_t retval;
567
568 retval = FALSE;
569
570 _dbus_string_init_const (&test_directory, test_data_dir);
571
572 if (!process_test_subdir (&test_directory, "valid-messages",
573 DBUS_VALID, func, user_data))
574 goto failed;
575
576 check_memleaks ();
577
578 if (!process_test_subdir (&test_directory, "invalid-messages",
579 DBUS_INVALID_FOR_UNKNOWN_REASON, func, user_data))
580 goto failed;
581
582 check_memleaks ();
583
584 if (!process_test_subdir (&test_directory, "incomplete-messages",
585 DBUS_VALID_BUT_INCOMPLETE, func, user_data))
586 goto failed;
587
588 check_memleaks ();
589
590 retval = TRUE;
591
592 failed:
593
594 _dbus_string_free (&test_directory);
595
596 return retval;
597 }
598
599 #if 0
600 #define GET_AND_CHECK(iter, typename, literal) \
601 do { \
602 if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_##typename) \
603 _dbus_assert_not_reached ("got wrong argument type from message iter"); \
604 dbus_message_iter_get_basic (&iter, &v_##typename); \
605 if (v_##typename != literal) \
606 _dbus_assert_not_reached ("got wrong value from message iter"); \
607 } while (0)
608
609 #define GET_AND_CHECK_STRCMP(iter, typename, literal) \
610 do { \
611 if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_##typename) \
612 _dbus_assert_not_reached ("got wrong argument type from message iter"); \
613 dbus_message_iter_get_basic (&iter, &v_##typename); \
614 if (strcmp (v_##typename, literal) != 0) \
615 _dbus_assert_not_reached ("got wrong value from message iter"); \
616 } while (0)
617
618 #define GET_AND_CHECK_AND_NEXT(iter, typename, literal) \
619 do { \
620 GET_AND_CHECK(iter, typename, literal); \
621 if (!dbus_message_iter_next (&iter)) \
622 _dbus_assert_not_reached ("failed to move iter to next"); \
623 } while (0)
624
625 #define GET_AND_CHECK_STRCMP_AND_NEXT(iter, typename, literal) \
626 do { \
627 GET_AND_CHECK_STRCMP(iter, typename, literal); \
628 if (!dbus_message_iter_next (&iter)) \
629 _dbus_assert_not_reached ("failed to move iter to next"); \
630 } while (0)
631
632 static void
633 message_iter_test (DBusMessage *message)
634 {
635 DBusMessageIter iter, array, array2;
636 const char *v_STRING;
637 double v_DOUBLE;
638 dbus_int16_t v_INT16;
639 dbus_uint16_t v_UINT16;
640 dbus_int32_t v_INT32;
641 dbus_uint32_t v_UINT32;
642 #ifdef DBUS_HAVE_INT64
643 dbus_int64_t v_INT64;
644 dbus_uint64_t v_UINT64;
645 #endif
646 unsigned char v_BYTE;
647 dbus_bool_t v_BOOLEAN;
648
649 const dbus_int32_t *our_int_array;
650 int len;
651
652 dbus_message_iter_init (message, &iter);
653
654 GET_AND_CHECK_STRCMP_AND_NEXT (iter, STRING, "Test string");
655 GET_AND_CHECK_AND_NEXT (iter, INT32, -0x12345678);
656 GET_AND_CHECK_AND_NEXT (iter, UINT32, 0xedd1e);
657 GET_AND_CHECK_AND_NEXT (iter, DOUBLE, 3.14159);
658
659 if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY)
660 _dbus_assert_not_reached ("Argument type not an array");
661
662 if (dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_DOUBLE)
663 _dbus_assert_not_reached ("Array type not double");
664
665 dbus_message_iter_recurse (&iter, &array);
666
667 GET_AND_CHECK_AND_NEXT (array, DOUBLE, 1.5);
668 GET_AND_CHECK (array, DOUBLE, 2.5);
669
670 if (dbus_message_iter_next (&array))
671 _dbus_assert_not_reached ("Didn't reach end of array");
672
673 if (!dbus_message_iter_next (&iter))
674 _dbus_assert_not_reached ("Reached end of arguments");
675
676 GET_AND_CHECK_AND_NEXT (iter, BYTE, 0xF0);
677
678 if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY)
679 _dbus_assert_not_reached ("no array");
680
681 if (dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_INT32)
682 _dbus_assert_not_reached ("Array type not int32");
683
684 /* Empty array */
685 dbus_message_iter_recurse (&iter, &array);
686
687 if (dbus_message_iter_next (&array))
688 _dbus_assert_not_reached ("Didn't reach end of array");
689
690 if (!dbus_message_iter_next (&iter))
691 _dbus_assert_not_reached ("Reached end of arguments");
692
693 GET_AND_CHECK (iter, BYTE, 0xF0);
694
695 if (dbus_message_iter_next (&iter))
696 _dbus_assert_not_reached ("Didn't reach end of arguments");
697 }
698 #endif
699
700 static void
verify_test_message(DBusMessage * message)701 verify_test_message (DBusMessage *message)
702 {
703 DBusMessageIter iter;
704 DBusError error;
705 dbus_int16_t our_int16;
706 dbus_uint16_t our_uint16;
707 dbus_int32_t our_int;
708 dbus_uint32_t our_uint;
709 const char *our_str;
710 double our_double;
711 double v_DOUBLE;
712 dbus_bool_t our_bool;
713 unsigned char our_byte_1, our_byte_2;
714 const dbus_uint32_t *our_uint32_array = (void*)0xdeadbeef;
715 int our_uint32_array_len;
716 dbus_int32_t *our_int32_array = (void*)0xdeadbeef;
717 int our_int32_array_len;
718 #ifdef DBUS_HAVE_INT64
719 dbus_int64_t our_int64;
720 dbus_uint64_t our_uint64;
721 dbus_int64_t *our_uint64_array = (void*)0xdeadbeef;
722 int our_uint64_array_len;
723 const dbus_int64_t *our_int64_array = (void*)0xdeadbeef;
724 int our_int64_array_len;
725 #endif
726 const double *our_double_array = (void*)0xdeadbeef;
727 int our_double_array_len;
728 const unsigned char *our_byte_array = (void*)0xdeadbeef;
729 int our_byte_array_len;
730 const dbus_bool_t *our_boolean_array = (void*)0xdeadbeef;
731 int our_boolean_array_len;
732 char **our_string_array;
733 int our_string_array_len;
734
735 dbus_message_iter_init (message, &iter);
736
737 dbus_error_init (&error);
738 if (!dbus_message_iter_get_args (&iter, &error,
739 DBUS_TYPE_INT16, &our_int16,
740 DBUS_TYPE_UINT16, &our_uint16,
741 DBUS_TYPE_INT32, &our_int,
742 DBUS_TYPE_UINT32, &our_uint,
743 #ifdef DBUS_HAVE_INT64
744 DBUS_TYPE_INT64, &our_int64,
745 DBUS_TYPE_UINT64, &our_uint64,
746 #endif
747 DBUS_TYPE_STRING, &our_str,
748 DBUS_TYPE_DOUBLE, &our_double,
749 DBUS_TYPE_BOOLEAN, &our_bool,
750 DBUS_TYPE_BYTE, &our_byte_1,
751 DBUS_TYPE_BYTE, &our_byte_2,
752 DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
753 &our_uint32_array, &our_uint32_array_len,
754 DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
755 &our_int32_array, &our_int32_array_len,
756 #ifdef DBUS_HAVE_INT64
757 DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64,
758 &our_uint64_array, &our_uint64_array_len,
759 DBUS_TYPE_ARRAY, DBUS_TYPE_INT64,
760 &our_int64_array, &our_int64_array_len,
761 #endif
762 DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE,
763 &our_double_array, &our_double_array_len,
764 DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
765 &our_byte_array, &our_byte_array_len,
766 DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN,
767 &our_boolean_array, &our_boolean_array_len,
768 DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
769 &our_string_array, &our_string_array_len,
770 0))
771 {
772 _dbus_warn ("error: %s - %s\n", error.name,
773 (error.message != NULL) ? error.message : "no message");
774 _dbus_assert_not_reached ("Could not get arguments");
775 }
776
777 if (our_int16 != -0x123)
778 _dbus_assert_not_reached ("16-bit integers differ!");
779
780 if (our_uint16 != 0x123)
781 _dbus_assert_not_reached ("16-bit uints differ!");
782
783 if (our_int != -0x12345678)
784 _dbus_assert_not_reached ("integers differ!");
785
786 if (our_uint != 0x12300042)
787 _dbus_assert_not_reached ("uints differ!");
788
789 #ifdef DBUS_HAVE_INT64
790 if (our_int64 != DBUS_INT64_CONSTANT (-0x123456789abcd))
791 _dbus_assert_not_reached ("64-bit integers differ!");
792 if (our_uint64 != DBUS_UINT64_CONSTANT (0x123456789abcd))
793 _dbus_assert_not_reached ("64-bit unsigned integers differ!");
794 #endif
795
796 v_DOUBLE = 3.14159;
797 if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double, v_DOUBLE))
798 _dbus_assert_not_reached ("doubles differ!");
799
800 if (strcmp (our_str, "Test string") != 0)
801 _dbus_assert_not_reached ("strings differ!");
802
803 if (!our_bool)
804 _dbus_assert_not_reached ("booleans differ");
805
806 if (our_byte_1 != 42)
807 _dbus_assert_not_reached ("bytes differ!");
808
809 if (our_byte_2 != 24)
810 _dbus_assert_not_reached ("bytes differ!");
811
812 if (our_uint32_array_len != 4 ||
813 our_uint32_array[0] != 0x12345678 ||
814 our_uint32_array[1] != 0x23456781 ||
815 our_uint32_array[2] != 0x34567812 ||
816 our_uint32_array[3] != 0x45678123)
817 _dbus_assert_not_reached ("uint array differs");
818
819 if (our_int32_array_len != 4 ||
820 our_int32_array[0] != 0x12345678 ||
821 our_int32_array[1] != -0x23456781 ||
822 our_int32_array[2] != 0x34567812 ||
823 our_int32_array[3] != -0x45678123)
824 _dbus_assert_not_reached ("int array differs");
825
826 #ifdef DBUS_HAVE_INT64
827 if (our_uint64_array_len != 4 ||
828 our_uint64_array[0] != 0x12345678 ||
829 our_uint64_array[1] != 0x23456781 ||
830 our_uint64_array[2] != 0x34567812 ||
831 our_uint64_array[3] != 0x45678123)
832 _dbus_assert_not_reached ("uint64 array differs");
833
834 if (our_int64_array_len != 4 ||
835 our_int64_array[0] != 0x12345678 ||
836 our_int64_array[1] != -0x23456781 ||
837 our_int64_array[2] != 0x34567812 ||
838 our_int64_array[3] != -0x45678123)
839 _dbus_assert_not_reached ("int64 array differs");
840 #endif /* DBUS_HAVE_INT64 */
841
842 if (our_double_array_len != 3)
843 _dbus_assert_not_reached ("double array had wrong length");
844
845 /* On all IEEE machines (i.e. everything sane) exact equality
846 * should be preserved over the wire
847 */
848 v_DOUBLE = 0.1234;
849 if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double_array[0], v_DOUBLE))
850 _dbus_assert_not_reached ("double array had wrong values");
851 v_DOUBLE = 9876.54321;
852 if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double_array[1], v_DOUBLE))
853 _dbus_assert_not_reached ("double array had wrong values");
854 v_DOUBLE = -300.0;
855 if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double_array[2], v_DOUBLE))
856 _dbus_assert_not_reached ("double array had wrong values");
857
858 if (our_byte_array_len != 4)
859 _dbus_assert_not_reached ("byte array had wrong length");
860
861 if (our_byte_array[0] != 'a' ||
862 our_byte_array[1] != 'b' ||
863 our_byte_array[2] != 'c' ||
864 our_byte_array[3] != 234)
865 _dbus_assert_not_reached ("byte array had wrong values");
866
867 if (our_boolean_array_len != 5)
868 _dbus_assert_not_reached ("bool array had wrong length");
869
870 if (our_boolean_array[0] != TRUE ||
871 our_boolean_array[1] != FALSE ||
872 our_boolean_array[2] != TRUE ||
873 our_boolean_array[3] != TRUE ||
874 our_boolean_array[4] != FALSE)
875 _dbus_assert_not_reached ("bool array had wrong values");
876
877 if (our_string_array_len != 4)
878 _dbus_assert_not_reached ("string array was wrong length");
879
880 if (strcmp (our_string_array[0], "Foo") != 0 ||
881 strcmp (our_string_array[1], "bar") != 0 ||
882 strcmp (our_string_array[2], "") != 0 ||
883 strcmp (our_string_array[3], "woo woo woo woo") != 0)
884 _dbus_assert_not_reached ("string array had wrong values");
885
886 dbus_free_string_array (our_string_array);
887
888 if (dbus_message_iter_next (&iter))
889 _dbus_assert_not_reached ("Didn't reach end of arguments");
890 }
891
892 /**
893 * @ingroup DBusMessageInternals
894 * Unit test for DBusMessage.
895 *
896 * @returns #TRUE on success.
897 */
898 dbus_bool_t
_dbus_message_test(const char * test_data_dir)899 _dbus_message_test (const char *test_data_dir)
900 {
901 DBusMessage *message;
902 DBusMessageLoader *loader;
903 int i;
904 const char *data;
905 DBusMessage *copy;
906 const char *name1;
907 const char *name2;
908 const dbus_uint32_t our_uint32_array[] =
909 { 0x12345678, 0x23456781, 0x34567812, 0x45678123 };
910 const dbus_int32_t our_int32_array[] =
911 { 0x12345678, -0x23456781, 0x34567812, -0x45678123 };
912 const dbus_uint32_t *v_ARRAY_UINT32 = our_uint32_array;
913 const dbus_int32_t *v_ARRAY_INT32 = our_int32_array;
914 #ifdef DBUS_HAVE_INT64
915 const dbus_uint64_t our_uint64_array[] =
916 { 0x12345678, 0x23456781, 0x34567812, 0x45678123 };
917 const dbus_int64_t our_int64_array[] =
918 { 0x12345678, -0x23456781, 0x34567812, -0x45678123 };
919 const dbus_uint64_t *v_ARRAY_UINT64 = our_uint64_array;
920 const dbus_int64_t *v_ARRAY_INT64 = our_int64_array;
921 #endif
922 const char *our_string_array[] = { "Foo", "bar", "", "woo woo woo woo" };
923 const char **v_ARRAY_STRING = our_string_array;
924 const double our_double_array[] = { 0.1234, 9876.54321, -300.0 };
925 const double *v_ARRAY_DOUBLE = our_double_array;
926 const unsigned char our_byte_array[] = { 'a', 'b', 'c', 234 };
927 const unsigned char *v_ARRAY_BYTE = our_byte_array;
928 const dbus_bool_t our_boolean_array[] = { TRUE, FALSE, TRUE, TRUE, FALSE };
929 const dbus_bool_t *v_ARRAY_BOOLEAN = our_boolean_array;
930 char sig[64];
931 const char *s;
932 const char *v_STRING;
933 double v_DOUBLE;
934 dbus_int16_t v_INT16;
935 dbus_uint16_t v_UINT16;
936 dbus_int32_t v_INT32;
937 dbus_uint32_t v_UINT32;
938 #ifdef DBUS_HAVE_INT64
939 dbus_int64_t v_INT64;
940 dbus_uint64_t v_UINT64;
941 #endif
942 unsigned char v_BYTE;
943 unsigned char v2_BYTE;
944 dbus_bool_t v_BOOLEAN;
945
946 message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
947 "/org/freedesktop/TestPath",
948 "Foo.TestInterface",
949 "TestMethod");
950 _dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.TestService"));
951 _dbus_assert (dbus_message_is_method_call (message, "Foo.TestInterface",
952 "TestMethod"));
953 _dbus_assert (strcmp (dbus_message_get_path (message),
954 "/org/freedesktop/TestPath") == 0);
955 _dbus_message_set_serial (message, 1234);
956
957 /* string length including nul byte not a multiple of 4 */
958 if (!dbus_message_set_sender (message, "org.foo.bar1"))
959 _dbus_assert_not_reached ("out of memory");
960
961 _dbus_assert (dbus_message_has_sender (message, "org.foo.bar1"));
962 dbus_message_set_reply_serial (message, 5678);
963
964 _dbus_verbose_bytes_of_string (&message->header.data, 0,
965 _dbus_string_get_length (&message->header.data));
966 _dbus_verbose_bytes_of_string (&message->body, 0,
967 _dbus_string_get_length (&message->body));
968
969 if (!dbus_message_set_sender (message, NULL))
970 _dbus_assert_not_reached ("out of memory");
971
972
973 _dbus_verbose_bytes_of_string (&message->header.data, 0,
974 _dbus_string_get_length (&message->header.data));
975 _dbus_verbose_bytes_of_string (&message->body, 0,
976 _dbus_string_get_length (&message->body));
977
978
979 _dbus_assert (!dbus_message_has_sender (message, "org.foo.bar1"));
980 _dbus_assert (dbus_message_get_serial (message) == 1234);
981 _dbus_assert (dbus_message_get_reply_serial (message) == 5678);
982 _dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.TestService"));
983
984 _dbus_assert (dbus_message_get_no_reply (message) == FALSE);
985 dbus_message_set_no_reply (message, TRUE);
986 _dbus_assert (dbus_message_get_no_reply (message) == TRUE);
987 dbus_message_set_no_reply (message, FALSE);
988 _dbus_assert (dbus_message_get_no_reply (message) == FALSE);
989
990 /* Set/get some header fields */
991
992 if (!dbus_message_set_path (message, "/foo"))
993 _dbus_assert_not_reached ("out of memory");
994 _dbus_assert (strcmp (dbus_message_get_path (message),
995 "/foo") == 0);
996
997 if (!dbus_message_set_interface (message, "org.Foo"))
998 _dbus_assert_not_reached ("out of memory");
999 _dbus_assert (strcmp (dbus_message_get_interface (message),
1000 "org.Foo") == 0);
1001
1002 if (!dbus_message_set_member (message, "Bar"))
1003 _dbus_assert_not_reached ("out of memory");
1004 _dbus_assert (strcmp (dbus_message_get_member (message),
1005 "Bar") == 0);
1006
1007 /* Set/get them with longer values */
1008 if (!dbus_message_set_path (message, "/foo/bar"))
1009 _dbus_assert_not_reached ("out of memory");
1010 _dbus_assert (strcmp (dbus_message_get_path (message),
1011 "/foo/bar") == 0);
1012
1013 if (!dbus_message_set_interface (message, "org.Foo.Bar"))
1014 _dbus_assert_not_reached ("out of memory");
1015 _dbus_assert (strcmp (dbus_message_get_interface (message),
1016 "org.Foo.Bar") == 0);
1017
1018 if (!dbus_message_set_member (message, "BarFoo"))
1019 _dbus_assert_not_reached ("out of memory");
1020 _dbus_assert (strcmp (dbus_message_get_member (message),
1021 "BarFoo") == 0);
1022
1023 /* Realloc shorter again */
1024
1025 if (!dbus_message_set_path (message, "/foo"))
1026 _dbus_assert_not_reached ("out of memory");
1027 _dbus_assert (strcmp (dbus_message_get_path (message),
1028 "/foo") == 0);
1029
1030 if (!dbus_message_set_interface (message, "org.Foo"))
1031 _dbus_assert_not_reached ("out of memory");
1032 _dbus_assert (strcmp (dbus_message_get_interface (message),
1033 "org.Foo") == 0);
1034
1035 if (!dbus_message_set_member (message, "Bar"))
1036 _dbus_assert_not_reached ("out of memory");
1037 _dbus_assert (strcmp (dbus_message_get_member (message),
1038 "Bar") == 0);
1039
1040 dbus_message_unref (message);
1041
1042 /* Test the vararg functions */
1043 message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
1044 "/org/freedesktop/TestPath",
1045 "Foo.TestInterface",
1046 "TestMethod");
1047 _dbus_message_set_serial (message, 1);
1048 dbus_message_set_reply_serial (message, 5678);
1049
1050 v_INT16 = -0x123;
1051 v_UINT16 = 0x123;
1052 v_INT32 = -0x12345678;
1053 v_UINT32 = 0x12300042;
1054 #ifdef DBUS_HAVE_INT64
1055 v_INT64 = DBUS_INT64_CONSTANT (-0x123456789abcd);
1056 v_UINT64 = DBUS_UINT64_CONSTANT (0x123456789abcd);
1057 #endif
1058 v_STRING = "Test string";
1059 v_DOUBLE = 3.14159;
1060 v_BOOLEAN = TRUE;
1061 v_BYTE = 42;
1062 v2_BYTE = 24;
1063
1064 dbus_message_append_args (message,
1065 DBUS_TYPE_INT16, &v_INT16,
1066 DBUS_TYPE_UINT16, &v_UINT16,
1067 DBUS_TYPE_INT32, &v_INT32,
1068 DBUS_TYPE_UINT32, &v_UINT32,
1069 #ifdef DBUS_HAVE_INT64
1070 DBUS_TYPE_INT64, &v_INT64,
1071 DBUS_TYPE_UINT64, &v_UINT64,
1072 #endif
1073 DBUS_TYPE_STRING, &v_STRING,
1074 DBUS_TYPE_DOUBLE, &v_DOUBLE,
1075 DBUS_TYPE_BOOLEAN, &v_BOOLEAN,
1076 DBUS_TYPE_BYTE, &v_BYTE,
1077 DBUS_TYPE_BYTE, &v2_BYTE,
1078 DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &v_ARRAY_UINT32,
1079 _DBUS_N_ELEMENTS (our_uint32_array),
1080 DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &v_ARRAY_INT32,
1081 _DBUS_N_ELEMENTS (our_int32_array),
1082 #ifdef DBUS_HAVE_INT64
1083 DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, &v_ARRAY_UINT64,
1084 _DBUS_N_ELEMENTS (our_uint64_array),
1085 DBUS_TYPE_ARRAY, DBUS_TYPE_INT64, &v_ARRAY_INT64,
1086 _DBUS_N_ELEMENTS (our_int64_array),
1087 #endif
1088 DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE, &v_ARRAY_DOUBLE,
1089 _DBUS_N_ELEMENTS (our_double_array),
1090 DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &v_ARRAY_BYTE,
1091 _DBUS_N_ELEMENTS (our_byte_array),
1092 DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN, &v_ARRAY_BOOLEAN,
1093 _DBUS_N_ELEMENTS (our_boolean_array),
1094 DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &v_ARRAY_STRING,
1095 _DBUS_N_ELEMENTS (our_string_array),
1096 DBUS_TYPE_INVALID);
1097
1098 i = 0;
1099 sig[i++] = DBUS_TYPE_INT16;
1100 sig[i++] = DBUS_TYPE_UINT16;
1101 sig[i++] = DBUS_TYPE_INT32;
1102 sig[i++] = DBUS_TYPE_UINT32;
1103 #ifdef DBUS_HAVE_INT64
1104 sig[i++] = DBUS_TYPE_INT64;
1105 sig[i++] = DBUS_TYPE_UINT64;
1106 #endif
1107 sig[i++] = DBUS_TYPE_STRING;
1108 sig[i++] = DBUS_TYPE_DOUBLE;
1109 sig[i++] = DBUS_TYPE_BOOLEAN;
1110 sig[i++] = DBUS_TYPE_BYTE;
1111 sig[i++] = DBUS_TYPE_BYTE;
1112 sig[i++] = DBUS_TYPE_ARRAY;
1113 sig[i++] = DBUS_TYPE_UINT32;
1114 sig[i++] = DBUS_TYPE_ARRAY;
1115 sig[i++] = DBUS_TYPE_INT32;
1116 #ifdef DBUS_HAVE_INT64
1117 sig[i++] = DBUS_TYPE_ARRAY;
1118 sig[i++] = DBUS_TYPE_UINT64;
1119 sig[i++] = DBUS_TYPE_ARRAY;
1120 sig[i++] = DBUS_TYPE_INT64;
1121 #endif
1122 sig[i++] = DBUS_TYPE_ARRAY;
1123 sig[i++] = DBUS_TYPE_DOUBLE;
1124 sig[i++] = DBUS_TYPE_ARRAY;
1125 sig[i++] = DBUS_TYPE_BYTE;
1126 sig[i++] = DBUS_TYPE_ARRAY;
1127 sig[i++] = DBUS_TYPE_BOOLEAN;
1128 sig[i++] = DBUS_TYPE_ARRAY;
1129 sig[i++] = DBUS_TYPE_STRING;
1130 sig[i++] = DBUS_TYPE_INVALID;
1131
1132 _dbus_assert (i < (int) _DBUS_N_ELEMENTS (sig));
1133
1134 _dbus_verbose ("HEADER\n");
1135 _dbus_verbose_bytes_of_string (&message->header.data, 0,
1136 _dbus_string_get_length (&message->header.data));
1137 _dbus_verbose ("BODY\n");
1138 _dbus_verbose_bytes_of_string (&message->body, 0,
1139 _dbus_string_get_length (&message->body));
1140
1141 _dbus_verbose ("Signature expected \"%s\" actual \"%s\"\n",
1142 sig, dbus_message_get_signature (message));
1143
1144 s = dbus_message_get_signature (message);
1145
1146 _dbus_assert (dbus_message_has_signature (message, sig));
1147 _dbus_assert (strcmp (s, sig) == 0);
1148
1149 verify_test_message (message);
1150
1151 copy = dbus_message_copy (message);
1152
1153 _dbus_assert (dbus_message_get_reply_serial (message) ==
1154 dbus_message_get_reply_serial (copy));
1155 _dbus_assert (message->header.padding == copy->header.padding);
1156
1157 _dbus_assert (_dbus_string_get_length (&message->header.data) ==
1158 _dbus_string_get_length (©->header.data));
1159
1160 _dbus_assert (_dbus_string_get_length (&message->body) ==
1161 _dbus_string_get_length (©->body));
1162
1163 verify_test_message (copy);
1164
1165 name1 = dbus_message_get_interface (message);
1166 name2 = dbus_message_get_interface (copy);
1167
1168 _dbus_assert (strcmp (name1, name2) == 0);
1169
1170 name1 = dbus_message_get_member (message);
1171 name2 = dbus_message_get_member (copy);
1172
1173 _dbus_assert (strcmp (name1, name2) == 0);
1174
1175 dbus_message_unref (copy);
1176
1177 /* Message loader test */
1178 _dbus_message_lock (message);
1179 loader = _dbus_message_loader_new ();
1180
1181 /* check ref/unref */
1182 _dbus_message_loader_ref (loader);
1183 _dbus_message_loader_unref (loader);
1184
1185 /* Write the header data one byte at a time */
1186 data = _dbus_string_get_const_data (&message->header.data);
1187 for (i = 0; i < _dbus_string_get_length (&message->header.data); i++)
1188 {
1189 DBusString *buffer;
1190
1191 _dbus_message_loader_get_buffer (loader, &buffer);
1192 _dbus_string_append_byte (buffer, data[i]);
1193 _dbus_message_loader_return_buffer (loader, buffer, 1);
1194 }
1195
1196 /* Write the body data one byte at a time */
1197 data = _dbus_string_get_const_data (&message->body);
1198 for (i = 0; i < _dbus_string_get_length (&message->body); i++)
1199 {
1200 DBusString *buffer;
1201
1202 _dbus_message_loader_get_buffer (loader, &buffer);
1203 _dbus_string_append_byte (buffer, data[i]);
1204 _dbus_message_loader_return_buffer (loader, buffer, 1);
1205 }
1206
1207 dbus_message_unref (message);
1208
1209 /* Now pop back the message */
1210 if (!_dbus_message_loader_queue_messages (loader))
1211 _dbus_assert_not_reached ("no memory to queue messages");
1212
1213 if (_dbus_message_loader_get_is_corrupted (loader))
1214 _dbus_assert_not_reached ("message loader corrupted");
1215
1216 message = _dbus_message_loader_pop_message (loader);
1217 if (!message)
1218 _dbus_assert_not_reached ("received a NULL message");
1219
1220 if (dbus_message_get_reply_serial (message) != 5678)
1221 _dbus_assert_not_reached ("reply serial fields differ");
1222
1223 verify_test_message (message);
1224
1225 dbus_message_unref (message);
1226 _dbus_message_loader_unref (loader);
1227
1228 check_memleaks ();
1229
1230 /* Load all the sample messages from the message factory */
1231 {
1232 DBusMessageDataIter diter;
1233 DBusMessageData mdata;
1234 int count;
1235
1236 reset_validities_seen ();
1237
1238 count = 0;
1239 _dbus_message_data_iter_init (&diter);
1240
1241 while (_dbus_message_data_iter_get_and_next (&diter,
1242 &mdata))
1243 {
1244 if (!dbus_internal_do_not_use_try_message_data (&mdata.data,
1245 mdata.expected_validity))
1246 {
1247 _dbus_warn ("expected validity %d and did not get it\n",
1248 mdata.expected_validity);
1249 _dbus_assert_not_reached ("message data failed");
1250 }
1251
1252 _dbus_message_data_free (&mdata);
1253
1254 count += 1;
1255 }
1256
1257 printf ("%d sample messages tested\n", count);
1258
1259 print_validities_seen (FALSE);
1260 print_validities_seen (TRUE);
1261 }
1262
1263 check_memleaks ();
1264
1265 /* Now load every message in test_data_dir if we have one */
1266 if (test_data_dir == NULL)
1267 return TRUE;
1268
1269 return dbus_internal_do_not_use_foreach_message_file (test_data_dir,
1270 (DBusForeachMessageFileFunc)
1271 dbus_internal_do_not_use_try_message_file,
1272 NULL);
1273 }
1274
1275 #endif /* DBUS_BUILD_TESTS */
1276