dbus-message-util.c

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /* dbus-message-util.c Would be in dbus-message.c, but only used by bus/tests
00003  *
00004  * Copyright (C) 2002, 2003, 2004, 2005  Red Hat Inc.
00005  * Copyright (C) 2002, 2003  CodeFactory AB
00006  *
00007  * Licensed under the Academic Free License version 2.1
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  */
00024 
00025 #include "dbus-internals.h"
00026 #include "dbus-test.h"
00027 #include "dbus-message-private.h"
00028 #include "dbus-marshal-recursive.h"
00029 #include "dbus-string.h"
00030 
00036 #ifdef DBUS_BUILD_TESTS
00037 
00049 static dbus_bool_t
00050 dbus_message_iter_get_args (DBusMessageIter *iter,
00051                             DBusError       *error,
00052                             int              first_arg_type,
00053                             ...)
00054 {
00055   dbus_bool_t retval;
00056   va_list var_args;
00057 
00058   _dbus_return_val_if_fail (iter != NULL, FALSE);
00059   _dbus_return_val_if_error_is_set (error, FALSE);
00060 
00061   va_start (var_args, first_arg_type);
00062   retval = _dbus_message_iter_get_args_valist (iter, error, first_arg_type, var_args);
00063   va_end (var_args);
00064 
00065   return retval;
00066 }
00067 #endif /* DBUS_BUILD_TESTS */
00068 
00071 #ifdef DBUS_BUILD_TESTS
00072 #include "dbus-test.h"
00073 #include "dbus-message-factory.h"
00074 #include <stdio.h>
00075 #include <stdlib.h>
00076 
00077 static int validities_seen[DBUS_VALIDITY_LAST + _DBUS_NEGATIVE_VALIDITY_COUNT];
00078 
00079 static void
00080 reset_validities_seen (void)
00081 {
00082   int i;
00083   i = 0;
00084   while (i < _DBUS_N_ELEMENTS (validities_seen))
00085     {
00086       validities_seen[i] = 0;
00087       ++i;
00088     }
00089 }
00090 
00091 static void
00092 record_validity_seen (DBusValidity validity)
00093 {
00094   validities_seen[validity + _DBUS_NEGATIVE_VALIDITY_COUNT] += 1;
00095 }
00096 
00097 static void
00098 print_validities_seen (dbus_bool_t not_seen)
00099 {
00100   int i;
00101   i = 0;
00102   while (i < _DBUS_N_ELEMENTS (validities_seen))
00103     {
00104       if ((i - _DBUS_NEGATIVE_VALIDITY_COUNT) == DBUS_VALIDITY_UNKNOWN ||
00105           (i - _DBUS_NEGATIVE_VALIDITY_COUNT) == DBUS_INVALID_FOR_UNKNOWN_REASON)
00106         ;
00107       else if ((not_seen && validities_seen[i] == 0) ||
00108                (!not_seen && validities_seen[i] > 0))
00109         printf ("validity %3d seen %d times\n",
00110                 i - _DBUS_NEGATIVE_VALIDITY_COUNT,
00111                 validities_seen[i]);
00112       ++i;
00113     }
00114 }
00115 
00116 static void
00117 check_memleaks (void)
00118 {
00119   dbus_shutdown ();
00120 
00121   if (_dbus_get_malloc_blocks_outstanding () != 0)
00122     {
00123       _dbus_warn ("%d dbus_malloc blocks were not freed in %s\n",
00124                   _dbus_get_malloc_blocks_outstanding (), __FILE__);
00125       _dbus_assert_not_reached ("memleaks");
00126     }
00127 }
00128 
00129 static dbus_bool_t
00130 check_have_valid_message (DBusMessageLoader *loader)
00131 {
00132   DBusMessage *message;
00133   dbus_bool_t retval;
00134 
00135   message = NULL;
00136   retval = FALSE;
00137 
00138   if (_dbus_message_loader_get_is_corrupted (loader))
00139     {
00140       _dbus_warn ("loader corrupted on message that was expected to be valid; invalid reason %d\n",
00141                   loader->corruption_reason);
00142       goto failed;
00143     }
00144 
00145   message = _dbus_message_loader_pop_message (loader);
00146   if (message == NULL)
00147     {
00148       _dbus_warn ("didn't load message that was expected to be valid (message not popped)\n");
00149       goto failed;
00150     }
00151 
00152   if (_dbus_string_get_length (&loader->data) > 0)
00153     {
00154       _dbus_warn ("had leftover bytes from expected-to-be-valid single message\n");
00155       goto failed;
00156     }
00157 
00158 #if 0
00159   /* FIXME */
00160   /* Verify that we're able to properly deal with the message.
00161    * For example, this would detect improper handling of messages
00162    * in nonstandard byte order.
00163    */
00164   if (!check_message_handling (message))
00165     goto failed;
00166 #endif
00167 
00168   record_validity_seen (DBUS_VALID);
00169   
00170   retval = TRUE;
00171 
00172  failed:
00173   if (message)
00174     dbus_message_unref (message);
00175 
00176   return retval;
00177 }
00178 
00179 static dbus_bool_t
00180 check_invalid_message (DBusMessageLoader *loader,
00181                        DBusValidity       expected_validity)
00182 {
00183   dbus_bool_t retval;
00184 
00185   retval = FALSE;
00186 
00187   if (!_dbus_message_loader_get_is_corrupted (loader))
00188     {
00189       _dbus_warn ("loader not corrupted on message that was expected to be invalid\n");
00190       goto failed;
00191     }
00192 
00193   record_validity_seen (loader->corruption_reason);
00194   
00195   if (expected_validity != DBUS_INVALID_FOR_UNKNOWN_REASON &&
00196       loader->corruption_reason != expected_validity)
00197     {
00198       _dbus_warn ("expected message to be corrupted for reason %d and was corrupted for %d instead\n",
00199                   expected_validity, loader->corruption_reason);
00200       goto failed;
00201     }
00202 
00203   retval = TRUE;
00204 
00205  failed:
00206   return retval;
00207 }
00208 
00209 static dbus_bool_t
00210 check_incomplete_message (DBusMessageLoader *loader)
00211 {
00212   DBusMessage *message;
00213   dbus_bool_t retval;
00214 
00215   message = NULL;
00216   retval = FALSE;
00217 
00218   if (_dbus_message_loader_get_is_corrupted (loader))
00219     {
00220       _dbus_warn ("loader corrupted on message that was expected to be valid (but incomplete), corruption reason %d\n",
00221                   loader->corruption_reason);
00222       goto failed;
00223     }
00224 
00225   message = _dbus_message_loader_pop_message (loader);
00226   if (message != NULL)
00227     {
00228       _dbus_warn ("loaded message that was expected to be incomplete\n");
00229       goto failed;
00230     }
00231 
00232   record_validity_seen (DBUS_VALID_BUT_INCOMPLETE);
00233   retval = TRUE;
00234 
00235  failed:
00236   if (message)
00237     dbus_message_unref (message);
00238   return retval;
00239 }
00240 
00241 static dbus_bool_t
00242 check_loader_results (DBusMessageLoader      *loader,
00243                       DBusValidity            expected_validity)
00244 {
00245   if (!_dbus_message_loader_queue_messages (loader))
00246     _dbus_assert_not_reached ("no memory to queue messages");
00247 
00248   if (expected_validity == DBUS_VALID)
00249     return check_have_valid_message (loader);
00250   else if (expected_validity == DBUS_VALID_BUT_INCOMPLETE)
00251     return check_incomplete_message (loader);
00252   else if (expected_validity == DBUS_VALIDITY_UNKNOWN)
00253     {
00254       /* here we just know we didn't segfault and that was the
00255        * only test. Also, we record that we got coverage
00256        * for the validity reason.
00257        */
00258       if (_dbus_message_loader_get_is_corrupted (loader))
00259         record_validity_seen (loader->corruption_reason);
00260       
00261       return TRUE;
00262     }
00263   else
00264     return check_invalid_message (loader, expected_validity);
00265 }
00266 
00274 dbus_bool_t
00275 dbus_internal_do_not_use_load_message_file (const DBusString    *filename,
00276                                             DBusString          *data)
00277 {
00278   dbus_bool_t retval;
00279   DBusError error;
00280   
00281   retval = FALSE;
00282 
00283   _dbus_verbose ("Loading raw %s\n", _dbus_string_get_const_data (filename));
00284   dbus_error_init (&error);
00285   if (!_dbus_file_get_contents (data, filename, &error))
00286     {
00287       _dbus_warn ("Could not load message file %s: %s\n",
00288                   _dbus_string_get_const_data (filename),
00289                   error.message);
00290       dbus_error_free (&error);
00291       goto failed;
00292     }
00293 
00294   retval = TRUE;
00295 
00296  failed:
00297 
00298   return retval;
00299 }
00300 
00309 dbus_bool_t
00310 dbus_internal_do_not_use_try_message_file (const DBusString    *filename,
00311                                            DBusValidity         expected_validity)
00312 {
00313   DBusString data;
00314   dbus_bool_t retval;
00315 
00316   retval = FALSE;
00317 
00318   if (!_dbus_string_init (&data))
00319     _dbus_assert_not_reached ("could not allocate string\n");
00320 
00321   if (!dbus_internal_do_not_use_load_message_file (filename, &data))
00322     goto failed;
00323 
00324   retval = dbus_internal_do_not_use_try_message_data (&data, expected_validity);
00325 
00326  failed:
00327 
00328   if (!retval)
00329     {
00330       if (_dbus_string_get_length (&data) > 0)
00331         _dbus_verbose_bytes_of_string (&data, 0,
00332                                        _dbus_string_get_length (&data));
00333 
00334       _dbus_warn ("Failed message loader test on %s\n",
00335                   _dbus_string_get_const_data (filename));
00336     }
00337 
00338   _dbus_string_free (&data);
00339 
00340   return retval;
00341 }
00342 
00351 dbus_bool_t
00352 dbus_internal_do_not_use_try_message_data (const DBusString    *data,
00353                                            DBusValidity         expected_validity)
00354 {
00355   DBusMessageLoader *loader;
00356   dbus_bool_t retval;
00357   int len;
00358   int i;
00359 
00360   loader = NULL;
00361   retval = FALSE;
00362 
00363   /* Write the data one byte at a time */
00364 
00365   loader = _dbus_message_loader_new ();
00366 
00367   /* check some trivial loader functions */
00368   _dbus_message_loader_ref (loader);
00369   _dbus_message_loader_unref (loader);
00370   _dbus_message_loader_get_max_message_size (loader);
00371 
00372   len = _dbus_string_get_length (data);
00373   for (i = 0; i < len; i++)
00374     {
00375       DBusString *buffer;
00376 
00377       _dbus_message_loader_get_buffer (loader, &buffer);
00378       _dbus_string_append_byte (buffer,
00379                                 _dbus_string_get_byte (data, i));
00380       _dbus_message_loader_return_buffer (loader, buffer, 1);
00381     }
00382 
00383   if (!check_loader_results (loader, expected_validity))
00384     goto failed;
00385 
00386   _dbus_message_loader_unref (loader);
00387   loader = NULL;
00388 
00389   /* Write the data all at once */
00390 
00391   loader = _dbus_message_loader_new ();
00392 
00393   {
00394     DBusString *buffer;
00395 
00396     _dbus_message_loader_get_buffer (loader, &buffer);
00397     _dbus_string_copy (data, 0, buffer,
00398                        _dbus_string_get_length (buffer));
00399     _dbus_message_loader_return_buffer (loader, buffer, 1);
00400   }
00401 
00402   if (!check_loader_results (loader, expected_validity))
00403     goto failed;
00404 
00405   _dbus_message_loader_unref (loader);
00406   loader = NULL;
00407 
00408   /* Write the data 2 bytes at a time */
00409 
00410   loader = _dbus_message_loader_new ();
00411 
00412   len = _dbus_string_get_length (data);
00413   for (i = 0; i < len; i += 2)
00414     {
00415       DBusString *buffer;
00416 
00417       _dbus_message_loader_get_buffer (loader, &buffer);
00418       _dbus_string_append_byte (buffer,
00419                                 _dbus_string_get_byte (data, i));
00420       if ((i+1) < len)
00421         _dbus_string_append_byte (buffer,
00422                                   _dbus_string_get_byte (data, i+1));
00423       _dbus_message_loader_return_buffer (loader, buffer, 1);
00424     }
00425 
00426   if (!check_loader_results (loader, expected_validity))
00427     goto failed;
00428 
00429   _dbus_message_loader_unref (loader);
00430   loader = NULL;
00431 
00432   retval = TRUE;
00433 
00434  failed:
00435 
00436   if (loader)
00437     _dbus_message_loader_unref (loader);
00438 
00439   return retval;
00440 }
00441 
00442 static dbus_bool_t
00443 process_test_subdir (const DBusString          *test_base_dir,
00444                      const char                *subdir,
00445                      DBusValidity               expected_validity,
00446                      DBusForeachMessageFileFunc function,
00447                      void                      *user_data)
00448 {
00449   DBusString test_directory;
00450   DBusString filename;
00451   DBusDirIter *dir;
00452   dbus_bool_t retval;
00453   DBusError error;
00454 
00455   retval = FALSE;
00456   dir = NULL;
00457 
00458   if (!_dbus_string_init (&test_directory))
00459     _dbus_assert_not_reached ("didn't allocate test_directory\n");
00460 
00461   _dbus_string_init_const (&filename, subdir);
00462 
00463   if (!_dbus_string_copy (test_base_dir, 0,
00464                           &test_directory, 0))
00465     _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
00466 
00467   if (!_dbus_concat_dir_and_file (&test_directory, &filename))
00468     _dbus_assert_not_reached ("couldn't allocate full path");
00469 
00470   _dbus_string_free (&filename);
00471   if (!_dbus_string_init (&filename))
00472     _dbus_assert_not_reached ("didn't allocate filename string\n");
00473 
00474   dbus_error_init (&error);
00475   dir = _dbus_directory_open (&test_directory, &error);
00476   if (dir == NULL)
00477     {
00478       _dbus_warn ("Could not open %s: %s\n",
00479                   _dbus_string_get_const_data (&test_directory),
00480                   error.message);
00481       dbus_error_free (&error);
00482       goto failed;
00483     }
00484 
00485   printf ("Testing %s:\n", subdir);
00486 
00487  next:
00488   while (_dbus_directory_get_next_file (dir, &filename, &error))
00489     {
00490       DBusString full_path;
00491 
00492       if (!_dbus_string_init (&full_path))
00493         _dbus_assert_not_reached ("couldn't init string");
00494 
00495       if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
00496         _dbus_assert_not_reached ("couldn't copy dir to full_path");
00497 
00498       if (!_dbus_concat_dir_and_file (&full_path, &filename))
00499         _dbus_assert_not_reached ("couldn't concat file to dir");
00500 
00501       if (_dbus_string_ends_with_c_str (&filename, ".message-raw"))
00502         ;
00503       else
00504         {
00505           if (_dbus_string_ends_with_c_str (&filename, ".message"))
00506             {
00507               _dbus_warn ("Could not load %s, message builder language no longer supported\n",
00508                           _dbus_string_get_const_data (&filename));
00509             }
00510           
00511           _dbus_verbose ("Skipping non-.message file %s\n",
00512                          _dbus_string_get_const_data (&filename));
00513           _dbus_string_free (&full_path);
00514           goto next;
00515         }
00516 
00517       printf ("    %s\n",
00518               _dbus_string_get_const_data (&filename));
00519 
00520       if (! (*function) (&full_path,
00521                          expected_validity, user_data))
00522         {
00523           _dbus_string_free (&full_path);
00524           goto failed;
00525         }
00526       else
00527         _dbus_string_free (&full_path);
00528     }
00529 
00530   if (dbus_error_is_set (&error))
00531     {
00532       _dbus_warn ("Could not get next file in %s: %s\n",
00533                   _dbus_string_get_const_data (&test_directory),
00534                   error.message);
00535       dbus_error_free (&error);
00536       goto failed;
00537     }
00538 
00539   retval = TRUE;
00540 
00541  failed:
00542 
00543   if (dir)
00544     _dbus_directory_close (dir);
00545   _dbus_string_free (&test_directory);
00546   _dbus_string_free (&filename);
00547 
00548   return retval;
00549 }
00550 
00560 dbus_bool_t
00561 dbus_internal_do_not_use_foreach_message_file (const char                *test_data_dir,
00562                                                DBusForeachMessageFileFunc func,
00563                                                void                      *user_data)
00564 {
00565   DBusString test_directory;
00566   dbus_bool_t retval;
00567 
00568   retval = FALSE;
00569 
00570   _dbus_string_init_const (&test_directory, test_data_dir);
00571   
00572   if (!process_test_subdir (&test_directory, "valid-messages",
00573                             DBUS_VALID, func, user_data))
00574     goto failed;
00575 
00576   check_memleaks ();
00577   
00578   if (!process_test_subdir (&test_directory, "invalid-messages",
00579                             DBUS_INVALID_FOR_UNKNOWN_REASON, func, user_data))
00580     goto failed;
00581 
00582   check_memleaks ();
00583   
00584   if (!process_test_subdir (&test_directory, "incomplete-messages",
00585                             DBUS_VALID_BUT_INCOMPLETE, func, user_data))
00586     goto failed;
00587 
00588   check_memleaks ();
00589   
00590   retval = TRUE;
00591   
00592  failed:
00593 
00594   _dbus_string_free (&test_directory);
00595 
00596   return retval;
00597 }
00598 
00599 #if 0
00600 #define GET_AND_CHECK(iter, typename, literal)                                  \
00601   do {                                                                          \
00602     if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_##typename)         \
00603       _dbus_assert_not_reached ("got wrong argument type from message iter");   \
00604     dbus_message_iter_get_basic (&iter, &v_##typename);                         \
00605     if (v_##typename != literal)                                                \
00606       _dbus_assert_not_reached ("got wrong value from message iter");           \
00607   } while (0)
00608 
00609 #define GET_AND_CHECK_STRCMP(iter, typename, literal)                           \
00610   do {                                                                          \
00611     if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_##typename)         \
00612       _dbus_assert_not_reached ("got wrong argument type from message iter");   \
00613     dbus_message_iter_get_basic (&iter, &v_##typename);                         \
00614     if (strcmp (v_##typename, literal) != 0)                                    \
00615       _dbus_assert_not_reached ("got wrong value from message iter");           \
00616   } while (0)
00617 
00618 #define GET_AND_CHECK_AND_NEXT(iter, typename, literal)         \
00619   do {                                                          \
00620     GET_AND_CHECK(iter, typename, literal);                     \
00621     if (!dbus_message_iter_next (&iter))                        \
00622       _dbus_assert_not_reached ("failed to move iter to next"); \
00623   } while (0)
00624 
00625 #define GET_AND_CHECK_STRCMP_AND_NEXT(iter, typename, literal)  \
00626   do {                                                          \
00627     GET_AND_CHECK_STRCMP(iter, typename, literal);              \
00628     if (!dbus_message_iter_next (&iter))                        \
00629       _dbus_assert_not_reached ("failed to move iter to next"); \
00630   } while (0)
00631 
00632 static void
00633 message_iter_test (DBusMessage *message)
00634 {
00635   DBusMessageIter iter, array, array2;
00636   const char *v_STRING;
00637   double v_DOUBLE;
00638   dbus_int16_t v_INT16;
00639   dbus_uint16_t v_UINT16;
00640   dbus_int32_t v_INT32;
00641   dbus_uint32_t v_UINT32;
00642 #ifdef DBUS_HAVE_INT64
00643   dbus_int64_t v_INT64;
00644   dbus_uint64_t v_UINT64;
00645 #endif
00646   unsigned char v_BYTE;
00647   dbus_bool_t v_BOOLEAN;
00648 
00649   const dbus_int32_t *our_int_array;
00650   int len;
00651 
00652   dbus_message_iter_init (message, &iter);
00653 
00654   GET_AND_CHECK_STRCMP_AND_NEXT (iter, STRING, "Test string");
00655   GET_AND_CHECK_AND_NEXT (iter, INT32, -0x12345678);
00656   GET_AND_CHECK_AND_NEXT (iter, UINT32, 0xedd1e);
00657   GET_AND_CHECK_AND_NEXT (iter, DOUBLE, 3.14159);
00658 
00659   if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY)
00660     _dbus_assert_not_reached ("Argument type not an array");
00661 
00662   if (dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_DOUBLE)
00663     _dbus_assert_not_reached ("Array type not double");
00664 
00665   dbus_message_iter_recurse (&iter, &array);
00666 
00667   GET_AND_CHECK_AND_NEXT (array, DOUBLE, 1.5);
00668   GET_AND_CHECK (array, DOUBLE, 2.5);
00669 
00670   if (dbus_message_iter_next (&array))
00671     _dbus_assert_not_reached ("Didn't reach end of array");
00672 
00673   if (!dbus_message_iter_next (&iter))
00674     _dbus_assert_not_reached ("Reached end of arguments");
00675 
00676   GET_AND_CHECK_AND_NEXT (iter, BYTE, 0xF0);
00677 
00678   if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY)
00679     _dbus_assert_not_reached ("no array");
00680 
00681   if (dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_INT32)
00682     _dbus_assert_not_reached ("Array type not int32");
00683 
00684   /* Empty array */
00685   dbus_message_iter_recurse (&iter, &array);
00686 
00687   if (dbus_message_iter_next (&array))
00688     _dbus_assert_not_reached ("Didn't reach end of array");
00689 
00690   if (!dbus_message_iter_next (&iter))
00691     _dbus_assert_not_reached ("Reached end of arguments");
00692 
00693   GET_AND_CHECK (iter, BYTE, 0xF0);
00694 
00695   if (dbus_message_iter_next (&iter))
00696     _dbus_assert_not_reached ("Didn't reach end of arguments");
00697 }
00698 #endif
00699 
00700 static void
00701 verify_test_message (DBusMessage *message)
00702 {
00703   DBusMessageIter iter;
00704   DBusError error;
00705   dbus_int16_t our_int16;
00706   dbus_uint16_t our_uint16;
00707   dbus_int32_t our_int;
00708   dbus_uint32_t our_uint;
00709   const char *our_str;
00710   double our_double;
00711   double v_DOUBLE;
00712   dbus_bool_t our_bool;
00713   unsigned char our_byte_1, our_byte_2;
00714   const dbus_uint32_t *our_uint32_array = (void*)0xdeadbeef;
00715   int our_uint32_array_len;
00716   dbus_int32_t *our_int32_array = (void*)0xdeadbeef;
00717   int our_int32_array_len;
00718 #ifdef DBUS_HAVE_INT64
00719   dbus_int64_t our_int64;
00720   dbus_uint64_t our_uint64;
00721   dbus_int64_t *our_uint64_array = (void*)0xdeadbeef;
00722   int our_uint64_array_len;
00723   const dbus_int64_t *our_int64_array = (void*)0xdeadbeef;
00724   int our_int64_array_len;
00725 #endif
00726   const double *our_double_array = (void*)0xdeadbeef;
00727   int our_double_array_len;
00728   const unsigned char *our_byte_array = (void*)0xdeadbeef;
00729   int our_byte_array_len;
00730   const dbus_bool_t *our_boolean_array = (void*)0xdeadbeef;
00731   int our_boolean_array_len;
00732   char **our_string_array;
00733   int our_string_array_len;
00734 
00735   dbus_message_iter_init (message, &iter);
00736 
00737   dbus_error_init (&error);
00738   if (!dbus_message_iter_get_args (&iter, &error,
00739                                    DBUS_TYPE_INT16, &our_int16,
00740                                    DBUS_TYPE_UINT16, &our_uint16,
00741                                    DBUS_TYPE_INT32, &our_int,
00742                                    DBUS_TYPE_UINT32, &our_uint,
00743 #ifdef DBUS_HAVE_INT64
00744                                    DBUS_TYPE_INT64, &our_int64,
00745                                    DBUS_TYPE_UINT64, &our_uint64,
00746 #endif
00747                                    DBUS_TYPE_STRING, &our_str,
00748                                    DBUS_TYPE_DOUBLE, &our_double,
00749                                    DBUS_TYPE_BOOLEAN, &our_bool,
00750                                    DBUS_TYPE_BYTE, &our_byte_1,
00751                                    DBUS_TYPE_BYTE, &our_byte_2,
00752                                    DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
00753                                    &our_uint32_array, &our_uint32_array_len,
00754                                    DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
00755                                    &our_int32_array, &our_int32_array_len,
00756 #ifdef DBUS_HAVE_INT64
00757                                    DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64,
00758                                    &our_uint64_array, &our_uint64_array_len,
00759                                    DBUS_TYPE_ARRAY, DBUS_TYPE_INT64,
00760                                    &our_int64_array, &our_int64_array_len,
00761 #endif
00762                                    DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE,
00763                                    &our_double_array, &our_double_array_len,
00764                                    DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
00765                                    &our_byte_array, &our_byte_array_len,
00766                                    DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN,
00767                                    &our_boolean_array, &our_boolean_array_len,
00768                                    DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
00769                                    &our_string_array, &our_string_array_len,
00770                                    0))
00771     {
00772       _dbus_warn ("error: %s - %s\n", error.name,
00773                   (error.message != NULL) ? error.message : "no message");
00774       _dbus_assert_not_reached ("Could not get arguments");
00775     }
00776 
00777   if (our_int16 != -0x123)
00778     _dbus_assert_not_reached ("16-bit integers differ!");
00779 
00780   if (our_uint16 != 0x123)
00781     _dbus_assert_not_reached ("16-bit uints differ!");
00782   
00783   if (our_int != -0x12345678)
00784     _dbus_assert_not_reached ("integers differ!");
00785 
00786   if (our_uint != 0x12300042)
00787     _dbus_assert_not_reached ("uints differ!");
00788 
00789 #ifdef DBUS_HAVE_INT64
00790   if (our_int64 != DBUS_INT64_CONSTANT (-0x123456789abcd))
00791     _dbus_assert_not_reached ("64-bit integers differ!");
00792   if (our_uint64 != DBUS_UINT64_CONSTANT (0x123456789abcd))
00793     _dbus_assert_not_reached ("64-bit unsigned integers differ!");
00794 #endif
00795 
00796   v_DOUBLE = 3.14159;
00797   if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double, v_DOUBLE))
00798     _dbus_assert_not_reached ("doubles differ!");
00799 
00800   if (strcmp (our_str, "Test string") != 0)
00801     _dbus_assert_not_reached ("strings differ!");
00802 
00803   if (!our_bool)
00804     _dbus_assert_not_reached ("booleans differ");
00805 
00806   if (our_byte_1 != 42)
00807     _dbus_assert_not_reached ("bytes differ!");
00808 
00809   if (our_byte_2 != 24)
00810     _dbus_assert_not_reached ("bytes differ!");
00811 
00812   if (our_uint32_array_len != 4 ||
00813       our_uint32_array[0] != 0x12345678 ||
00814       our_uint32_array[1] != 0x23456781 ||
00815       our_uint32_array[2] != 0x34567812 ||
00816       our_uint32_array[3] != 0x45678123)
00817     _dbus_assert_not_reached ("uint array differs");
00818 
00819   if (our_int32_array_len != 4 ||
00820       our_int32_array[0] != 0x12345678 ||
00821       our_int32_array[1] != -0x23456781 ||
00822       our_int32_array[2] != 0x34567812 ||
00823       our_int32_array[3] != -0x45678123)
00824     _dbus_assert_not_reached ("int array differs");
00825 
00826 #ifdef DBUS_HAVE_INT64
00827   if (our_uint64_array_len != 4 ||
00828       our_uint64_array[0] != 0x12345678 ||
00829       our_uint64_array[1] != 0x23456781 ||
00830       our_uint64_array[2] != 0x34567812 ||
00831       our_uint64_array[3] != 0x45678123)
00832     _dbus_assert_not_reached ("uint64 array differs");
00833 
00834   if (our_int64_array_len != 4 ||
00835       our_int64_array[0] != 0x12345678 ||
00836       our_int64_array[1] != -0x23456781 ||
00837       our_int64_array[2] != 0x34567812 ||
00838       our_int64_array[3] != -0x45678123)
00839     _dbus_assert_not_reached ("int64 array differs");
00840 #endif /* DBUS_HAVE_INT64 */
00841 
00842   if (our_double_array_len != 3)
00843     _dbus_assert_not_reached ("double array had wrong length");
00844 
00845   /* On all IEEE machines (i.e. everything sane) exact equality
00846    * should be preserved over the wire
00847    */
00848   v_DOUBLE = 0.1234;
00849   if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double_array[0], v_DOUBLE))
00850     _dbus_assert_not_reached ("double array had wrong values");
00851   v_DOUBLE = 9876.54321;
00852   if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double_array[1], v_DOUBLE))
00853     _dbus_assert_not_reached ("double array had wrong values");
00854   v_DOUBLE = -300.0;
00855   if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double_array[2], v_DOUBLE))
00856     _dbus_assert_not_reached ("double array had wrong values");
00857 
00858   if (our_byte_array_len != 4)
00859     _dbus_assert_not_reached ("byte array had wrong length");
00860 
00861   if (our_byte_array[0] != 'a' ||
00862       our_byte_array[1] != 'b' ||
00863       our_byte_array[2] != 'c' ||
00864       our_byte_array[3] != 234)
00865     _dbus_assert_not_reached ("byte array had wrong values");
00866 
00867   if (our_boolean_array_len != 5)
00868     _dbus_assert_not_reached ("bool array had wrong length");
00869 
00870   if (our_boolean_array[0] != TRUE ||
00871       our_boolean_array[1] != FALSE ||
00872       our_boolean_array[2] != TRUE ||
00873       our_boolean_array[3] != TRUE ||
00874       our_boolean_array[4] != FALSE)
00875     _dbus_assert_not_reached ("bool array had wrong values");
00876 
00877   if (our_string_array_len != 4)
00878     _dbus_assert_not_reached ("string array was wrong length");
00879 
00880   if (strcmp (our_string_array[0], "Foo") != 0 ||
00881       strcmp (our_string_array[1], "bar") != 0 ||
00882       strcmp (our_string_array[2], "") != 0 ||
00883       strcmp (our_string_array[3], "woo woo woo woo") != 0)
00884     _dbus_assert_not_reached ("string array had wrong values");
00885 
00886   dbus_free_string_array (our_string_array);
00887   
00888   if (dbus_message_iter_next (&iter))
00889     _dbus_assert_not_reached ("Didn't reach end of arguments");
00890 }
00891 
00898 dbus_bool_t
00899 _dbus_message_test (const char *test_data_dir)
00900 {
00901   DBusMessage *message;
00902   DBusMessageLoader *loader;
00903   int i;
00904   const char *data;
00905   DBusMessage *copy;
00906   const char *name1;
00907   const char *name2;
00908   const dbus_uint32_t our_uint32_array[] =
00909     { 0x12345678, 0x23456781, 0x34567812, 0x45678123 };
00910   const dbus_int32_t our_int32_array[] =
00911     { 0x12345678, -0x23456781, 0x34567812, -0x45678123 };
00912   const dbus_uint32_t *v_ARRAY_UINT32 = our_uint32_array;
00913   const dbus_int32_t *v_ARRAY_INT32 = our_int32_array;
00914 #ifdef DBUS_HAVE_INT64
00915   const dbus_uint64_t our_uint64_array[] =
00916     { 0x12345678, 0x23456781, 0x34567812, 0x45678123 };
00917   const dbus_int64_t our_int64_array[] =
00918     { 0x12345678, -0x23456781, 0x34567812, -0x45678123 };
00919   const dbus_uint64_t *v_ARRAY_UINT64 = our_uint64_array;
00920   const dbus_int64_t *v_ARRAY_INT64 = our_int64_array;
00921 #endif
00922   const char *our_string_array[] = { "Foo", "bar", "", "woo woo woo woo" };
00923   const char **v_ARRAY_STRING = our_string_array;
00924   const double our_double_array[] = { 0.1234, 9876.54321, -300.0 };
00925   const double *v_ARRAY_DOUBLE = our_double_array;
00926   const unsigned char our_byte_array[] = { 'a', 'b', 'c', 234 };
00927   const unsigned char *v_ARRAY_BYTE = our_byte_array;
00928   const dbus_bool_t our_boolean_array[] = { TRUE, FALSE, TRUE, TRUE, FALSE };
00929   const dbus_bool_t *v_ARRAY_BOOLEAN = our_boolean_array;
00930   char sig[64];
00931   const char *s;
00932   const char *v_STRING;
00933   double v_DOUBLE;
00934   dbus_int16_t v_INT16;
00935   dbus_uint16_t v_UINT16;
00936   dbus_int32_t v_INT32;
00937   dbus_uint32_t v_UINT32;
00938 #ifdef DBUS_HAVE_INT64
00939   dbus_int64_t v_INT64;
00940   dbus_uint64_t v_UINT64;
00941 #endif
00942   unsigned char v_BYTE;
00943   unsigned char v2_BYTE;
00944   dbus_bool_t v_BOOLEAN;
00945 
00946   message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
00947                                           "/org/freedesktop/TestPath",
00948                                           "Foo.TestInterface",
00949                                           "TestMethod");
00950   _dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.TestService"));
00951   _dbus_assert (dbus_message_is_method_call (message, "Foo.TestInterface",
00952                                              "TestMethod"));
00953   _dbus_assert (strcmp (dbus_message_get_path (message),
00954                         "/org/freedesktop/TestPath") == 0);
00955   _dbus_message_set_serial (message, 1234);
00956 
00957   /* string length including nul byte not a multiple of 4 */
00958   if (!dbus_message_set_sender (message, "org.foo.bar1"))
00959     _dbus_assert_not_reached ("out of memory");
00960 
00961   _dbus_assert (dbus_message_has_sender (message, "org.foo.bar1"));
00962   dbus_message_set_reply_serial (message, 5678);
00963 
00964   _dbus_verbose_bytes_of_string (&message->header.data, 0,
00965                                  _dbus_string_get_length (&message->header.data));
00966   _dbus_verbose_bytes_of_string (&message->body, 0,
00967                                  _dbus_string_get_length (&message->body));
00968 
00969   if (!dbus_message_set_sender (message, NULL))
00970     _dbus_assert_not_reached ("out of memory");
00971 
00972 
00973   _dbus_verbose_bytes_of_string (&message->header.data, 0,
00974                                  _dbus_string_get_length (&message->header.data));
00975   _dbus_verbose_bytes_of_string (&message->body, 0,
00976                                  _dbus_string_get_length (&message->body));
00977 
00978 
00979   _dbus_assert (!dbus_message_has_sender (message, "org.foo.bar1"));
00980   _dbus_assert (dbus_message_get_serial (message) == 1234);
00981   _dbus_assert (dbus_message_get_reply_serial (message) == 5678);
00982   _dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.TestService"));
00983 
00984   _dbus_assert (dbus_message_get_no_reply (message) == FALSE);
00985   dbus_message_set_no_reply (message, TRUE);
00986   _dbus_assert (dbus_message_get_no_reply (message) == TRUE);
00987   dbus_message_set_no_reply (message, FALSE);
00988   _dbus_assert (dbus_message_get_no_reply (message) == FALSE);
00989 
00990   /* Set/get some header fields */
00991 
00992   if (!dbus_message_set_path (message, "/foo"))
00993     _dbus_assert_not_reached ("out of memory");
00994   _dbus_assert (strcmp (dbus_message_get_path (message),
00995                         "/foo") == 0);
00996 
00997   if (!dbus_message_set_interface (message, "org.Foo"))
00998     _dbus_assert_not_reached ("out of memory");
00999   _dbus_assert (strcmp (dbus_message_get_interface (message),
01000                         "org.Foo") == 0);
01001 
01002   if (!dbus_message_set_member (message, "Bar"))
01003     _dbus_assert_not_reached ("out of memory");
01004   _dbus_assert (strcmp (dbus_message_get_member (message),
01005                         "Bar") == 0);
01006 
01007   /* Set/get them with longer values */
01008   if (!dbus_message_set_path (message, "/foo/bar"))
01009     _dbus_assert_not_reached ("out of memory");
01010   _dbus_assert (strcmp (dbus_message_get_path (message),
01011                         "/foo/bar") == 0);
01012 
01013   if (!dbus_message_set_interface (message, "org.Foo.Bar"))
01014     _dbus_assert_not_reached ("out of memory");
01015   _dbus_assert (strcmp (dbus_message_get_interface (message),
01016                         "org.Foo.Bar") == 0);
01017 
01018   if (!dbus_message_set_member (message, "BarFoo"))
01019     _dbus_assert_not_reached ("out of memory");
01020   _dbus_assert (strcmp (dbus_message_get_member (message),
01021                         "BarFoo") == 0);
01022 
01023   /* Realloc shorter again */
01024 
01025   if (!dbus_message_set_path (message, "/foo"))
01026     _dbus_assert_not_reached ("out of memory");
01027   _dbus_assert (strcmp (dbus_message_get_path (message),
01028                         "/foo") == 0);
01029 
01030   if (!dbus_message_set_interface (message, "org.Foo"))
01031     _dbus_assert_not_reached ("out of memory");
01032   _dbus_assert (strcmp (dbus_message_get_interface (message),
01033                         "org.Foo") == 0);
01034 
01035   if (!dbus_message_set_member (message, "Bar"))
01036     _dbus_assert_not_reached ("out of memory");
01037   _dbus_assert (strcmp (dbus_message_get_member (message),
01038                         "Bar") == 0);
01039 
01040   dbus_message_unref (message);
01041 
01042   /* Test the vararg functions */
01043   message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
01044                                           "/org/freedesktop/TestPath",
01045                                           "Foo.TestInterface",
01046                                           "TestMethod");
01047   _dbus_message_set_serial (message, 1);
01048   dbus_message_set_reply_serial (message, 5678);
01049 
01050   v_INT16 = -0x123;
01051   v_UINT16 = 0x123;
01052   v_INT32 = -0x12345678;
01053   v_UINT32 = 0x12300042;
01054 #ifdef DBUS_HAVE_INT64
01055   v_INT64 = DBUS_INT64_CONSTANT (-0x123456789abcd);
01056   v_UINT64 = DBUS_UINT64_CONSTANT (0x123456789abcd);
01057 #endif
01058   v_STRING = "Test string";
01059   v_DOUBLE = 3.14159;
01060   v_BOOLEAN = TRUE;
01061   v_BYTE = 42;
01062   v2_BYTE = 24;
01063 
01064   dbus_message_append_args (message,
01065                             DBUS_TYPE_INT16, &v_INT16,
01066                             DBUS_TYPE_UINT16, &v_UINT16,
01067                             DBUS_TYPE_INT32, &v_INT32,
01068                             DBUS_TYPE_UINT32, &v_UINT32,
01069 #ifdef DBUS_HAVE_INT64
01070                             DBUS_TYPE_INT64, &v_INT64,
01071                             DBUS_TYPE_UINT64, &v_UINT64,
01072 #endif
01073                             DBUS_TYPE_STRING, &v_STRING,
01074                             DBUS_TYPE_DOUBLE, &v_DOUBLE,
01075                             DBUS_TYPE_BOOLEAN, &v_BOOLEAN,
01076                             DBUS_TYPE_BYTE, &v_BYTE,
01077                             DBUS_TYPE_BYTE, &v2_BYTE,
01078                             DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &v_ARRAY_UINT32,
01079                             _DBUS_N_ELEMENTS (our_uint32_array),
01080                             DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &v_ARRAY_INT32,
01081                             _DBUS_N_ELEMENTS (our_int32_array),
01082 #ifdef DBUS_HAVE_INT64
01083                             DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, &v_ARRAY_UINT64,
01084                             _DBUS_N_ELEMENTS (our_uint64_array),
01085                             DBUS_TYPE_ARRAY, DBUS_TYPE_INT64, &v_ARRAY_INT64,
01086                             _DBUS_N_ELEMENTS (our_int64_array),
01087 #endif
01088                             DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE, &v_ARRAY_DOUBLE,
01089                             _DBUS_N_ELEMENTS (our_double_array),
01090                             DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &v_ARRAY_BYTE,
01091                             _DBUS_N_ELEMENTS (our_byte_array),
01092                             DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN, &v_ARRAY_BOOLEAN,
01093                             _DBUS_N_ELEMENTS (our_boolean_array),
01094                             DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &v_ARRAY_STRING,
01095                             _DBUS_N_ELEMENTS (our_string_array),
01096                             DBUS_TYPE_INVALID);
01097 
01098   i = 0;
01099   sig[i++] = DBUS_TYPE_INT16;
01100   sig[i++] = DBUS_TYPE_UINT16;
01101   sig[i++] = DBUS_TYPE_INT32;
01102   sig[i++] = DBUS_TYPE_UINT32;
01103 #ifdef DBUS_HAVE_INT64
01104   sig[i++] = DBUS_TYPE_INT64;
01105   sig[i++] = DBUS_TYPE_UINT64;
01106 #endif
01107   sig[i++] = DBUS_TYPE_STRING;
01108   sig[i++] = DBUS_TYPE_DOUBLE;
01109   sig[i++] = DBUS_TYPE_BOOLEAN;
01110   sig[i++] = DBUS_TYPE_BYTE;
01111   sig[i++] = DBUS_TYPE_BYTE;
01112   sig[i++] = DBUS_TYPE_ARRAY;
01113   sig[i++] = DBUS_TYPE_UINT32;
01114   sig[i++] = DBUS_TYPE_ARRAY;
01115   sig[i++] = DBUS_TYPE_INT32;
01116 #ifdef DBUS_HAVE_INT64
01117   sig[i++] = DBUS_TYPE_ARRAY;
01118   sig[i++] = DBUS_TYPE_UINT64;
01119   sig[i++] = DBUS_TYPE_ARRAY;
01120   sig[i++] = DBUS_TYPE_INT64;
01121 #endif
01122   sig[i++] = DBUS_TYPE_ARRAY;
01123   sig[i++] = DBUS_TYPE_DOUBLE;
01124   sig[i++] = DBUS_TYPE_ARRAY;
01125   sig[i++] = DBUS_TYPE_BYTE;
01126   sig[i++] = DBUS_TYPE_ARRAY;
01127   sig[i++] = DBUS_TYPE_BOOLEAN;
01128   sig[i++] = DBUS_TYPE_ARRAY;
01129   sig[i++] = DBUS_TYPE_STRING;
01130   sig[i++] = DBUS_TYPE_INVALID;  
01131 
01132   _dbus_assert (i < (int) _DBUS_N_ELEMENTS (sig));
01133 
01134   _dbus_verbose ("HEADER\n");
01135   _dbus_verbose_bytes_of_string (&message->header.data, 0,
01136                                  _dbus_string_get_length (&message->header.data));
01137   _dbus_verbose ("BODY\n");
01138   _dbus_verbose_bytes_of_string (&message->body, 0,
01139                                  _dbus_string_get_length (&message->body));
01140 
01141   _dbus_verbose ("Signature expected \"%s\" actual \"%s\"\n",
01142                  sig, dbus_message_get_signature (message));
01143 
01144   s = dbus_message_get_signature (message);
01145 
01146   _dbus_assert (dbus_message_has_signature (message, sig));
01147   _dbus_assert (strcmp (s, sig) == 0);
01148 
01149   verify_test_message (message);
01150 
01151   copy = dbus_message_copy (message);
01152 
01153   _dbus_assert (dbus_message_get_reply_serial (message) ==
01154                 dbus_message_get_reply_serial (copy));
01155   _dbus_assert (message->header.padding == copy->header.padding);
01156 
01157   _dbus_assert (_dbus_string_get_length (&message->header.data) ==
01158                 _dbus_string_get_length (&copy->header.data));
01159 
01160   _dbus_assert (_dbus_string_get_length (&message->body) ==
01161                 _dbus_string_get_length (&copy->body));
01162 
01163   verify_test_message (copy);
01164 
01165   name1 = dbus_message_get_interface (message);
01166   name2 = dbus_message_get_interface (copy);
01167 
01168   _dbus_assert (strcmp (name1, name2) == 0);
01169 
01170   name1 = dbus_message_get_member (message);
01171   name2 = dbus_message_get_member (copy);
01172 
01173   _dbus_assert (strcmp (name1, name2) == 0);
01174 
01175   dbus_message_unref (copy);
01176 
01177   /* Message loader test */
01178   _dbus_message_lock (message);
01179   loader = _dbus_message_loader_new ();
01180   
01181   /* check ref/unref */
01182   _dbus_message_loader_ref (loader);
01183   _dbus_message_loader_unref (loader);
01184 
01185   /* Write the header data one byte at a time */
01186   data = _dbus_string_get_const_data (&message->header.data);
01187   for (i = 0; i < _dbus_string_get_length (&message->header.data); i++)
01188     {
01189       DBusString *buffer;
01190 
01191       _dbus_message_loader_get_buffer (loader, &buffer);
01192       _dbus_string_append_byte (buffer, data[i]);
01193       _dbus_message_loader_return_buffer (loader, buffer, 1);
01194     }
01195 
01196   /* Write the body data one byte at a time */
01197   data = _dbus_string_get_const_data (&message->body);
01198   for (i = 0; i < _dbus_string_get_length (&message->body); i++)
01199     {
01200       DBusString *buffer;
01201 
01202       _dbus_message_loader_get_buffer (loader, &buffer);
01203       _dbus_string_append_byte (buffer, data[i]);
01204       _dbus_message_loader_return_buffer (loader, buffer, 1);
01205     }
01206 
01207   dbus_message_unref (message);
01208 
01209   /* Now pop back the message */
01210   if (!_dbus_message_loader_queue_messages (loader))
01211     _dbus_assert_not_reached ("no memory to queue messages");
01212 
01213   if (_dbus_message_loader_get_is_corrupted (loader))
01214     _dbus_assert_not_reached ("message loader corrupted");
01215 
01216   message = _dbus_message_loader_pop_message (loader);
01217   if (!message)
01218     _dbus_assert_not_reached ("received a NULL message");
01219 
01220   if (dbus_message_get_reply_serial (message) != 5678)
01221     _dbus_assert_not_reached ("reply serial fields differ");
01222 
01223   verify_test_message (message);
01224 
01225   dbus_message_unref (message);
01226   _dbus_message_loader_unref (loader);
01227 
01228   check_memleaks ();
01229 
01230   /* Load all the sample messages from the message factory */
01231   {
01232     DBusMessageDataIter diter;
01233     DBusMessageData mdata;
01234     int count;
01235 
01236     reset_validities_seen ();
01237     
01238     count = 0;
01239     _dbus_message_data_iter_init (&diter);
01240     
01241     while (_dbus_message_data_iter_get_and_next (&diter,
01242                                                  &mdata))
01243       {
01244         if (!dbus_internal_do_not_use_try_message_data (&mdata.data,
01245                                                         mdata.expected_validity))
01246           {
01247             _dbus_warn ("expected validity %d and did not get it\n",
01248                         mdata.expected_validity);
01249             _dbus_assert_not_reached ("message data failed");
01250           }
01251 
01252         _dbus_message_data_free (&mdata);
01253 
01254         count += 1;
01255       }
01256 
01257     printf ("%d sample messages tested\n", count);
01258 
01259     print_validities_seen (FALSE);
01260     print_validities_seen (TRUE);
01261   }
01262   
01263   check_memleaks ();
01264   
01265   /* Now load every message in test_data_dir if we have one */
01266   if (test_data_dir == NULL)
01267     return TRUE;
01268 
01269   return dbus_internal_do_not_use_foreach_message_file (test_data_dir,
01270                                                         (DBusForeachMessageFileFunc)
01271                                                         dbus_internal_do_not_use_try_message_file,
01272                                                         NULL);  
01273 }
01274 
01275 #endif /* DBUS_BUILD_TESTS */

Generated on Fri Sep 21 18:12:12 2007 for D-Bus by  doxygen 1.5.1