diff options
| author | Havoc Pennington <hp@redhat.com> | 2003-05-05 03:13:35 +0000 | 
|---|---|---|
| committer | Havoc Pennington <hp@redhat.com> | 2003-05-05 03:13:35 +0000 | 
| commit | d1c7eefb66483c3ea4d9e7fb6dca23dcfac8cad5 (patch) | |
| tree | d012f30757e2319ff1862f51d406291506be5b55 | |
| parent | 3d0dcbf536601e39d3d5125ed29f5afa217c9bf6 (diff) | |
2003-05-04  Havoc Pennington  <hp@pobox.com>
	* dbus/dbus-message-handler.c (_dbus_message_handler_test): add
	unit test
	* dbus/dbus-marshal.c (_dbus_demarshal_string_array): fix this
	function, which assumed length was in # of strings, not bytes
	* dbus/dbus-message.c (_dbus_message_test): add tests for some
	missing coverage
	* dbus/dbus-connection.c
	(_dbus_connection_queue_received_message): disable function for
	now, we are only using it in test mode
	* dbus/dbus-message.c (_dbus_message_loader_queue_messages):
	remove a mistaken FIXME
| -rw-r--r-- | ChangeLog | 18 | ||||
| -rw-r--r-- | dbus/dbus-auth-script.c | 8 | ||||
| -rw-r--r-- | dbus/dbus-connection.c | 3 | ||||
| -rw-r--r-- | dbus/dbus-hash.c | 11 | ||||
| -rw-r--r-- | dbus/dbus-keyring.c | 8 | ||||
| -rw-r--r-- | dbus/dbus-marshal.c | 60 | ||||
| -rw-r--r-- | dbus/dbus-message-builder.c | 5 | ||||
| -rw-r--r-- | dbus/dbus-message-handler.c | 51 | ||||
| -rw-r--r-- | dbus/dbus-message.c | 202 | ||||
| -rw-r--r-- | dbus/dbus-string.c | 5 | ||||
| -rw-r--r-- | dbus/dbus-sysdeps.c | 3 | ||||
| -rw-r--r-- | dbus/dbus-test.c | 30 | ||||
| -rw-r--r-- | dbus/dbus-test.h | 34 | 
13 files changed, 367 insertions, 71 deletions
| @@ -1,5 +1,23 @@  2003-05-04  Havoc Pennington  <hp@pobox.com> +	* dbus/dbus-message-handler.c (_dbus_message_handler_test): add +	unit test + +	* dbus/dbus-marshal.c (_dbus_demarshal_string_array): fix this +	function, which assumed length was in # of strings, not bytes + +	* dbus/dbus-message.c (_dbus_message_test): add tests for some +	missing coverage + +	* dbus/dbus-connection.c +	(_dbus_connection_queue_received_message): disable function for +	now, we are only using it in test mode + +	* dbus/dbus-message.c (_dbus_message_loader_queue_messages): +	remove a mistaken FIXME + +2003-05-04  Havoc Pennington  <hp@pobox.com> +  	* dbus/dbus-connection.c (dbus_connection_preallocate_send):  	unlock mutex on successful return, patch from Anders Gustafsson diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index d61ecb59..37f88900 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -278,6 +278,10 @@ _dbus_auth_script_run (const DBusString *filename)                goto out;              } +          /* test ref/unref */ +          _dbus_auth_ref (auth); +          _dbus_auth_unref (auth); +                      _dbus_credentials_from_current_process (&creds);            _dbus_auth_set_credentials (auth, &creds);          } @@ -299,6 +303,10 @@ _dbus_auth_script_run (const DBusString *filename)                goto out;              } +          /* test ref/unref */ +          _dbus_auth_ref (auth); +          _dbus_auth_unref (auth); +                      _dbus_credentials_from_current_process (&creds);            _dbus_auth_set_credentials (auth, &creds);            _dbus_auth_set_context (auth, &context); diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index ad037fe0..688841d7 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -221,6 +221,8 @@ _dbus_connection_wakeup_mainloop (DBusConnection *connection)      (*connection->wakeup_main_function) (connection->wakeup_main_data);  } +#ifdef DBUS_BUILD_TESTS +/* For now this function isn't used */  /**   * Adds a message to the incoming message queue, returning #FALSE   * if there's insufficient memory to queue the message. @@ -245,6 +247,7 @@ _dbus_connection_queue_received_message (DBusConnection *connection,    return TRUE;  } +#endif  /**   * Adds a message-containing list link to the incoming message queue, diff --git a/dbus/dbus-hash.c b/dbus/dbus-hash.c index 8d2747b4..2c410010 100644 --- a/dbus/dbus-hash.c +++ b/dbus/dbus-hash.c @@ -1094,6 +1094,8 @@ _dbus_hash_table_lookup_int (DBusHashTable *table,      return NULL;  } +#ifdef DBUS_BUILD_TESTS +/* disabled since it's only used for testing */  /**   * Looks up the value for a given integer in a hash table   * of type #DBUS_HASH_POINTER. Returns %NULL if the value @@ -1118,6 +1120,7 @@ _dbus_hash_table_lookup_pointer (DBusHashTable *table,    else      return NULL;  } +#endif /* DBUS_BUILD_TESTS */  /**   * Looks up the value for a given integer in a hash table @@ -1200,6 +1203,8 @@ _dbus_hash_table_remove_int (DBusHashTable *table,      return FALSE;  } +#ifdef DBUS_BUILD_TESTS +/* disabled since it's only used for testing */  /**   * Removes the hash entry for the given key. If no hash entry   * for the key exists, does nothing. @@ -1227,7 +1232,7 @@ _dbus_hash_table_remove_pointer (DBusHashTable *table,    else      return FALSE;  } - +#endif /* DBUS_BUILD_TESTS */  /**   * Removes the hash entry for the given key. If no hash entry @@ -1332,6 +1337,8 @@ _dbus_hash_table_insert_int (DBusHashTable *table,    return TRUE;  } +#ifdef DBUS_BUILD_TESTS +/* disabled since it's only used for testing */  /**   * Creates a hash entry with the given key and value.   * The key and value are not copied; they are stored @@ -1372,7 +1379,7 @@ _dbus_hash_table_insert_pointer (DBusHashTable *table,    return TRUE;  } - +#endif /* DBUS_BUILD_TESTS */  /**   * Creates a hash entry with the given key and value. diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 6606ee99..b5974af0 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -1138,6 +1138,14 @@ _dbus_keyring_test (void)    printf (" %d keys in test\n", ring1->n_keys); +  /* Test ref/unref */ +  _dbus_keyring_ref (ring1); +  _dbus_keyring_ref (ring2); +  _dbus_keyring_unref (ring1); +  _dbus_keyring_unref (ring2); + + +  /* really unref */    _dbus_keyring_unref (ring1);    _dbus_keyring_unref (ring2); diff --git a/dbus/dbus-marshal.c b/dbus/dbus-marshal.c index e403bfdd..7841ad38 100644 --- a/dbus/dbus-marshal.c +++ b/dbus/dbus-marshal.c @@ -1004,9 +1004,9 @@ _dbus_demarshal_uint64  (const DBusString *str,   */  char *  _dbus_demarshal_string (const DBusString *str, -			int         byte_order, -			int         pos, -			int        *new_pos) +			int               byte_order, +			int               pos, +			int              *new_pos)  {    int len;    char *retval; @@ -1330,12 +1330,14 @@ _dbus_demarshal_string_array (const DBusString   *str,  			      char             ***array,  			      int                *array_len)  { -  int len, i, j; +  int bytes_len, i; +  int len, allocated; +  int end_pos;    char **retval; - -  len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos); - -  if (len == 0) +   +  bytes_len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos); +   +  if (bytes_len == 0)      {        *array_len = 0;        *array = NULL; @@ -1345,32 +1347,50 @@ _dbus_demarshal_string_array (const DBusString   *str,        return TRUE;      } + +  len = 0; +  allocated = 4; +  end_pos = pos + bytes_len; -  retval = dbus_new (char *, len + 1); +  retval = dbus_new (char *, allocated);    if (!retval)      return FALSE; -  retval[len] = NULL; -   -  for (i = 0; i < len; i++) +  while (pos < end_pos)      { -      retval[i] = _dbus_demarshal_string (str, byte_order, pos, &pos); - -      if (retval[i] == 0) +      retval[len] = _dbus_demarshal_string (str, byte_order, pos, &pos); +       +      if (retval[len] == NULL)  	goto error; +       +      len += 1; + +      if (len >= allocated - 1) /* -1 for NULL termination */ +        { +          char **newp; +          newp = dbus_realloc (retval, +                               sizeof (char*) * allocated * 2); +          if (newp == NULL) +            goto error; + +          allocated *= 2; +          retval = newp; +        }      } +       +  retval[len] = NULL; - if (new_pos) +  if (new_pos)      *new_pos = pos; - - *array = retval; - *array_len = len; +   +  *array = retval; +  *array_len = len;    return TRUE;   error: -  for (j = 0; j < i; j++) +  for (i = 0; i < len; i++)      dbus_free (retval[i]);    dbus_free (retval); diff --git a/dbus/dbus-message-builder.c b/dbus/dbus-message-builder.c index 135e4bb0..30b250e8 100644 --- a/dbus/dbus-message-builder.c +++ b/dbus/dbus-message-builder.c @@ -1160,12 +1160,11 @@ _dbus_message_data_load (DBusString       *dest,                                                 "UINT32"))          {            SAVE_FOR_UNALIGN (dest, 4); -          long val; +          unsigned long val;            _dbus_string_delete_first_word (&line); -          /* FIXME should have _dbus_string_parse_uint32 */ -          if (!_dbus_string_parse_int (&line, 0, &val, NULL)) +          if (!_dbus_string_parse_uint (&line, 0, &val, NULL))              goto parse_failed;            if (!_dbus_marshal_uint32 (dest, endian, diff --git a/dbus/dbus-message-handler.c b/dbus/dbus-message-handler.c index 964f7d72..0b44e133 100644 --- a/dbus/dbus-message-handler.c +++ b/dbus/dbus-message-handler.c @@ -25,6 +25,7 @@  #include "dbus-message-handler.h"  #include "dbus-list.h"  #include "dbus-threads.h" +#include "dbus-test.h"  #include "dbus-connection-internal.h"  /** @@ -318,3 +319,53 @@ dbus_message_handler_set_function (DBusMessageHandler        *handler,  }  /** @} */ + +#ifdef DBUS_BUILD_TESTS +static DBusHandlerResult +test_handler (DBusMessageHandler *handler, +              DBusConnection     *connection, +              DBusMessage        *message, +              void               *user_data) +{ +  return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS; +} + +static void +free_test_data (void *data) +{ +  /* does nothing */ +} + +/** + * @ingroup DBusMessageInternals + * Unit test for DBusMessageHandler. + * + * @returns #TRUE on success. + */ +dbus_bool_t +_dbus_message_handler_test (const char *test_data_dir) +{ +  DBusMessageHandler *handler; + +#define TEST_DATA ((void*) 0xcafebabe) +   +  handler = dbus_message_handler_new (test_handler, +                                      TEST_DATA, +                                      free_test_data); + +  _dbus_assert (handler != NULL); +  _dbus_assert (handler->function == test_handler); + +  if (dbus_message_handler_get_data (handler) != TEST_DATA) +    _dbus_assert_not_reached ("got wrong data"); + +  dbus_message_handler_set_function (handler, NULL); +  _dbus_assert (handler->function == NULL); + +  dbus_message_handler_ref (handler); +  dbus_message_handler_unref (handler); +  dbus_message_handler_unref (handler); +   +  return TRUE; +} +#endif /* DBUS_BUILD_TESTS */ diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index efe26b9e..668736dc 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -4478,8 +4478,9 @@ _dbus_message_loader_queue_messages (DBusMessageLoader *loader)            _dbus_assert (_dbus_string_get_length (&message->header) == header_len);            _dbus_assert (_dbus_string_get_length (&message->body) == body_len); -          /* Fill in caches */ -          /* FIXME there's no type check if the field has the wrong type */ +          /* Fill in caches (we checked the types of these fields +           * earlier) +           */            message->reply_serial = get_uint_field (message,                                                    FIELD_REPLY_SERIAL);            message->client_serial = get_uint_field (message, @@ -5224,6 +5225,11 @@ dbus_internal_do_not_use_try_message_data (const DBusString    *data,    loader = _dbus_message_loader_new (); +  /* check some trivial loader functions */ +  _dbus_message_loader_ref (loader); +  _dbus_message_loader_unref (loader); +  _dbus_message_loader_get_max_message_size (loader); +      len = _dbus_string_get_length (data);    for (i = 0; i < len; i++)      { @@ -5449,18 +5455,33 @@ dbus_internal_do_not_use_foreach_message_file (const char                *test_d  static void  verify_test_message (DBusMessage *message)  { +  DBusMessageIter iter, dict; +  DBusError error;    dbus_int32_t our_int;    char *our_str;    double our_double;    dbus_bool_t our_bool; -  dbus_int32_t *our_int_array;    dbus_uint32_t our_uint32; -  int our_int_array_len; -  DBusMessageIter iter, dict; -  DBusError error; +  dbus_int32_t *our_uint32_array; +  int our_uint32_array_len; +  dbus_int32_t *our_int32_array; +  int our_int32_array_len; +  char **our_string_array; +  int our_string_array_len;  #ifdef DBUS_HAVE_INT64    dbus_int64_t our_int64; +  dbus_uint64_t our_uint64; +  dbus_int64_t *our_uint64_array; +  int our_uint64_array_len; +  dbus_int64_t *our_int64_array; +  int our_int64_array_len;  #endif +  double *our_double_array; +  int our_double_array_len; +  unsigned char *our_byte_array; +  int our_byte_array_len; +  unsigned char *our_boolean_array; +  int our_boolean_array_len;    dbus_message_iter_init (message, &iter); @@ -5469,14 +5490,33 @@ verify_test_message (DBusMessage *message)  				   DBUS_TYPE_INT32, &our_int,  #ifdef DBUS_HAVE_INT64                                     DBUS_TYPE_INT64, &our_int64, +                                   DBUS_TYPE_UINT64, &our_uint64,  #endif  				   DBUS_TYPE_STRING, &our_str,  				   DBUS_TYPE_DOUBLE, &our_double,  				   DBUS_TYPE_BOOLEAN, &our_bool, -				   DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &our_int_array, &our_int_array_len, +				   DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, +                                   &our_uint32_array, &our_uint32_array_len, +                                   DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, +                                   &our_int32_array, &our_int32_array_len, +#ifdef DBUS_HAVE_INT64 +				   DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, +                                   &our_uint64_array, &our_uint64_array_len, +                                   DBUS_TYPE_ARRAY, DBUS_TYPE_INT64, +                                   &our_int64_array, &our_int64_array_len, +#endif +                                   DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, +                                   &our_string_array, &our_string_array_len, +                                   DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE, +                                   &our_double_array, &our_double_array_len, +                                   DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, +                                   &our_byte_array, &our_byte_array_len, +                                   DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN, +                                   &our_boolean_array, &our_boolean_array_len,  				   0))      { -      _dbus_verbose ("error: %s - %s\n", error.name, (error.message != NULL)?error.message: "no message"); +      _dbus_warn ("error: %s - %s\n", error.name, +                  (error.message != NULL) ? error.message : "no message");        _dbus_assert_not_reached ("Could not get arguments");      } @@ -5486,6 +5526,8 @@ verify_test_message (DBusMessage *message)  #ifdef DBUS_HAVE_INT64    if (our_int64 != -0x123456789abcd)      _dbus_assert_not_reached ("64-bit integers differ!"); +  if (our_uint64 != 0x123456789abcd) +    _dbus_assert_not_reached ("64-bit unsigned integers differ!");  #endif    if (our_double != 3.14159) @@ -5498,14 +5540,87 @@ verify_test_message (DBusMessage *message)    if (!our_bool)      _dbus_assert_not_reached ("booleans differ"); -  if (our_int_array_len != 4 || -      our_int_array[0] != 0x12345678 || -      our_int_array[1] != 0x23456781 || -      our_int_array[2] != 0x34567812 || -      our_int_array[3] != 0x45678123) -    _dbus_assert_not_reached ("array differ"); -  dbus_free (our_int_array); +  if (our_uint32_array_len != 4 || +      our_uint32_array[0] != 0x12345678 || +      our_uint32_array[1] != 0x23456781 || +      our_uint32_array[2] != 0x34567812 || +      our_uint32_array[3] != 0x45678123) +    _dbus_assert_not_reached ("uint array differs"); +  dbus_free (our_uint32_array); + +  if (our_int32_array_len != 4 || +      our_int32_array[0] != 0x12345678 || +      our_int32_array[1] != -0x23456781 || +      our_int32_array[2] != 0x34567812 || +      our_int32_array[3] != -0x45678123) +    _dbus_assert_not_reached ("int array differs"); +  dbus_free (our_int32_array); + +#ifdef DBUS_HAVE_INT64 +  if (our_uint64_array_len != 4 || +      our_uint64_array[0] != 0x12345678 || +      our_uint64_array[1] != 0x23456781 || +      our_uint64_array[2] != 0x34567812 || +      our_uint64_array[3] != 0x45678123) +    _dbus_assert_not_reached ("uint64 array differs"); +  dbus_free (our_uint64_array); +   +  if (our_int64_array_len != 4 || +      our_int64_array[0] != 0x12345678 || +      our_int64_array[1] != -0x23456781 || +      our_int64_array[2] != 0x34567812 || +      our_int64_array[3] != -0x45678123) +    _dbus_assert_not_reached ("int64 array differs"); +  dbus_free (our_int64_array); +#endif /* DBUS_HAVE_INT64 */ +   +  if (our_string_array_len != 4) +    _dbus_assert_not_reached ("string array has wrong length"); + +  if (strcmp (our_string_array[0], "Foo") != 0 || +      strcmp (our_string_array[1], "bar") != 0 || +      strcmp (our_string_array[2], "") != 0 || +      strcmp (our_string_array[3], "woo woo woo woo") != 0) +    _dbus_assert_not_reached ("string array differs"); + +  dbus_free_string_array (our_string_array); + +  if (our_double_array_len != 3) +    _dbus_assert_not_reached ("double array had wrong length"); + +  /* On all IEEE machines (i.e. everything sane) exact equality +   * should be preserved over the wire +   */ +  if (our_double_array[0] != 0.1234 || +      our_double_array[1] != 9876.54321 || +      our_double_array[2] != -300.0) +    _dbus_assert_not_reached ("double array had wrong values"); +  dbus_free (our_double_array); + +  if (our_byte_array_len != 4) +    _dbus_assert_not_reached ("byte array had wrong length"); + +  if (our_byte_array[0] != 'a' || +      our_byte_array[1] != 'b' || +      our_byte_array[2] != 'c' || +      our_byte_array[3] != 234) +    _dbus_assert_not_reached ("byte array had wrong values"); + +  dbus_free (our_byte_array); + +  if (our_boolean_array_len != 5) +    _dbus_assert_not_reached ("bool array had wrong length"); + +  if (our_boolean_array[0] != TRUE || +      our_boolean_array[1] != FALSE || +      our_boolean_array[2] != TRUE || +      our_boolean_array[3] != TRUE || +      our_boolean_array[4] != FALSE) +    _dbus_assert_not_reached ("bool array had wrong values"); + +  dbus_free (our_boolean_array); +      if (!dbus_message_iter_next (&iter))      _dbus_assert_not_reached ("Reached end of arguments"); @@ -5565,10 +5680,41 @@ _dbus_message_test (const char *test_data_dir)    DBusMessage *copy;    const char *name1;    const char *name2; -  const dbus_uint32_t our_int32_array[] = { 0x12345678, 0x23456781, 0x34567812, 0x45678123 }; - +  const dbus_uint32_t our_uint32_array[] = +    { 0x12345678, 0x23456781, 0x34567812, 0x45678123 }; +  const dbus_uint32_t our_int32_array[] = +    { 0x12345678, -0x23456781, 0x34567812, -0x45678123 }; +#ifdef DBUS_HAVE_INT64 +  const dbus_uint64_t our_uint64_array[] = +    { 0x12345678, 0x23456781, 0x34567812, 0x45678123 }; +  const dbus_uint64_t our_int64_array[] = +    { 0x12345678, -0x23456781, 0x34567812, -0x45678123 }; +#endif +  const char *our_string_array[] = { "Foo", "bar", "", "woo woo woo woo" }; +  const double our_double_array[] = { 0.1234, 9876.54321, -300.0 }; +  const unsigned char our_byte_array[] = { 'a', 'b', 'c', 234 }; +  const unsigned char our_boolean_array[] = { TRUE, FALSE, TRUE, TRUE, FALSE }; +      _dbus_assert (sizeof (DBusMessageRealIter) <= sizeof (DBusMessageIter)); +  message = dbus_message_new ("test.Message", "org.freedesktop.DBus.Test"); +  _dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.Test")); +  _dbus_message_set_serial (message, 1234); +  dbus_message_set_sender (message, "org.foo.bar"); +  _dbus_assert (dbus_message_has_sender (message, "org.foo.bar")); +  dbus_message_set_sender (message, NULL); +  _dbus_assert (!dbus_message_has_sender (message, "org.foo.bar")); +  _dbus_assert (dbus_message_get_serial (message) == 1234); +  _dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.Test")); + +  _dbus_assert (dbus_message_get_is_error (message) == FALSE); +  dbus_message_set_is_error (message, TRUE); +  _dbus_assert (dbus_message_get_is_error (message) == TRUE); +  dbus_message_set_is_error (message, FALSE); +  _dbus_assert (dbus_message_get_is_error (message) == FALSE); +   +  dbus_message_unref (message); +      /* Test the vararg functions */    message = dbus_message_new ("test.Message", "org.freedesktop.DBus.Test");    _dbus_message_set_serial (message, 1); @@ -5576,11 +5722,27 @@ _dbus_message_test (const char *test_data_dir)  			    DBUS_TYPE_INT32, -0x12345678,  #ifdef DBUS_HAVE_INT64                              DBUS_TYPE_INT64, -0x123456789abcd, +                            DBUS_TYPE_UINT64, 0x123456789abcd,  #endif  			    DBUS_TYPE_STRING, "Test string",  			    DBUS_TYPE_DOUBLE, 3.14159,  			    DBUS_TYPE_BOOLEAN, TRUE, -			    DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, our_int32_array, 4, +			    DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, our_uint32_array, +                            _DBUS_N_ELEMENTS (our_uint32_array), +                            DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, our_int32_array, +                            _DBUS_N_ELEMENTS (our_int32_array), +                            DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, our_uint64_array, +                            _DBUS_N_ELEMENTS (our_uint64_array), +                            DBUS_TYPE_ARRAY, DBUS_TYPE_INT64, our_int64_array, +                            _DBUS_N_ELEMENTS (our_int64_array), +                            DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, our_string_array, +                            _DBUS_N_ELEMENTS (our_string_array), +                            DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE, our_double_array, +                            _DBUS_N_ELEMENTS (our_double_array), +                            DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, our_byte_array, +                            _DBUS_N_ELEMENTS (our_byte_array), +                            DBUS_TYPE_ARRAY, DBUS_TYPE_BOOLEAN, our_boolean_array, +                            _DBUS_N_ELEMENTS (our_boolean_array),  			    0);    dbus_message_append_iter_init (message, &iter); @@ -5663,6 +5825,10 @@ _dbus_message_test (const char *test_data_dir)    _dbus_message_lock (message);    loader = _dbus_message_loader_new (); +  /* check ref/unref */ +  _dbus_message_loader_ref (loader); +  _dbus_message_loader_unref (loader); +      /* Write the header data one byte at a time */    data = _dbus_string_get_const_data (&message->header);    for (i = 0; i < _dbus_string_get_length (&message->header); i++) diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 8abc74ac..65d2fb1b 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -301,6 +301,10 @@ _dbus_string_free (DBusString *str)    real->invalid = TRUE;  } +#ifdef DBUS_BUILD_TESTS +/* Not using this feature at the moment, + * so marked DBUS_BUILD_TESTS-only + */  /**   * Locks a string such that any attempts to change the string will   * result in aborting the program. Also, if the string is wasting a @@ -338,6 +342,7 @@ _dbus_string_lock (DBusString *str)          }      }  } +#endif /* DBUS_BUILD_TESTS */  static dbus_bool_t  set_length (DBusRealString *real, diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index d59498b1..91f6e95a 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -1070,6 +1070,8 @@ _dbus_string_parse_int (const DBusString *str,    return TRUE;  } +#ifdef DBUS_BUILD_TESTS +/* Not currently used, so only built when tests are enabled */  /**   * Parses an unsigned integer contained in a DBusString. Either return   * parameter may be #NULL if you aren't interested in it. The integer @@ -1108,6 +1110,7 @@ _dbus_string_parse_uint (const DBusString *str,    return TRUE;  } +#endif /* DBUS_BUILD_TESTS */  static dbus_bool_t  ascii_isspace (char c) diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c index 6f7431a8..00eb22dc 100644 --- a/dbus/dbus-test.c +++ b/dbus/dbus-test.c @@ -87,12 +87,6 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir)      die ("sysdeps");    check_memleaks (); - -  printf ("%s: running spawn tests\n", "dbus-test"); -  if (!_dbus_spawn_test (test_data_dir)) -    die ("spawn"); - -  check_memleaks ();    printf ("%s: running data slot tests\n", "dbus-test");    if (!_dbus_data_slot_test ()) @@ -112,12 +106,6 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir)    check_memleaks (); -  printf ("%s: running message tests\n", "dbus-test"); -  if (!_dbus_message_test (test_data_dir)) -    die ("messages"); - -  check_memleaks (); -      printf ("%s: running memory pool tests\n", "dbus-test");    if (!_dbus_mem_pool_test ())      die ("memory pools"); @@ -130,12 +118,30 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir)    check_memleaks (); +  printf ("%s: running message tests\n", "dbus-test"); +  if (!_dbus_message_test (test_data_dir)) +    die ("messages"); + +  check_memleaks (); + +  printf ("%s: running message handler tests\n", "dbus-test"); +  if (!_dbus_message_handler_test (test_data_dir)) +    die ("message handler"); + +  check_memleaks (); +      printf ("%s: running hash table tests\n", "dbus-test");    if (!_dbus_hash_test ())      die ("hash tables");    check_memleaks (); +  printf ("%s: running spawn tests\n", "dbus-test"); +  if (!_dbus_spawn_test (test_data_dir)) +    die ("spawn"); + +  check_memleaks (); +      printf ("%s: running user database tests\n", "dbus-test");    if (!_dbus_userdb_test (test_data_dir))      die ("user database"); diff --git a/dbus/dbus-test.h b/dbus/dbus-test.h index e97fd85a..2216a433 100644 --- a/dbus/dbus-test.h +++ b/dbus/dbus-test.h @@ -35,22 +35,24 @@ typedef enum    _DBUS_MESSAGE_UNKNOWN  } DBusMessageValidity; -dbus_bool_t _dbus_hash_test      (void); -dbus_bool_t _dbus_dict_test      (void); -dbus_bool_t _dbus_list_test      (void); -dbus_bool_t _dbus_marshal_test   (void); -dbus_bool_t _dbus_mem_pool_test  (void); -dbus_bool_t _dbus_string_test    (void); -dbus_bool_t _dbus_address_test   (void); -dbus_bool_t _dbus_message_test   (const char *test_data_dir); -dbus_bool_t _dbus_auth_test      (const char *test_data_dir); -dbus_bool_t _dbus_md5_test       (void); -dbus_bool_t _dbus_sha_test       (const char *test_data_dir); -dbus_bool_t _dbus_keyring_test   (void); -dbus_bool_t _dbus_data_slot_test (void); -dbus_bool_t _dbus_sysdeps_test   (void); -dbus_bool_t _dbus_spawn_test     (const char *test_data_dir); -dbus_bool_t _dbus_userdb_test    (const char *test_data_dir); +dbus_bool_t _dbus_hash_test            (void); +dbus_bool_t _dbus_dict_test            (void); +dbus_bool_t _dbus_list_test            (void); +dbus_bool_t _dbus_marshal_test         (void); +dbus_bool_t _dbus_mem_pool_test        (void); +dbus_bool_t _dbus_string_test          (void); +dbus_bool_t _dbus_address_test         (void); +dbus_bool_t _dbus_message_test         (const char *test_data_dir); +dbus_bool_t _dbus_message_handler_test (const char *test_data_dir); +dbus_bool_t _dbus_auth_test            (const char *test_data_dir); +dbus_bool_t _dbus_md5_test             (void); +dbus_bool_t _dbus_sha_test             (const char *test_data_dir); +dbus_bool_t _dbus_keyring_test         (void); +dbus_bool_t _dbus_data_slot_test       (void); +dbus_bool_t _dbus_sysdeps_test         (void); +dbus_bool_t _dbus_spawn_test           (const char *test_data_dir); +dbus_bool_t _dbus_userdb_test          (const char *test_data_dir); +  void        dbus_internal_do_not_use_run_tests         (const char          *test_data_dir);  dbus_bool_t dbus_internal_do_not_use_try_message_file  (const DBusString    *filename, | 
