Coverage report for dbus/dbus-message-factory.c.gcov

        -:    0:Source:dbus-message-factory.c
        -:    0:Graph:.libs/dbus-message-factory.gcno
        -:    0:Data:.libs/dbus-message-factory.gcda
        -:    0:Runs:765
        -:    0:Programs:1
        -:    1:/* -*- mode: C; c-file-style: "gnu" -*- */
        -:    2:/* dbus-message-factory.c Generator of valid and invalid message data for test suite
        -:    3: *
        -:    4: * Copyright (C) 2005 Red Hat Inc.
        -:    5: *
        -:    6: * Licensed under the Academic Free License version 2.1
        -:    7: * 
        -:    8: * This program is free software; you can redistribute it and/or modify
        -:    9: * it under the terms of the GNU General Public License as published by
        -:   10: * the Free Software Foundation; either version 2 of the License, or
        -:   11: * (at your option) any later version.
        -:   12: *
        -:   13: * This program is distributed in the hope that it will be useful,
        -:   14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
        -:   15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        -:   16: * GNU General Public License for more details.
        -:   17: * 
        -:   18: * You should have received a copy of the GNU General Public License
        -:   19: * along with this program; if not, write to the Free Software
        -:   20: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        -:   21: *
        -:   22: */
        -:   23:#include <config.h>
        -:   24:
        -:   25:#ifdef DBUS_BUILD_TESTS
        -:   26:#include "dbus-message-factory.h"
        -:   27:#include "dbus-message-private.h"
        -:   28:#include "dbus-test.h"
        -:   29:#include <stdio.h>
        -:   30:
        -:   31:typedef enum
        -:   32:  {
        -:   33:    CHANGE_TYPE_ADJUST,
        -:   34:    CHANGE_TYPE_ABSOLUTE
        -:   35:  } ChangeType;
        -:   36:
        -:   37:#define BYTE_ORDER_OFFSET  0
        -:   38:#define TYPE_OFFSET        1
        -:   39:#define BODY_LENGTH_OFFSET 4
        -:   40:#define FIELDS_ARRAY_LENGTH_OFFSET 12
        -:   41:
        -:   42:static void
        -:   43:iter_recurse (DBusMessageDataIter *iter)
function iter_recurse called 141199 returned 100% blocks executed 100%
   141199:   44:{
   141199:   45:  iter->depth += 1;
   141199:   46:  _dbus_assert (iter->depth < _DBUS_MESSAGE_DATA_MAX_NESTING);
call    0 returned 100%
   141199:   47:  _dbus_assert (iter->sequence_nos[iter->depth] >= 0);
call    0 returned 100%
   141199:   48:}
        -:   49:
        -:   50:static int
        -:   51:iter_get_sequence (DBusMessageDataIter *iter)
function iter_get_sequence called 241418 returned 100% blocks executed 100%
   241418:   52:{
   241418:   53:  _dbus_assert (iter->sequence_nos[iter->depth] >= 0);
call    0 returned 100%
   241418:   54:  return iter->sequence_nos[iter->depth];
        -:   55:}
        -:   56:
        -:   57:static void
        -:   58:iter_set_sequence (DBusMessageDataIter *iter,
        -:   59:                   int                  sequence)
function iter_set_sequence called 50112 returned 100% blocks executed 100%
    50112:   60:{
    50112:   61:  _dbus_assert (sequence >= 0);
call    0 returned 100%
    50112:   62:  iter->sequence_nos[iter->depth] = sequence;
    50112:   63:}
        -:   64:
        -:   65:static void
        -:   66:iter_unrecurse (DBusMessageDataIter *iter)
function iter_unrecurse called 141199 returned 100% blocks executed 100%
   141199:   67:{
   141199:   68:  iter->depth -= 1;
   141199:   69:  _dbus_assert (iter->depth >= 0);
call    0 returned 100%
   141199:   70:}
        -:   71:
        -:   72:static void
        -:   73:iter_next (DBusMessageDataIter *iter)
function iter_next called 212723 returned 100% blocks executed 100%
   212723:   74:{
   212723:   75:  iter->sequence_nos[iter->depth] += 1;
   212723:   76:}
        -:   77:
        -:   78:static dbus_bool_t
        -:   79:iter_first_in_series (DBusMessageDataIter *iter)
function iter_first_in_series called 51551 returned 100% blocks executed 100%
    51551:   80:{
        -:   81:  int i;
        -:   82:
    51551:   83:  i = iter->depth;
   103662:   84:  while (i < _DBUS_MESSAGE_DATA_MAX_NESTING)
branch  0 taken 99%
branch  1 taken 1% (fallthrough)
        -:   85:    {
    52105:   86:      if (iter->sequence_nos[i] != 0)
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
    51545:   87:        return FALSE;
      560:   88:      ++i;
        -:   89:    }
        6:   90:  return TRUE;
        -:   91:}
        -:   92:
        -:   93:typedef dbus_bool_t (* DBusInnerGeneratorFunc)   (DBusMessageDataIter *iter,
        -:   94:                                                  DBusMessage        **message_p);
        -:   95:typedef dbus_bool_t (* DBusMessageGeneratorFunc) (DBusMessageDataIter *iter,
        -:   96:                                                  DBusString          *data,
        -:   97:                                                  DBusValidity        *expected_validity);
        -:   98:
        -:   99:static void
        -:  100:set_reply_serial (DBusMessage *message)
function set_reply_serial called 51793 returned 100% blocks executed 67%
    51793:  101:{
    51793:  102:  if (message == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  103:    _dbus_assert_not_reached ("oom");
call    0 never executed
    51793:  104:  if (!dbus_message_set_reply_serial (message, 100))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  105:    _dbus_assert_not_reached ("oom");
call    0 never executed
    51793:  106:}
        -:  107:
        -:  108:static dbus_bool_t
        -:  109:generate_trivial_inner (DBusMessageDataIter *iter,
        -:  110:                        DBusMessage        **message_p)
function generate_trivial_inner called 5 returned 100% blocks executed 88%
        5:  111:{
        -:  112:  DBusMessage *message;
        -:  113:
        5:  114:  switch (iter_get_sequence (iter))
call    0 returned 100%
branch  1 taken 20%
branch  2 taken 20%
branch  3 taken 20%
branch  4 taken 20%
branch  5 taken 20%
        -:  115:    {
        -:  116:    case 0:
        1:  117:      message = dbus_message_new_method_call ("org.freedesktop.TextEditor",
call    0 returned 100%
        -:  118:                                              "/foo/bar",
        -:  119:                                              "org.freedesktop.DocumentFactory",
        -:  120:                                              "Create");
        1:  121:      break;
        -:  122:    case 1:
        1:  123:      message = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN);
call    0 returned 100%
        1:  124:      set_reply_serial (message);
call    0 returned 100%
        1:  125:      break;
        -:  126:    case 2:
        1:  127:      message = dbus_message_new_signal ("/foo/bar",
call    0 returned 100%
        -:  128:                                         "org.freedesktop.DocumentFactory",
        -:  129:                                         "Created");
        1:  130:      break;
        -:  131:    case 3:
        1:  132:      message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
call    0 returned 100%
        -:  133:
        1:  134:      if (!dbus_message_set_error_name (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  135:                                        "org.freedesktop.TestErrorName"))
    #####:  136:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  137:      
        -:  138:      {
        -:  139:        DBusMessageIter iter;
        1:  140:        const char *v_STRING = "This is an error";
        -:  141:        
        1:  142:        dbus_message_iter_init_append (message, &iter);
call    0 returned 100%
        1:  143:        if (!dbus_message_iter_append_basic (&iter,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  144:                                             DBUS_TYPE_STRING,
        -:  145:                                             &v_STRING))
    #####:  146:          _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  147:      }
        -:  148:      
        1:  149:      set_reply_serial (message);
call    0 returned 100%
        1:  150:      break;
        -:  151:    default:
        1:  152:      return FALSE;
        -:  153:    }
        -:  154:  
        4:  155:  if (message == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  156:    _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  157:
        4:  158:  *message_p = message;
        -:  159:  
        4:  160:  return TRUE;
        -:  161:}
        -:  162:
        -:  163:static dbus_bool_t
        -:  164:generate_many_bodies_inner (DBusMessageDataIter *iter,
        -:  165:                            DBusMessage        **message_p)
function generate_many_bodies_inner called 51789 returned 100% blocks executed 85%
    51789:  166:{
        -:  167:  DBusMessage *message;
        -:  168:  DBusString signature;
        -:  169:  DBusString body;
        -:  170:
        -:  171:  /* Keeping this small makes things go faster */
    51789:  172:  message = dbus_message_new_method_call ("o.z.F",
call    0 returned 100%
        -:  173:                                          "/",
        -:  174:                                          "o.z.B",
        -:  175:                                          "Nah");
    51789:  176:  if (message == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  177:    _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  178:
    51789:  179:  set_reply_serial (message);
call    0 returned 100%
        -:  180:
    51789:  181:  if (!_dbus_string_init (&signature) || !_dbus_string_init (&body))
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
call    3 returned 100%
branch  4 taken 0% (fallthrough)
branch  5 taken 100%
    #####:  182:    _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  183:  
    51789:  184:  if (dbus_internal_do_not_use_generate_bodies (iter_get_sequence (iter),
call    0 returned 100%
call    1 returned 100%
branch  2 taken 99% (fallthrough)
branch  3 taken 1%
        -:  185:                                                message->byte_order,
        -:  186:                                                &signature, &body))
        -:  187:    {
        -:  188:      const char *v_SIGNATURE;
        -:  189:
    51761:  190:      v_SIGNATURE = _dbus_string_get_const_data (&signature);
call    0 returned 100%
    51761:  191:      if (!_dbus_header_set_field_basic (&message->header,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  192:                                         DBUS_HEADER_FIELD_SIGNATURE,
        -:  193:                                         DBUS_TYPE_SIGNATURE,
        -:  194:                                         &v_SIGNATURE))
    #####:  195:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  196:
    51761:  197:      if (!_dbus_string_move (&body, 0, &message->body, 0))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  198:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  199:
    51761:  200:      _dbus_marshal_set_uint32 (&message->header.data, BODY_LENGTH_OFFSET,
call    0 returned 100%
call    1 returned 100%
        -:  201:                                _dbus_string_get_length (&message->body),
        -:  202:                                message->byte_order);
        -:  203:      
    51761:  204:      *message_p = message;
        -:  205:    }
        -:  206:  else
        -:  207:    {
       28:  208:      dbus_message_unref (message);
call    0 returned 100%
       28:  209:      *message_p = NULL;
        -:  210:    }
        -:  211:  
    51789:  212:  _dbus_string_free (&signature);
call    0 returned 100%
    51789:  213:  _dbus_string_free (&body);
call    0 returned 100%
        -:  214:
    51789:  215:  return *message_p != NULL;
        -:  216:}
        -:  217:
        -:  218:static void
        -:  219:generate_from_message (DBusString            *data,
        -:  220:                       DBusValidity          *expected_validity,
        -:  221:                       DBusMessage           *message)
function generate_from_message called 51785 returned 100% blocks executed 80%
    51785:  222:{
    51785:  223:  _dbus_message_set_serial (message, 1);
call    0 returned 100%
    51785:  224:  _dbus_message_lock (message);
call    0 returned 100%
        -:  225:
    51785:  226:  *expected_validity = DBUS_VALID;
        -:  227:  
        -:  228:  /* move for efficiency, since we'll nuke the message anyway */
    51785:  229:  if (!_dbus_string_move (&message->header.data, 0,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  230:                          data, 0))
    #####:  231:    _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  232:
    51785:  233:  if (!_dbus_string_copy (&message->body, 0,
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -:  234:                          data, _dbus_string_get_length (data)))
    #####:  235:    _dbus_assert_not_reached ("oom");
call    0 never executed
    51785:  236:}
        -:  237:
        -:  238:static dbus_bool_t
        -:  239:generate_outer (DBusMessageDataIter   *iter,
        -:  240:                DBusString            *data,
        -:  241:                DBusValidity          *expected_validity,
        -:  242:                DBusInnerGeneratorFunc func)
function generate_outer called 51794 returned 100% blocks executed 100%
    51794:  243:{
        -:  244:  DBusMessage *message;
        -:  245:
    51794:  246:  message = NULL;
    51794:  247:  if (!(*func)(iter, &message))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
       29:  248:    return FALSE;
        -:  249:
    51765:  250:  iter_next (iter);
call    0 returned 100%
        -:  251:  
    51765:  252:  _dbus_assert (message != NULL);
call    0 returned 100%
        -:  253:
    51765:  254:  generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  255:
    51765:  256:  dbus_message_unref (message);
call    0 returned 100%
        -:  257:
    51765:  258:  return TRUE;
        -:  259:}
        -:  260:
        -:  261:static dbus_bool_t
        -:  262:generate_trivial (DBusMessageDataIter   *iter,
        -:  263:                  DBusString            *data,
        -:  264:                  DBusValidity          *expected_validity)
function generate_trivial called 5 returned 100% blocks executed 100%
        5:  265:{
        5:  266:  return generate_outer (iter, data, expected_validity,
call    0 returned 100%
        -:  267:                         generate_trivial_inner);
        -:  268:}
        -:  269:
        -:  270:static dbus_bool_t
        -:  271:generate_many_bodies (DBusMessageDataIter   *iter,
        -:  272:                      DBusString            *data,
        -:  273:                      DBusValidity          *expected_validity)
function generate_many_bodies called 51789 returned 100% blocks executed 100%
    51789:  274:{
    51789:  275:  return generate_outer (iter, data, expected_validity,
call    0 returned 100%
        -:  276:                         generate_many_bodies_inner);
        -:  277:}
        -:  278:
        -:  279:static DBusMessage*
        -:  280:simple_method_call (void)
function simple_method_call called 17 returned 100% blocks executed 75%
       17:  281:{
        -:  282:  DBusMessage *message;
        -:  283:  /* Keeping this small makes stuff go faster */
       17:  284:  message = dbus_message_new_method_call ("o.b.Q",
call    0 returned 100%
        -:  285:                                          "/f/b",
        -:  286:                                          "o.b.Z",
        -:  287:                                          "Fro");
       17:  288:  if (message == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  289:    _dbus_assert_not_reached ("oom");
call    0 never executed
       17:  290:  return message;
        -:  291:}
        -:  292:
        -:  293:static DBusMessage*
        -:  294:simple_signal (void)
function simple_signal called 1 returned 100% blocks executed 75%
        1:  295:{
        -:  296:  DBusMessage *message;
        1:  297:  message = dbus_message_new_signal ("/f/b",
call    0 returned 100%
        -:  298:                                     "o.b.Z",
        -:  299:                                     "Fro");
        1:  300:  if (message == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  301:    _dbus_assert_not_reached ("oom");
call    0 never executed
        1:  302:  return message;
        -:  303:}
        -:  304:
        -:  305:static DBusMessage*
        -:  306:simple_method_return (void)
function simple_method_return called 1 returned 100% blocks executed 80%
        1:  307:{
        -:  308:  DBusMessage *message;
        1:  309:  message =  dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN);
call    0 returned 100%
        1:  310:  if (message == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  311:    _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  312:
        1:  313:  set_reply_serial (message);
call    0 returned 100%
        -:  314:  
        1:  315:  return message;
        -:  316:}
        -:  317:
        -:  318:static DBusMessage*
        -:  319:simple_error (void)
function simple_error called 1 returned 100% blocks executed 75%
        1:  320:{
        -:  321:  DBusMessage *message;
        1:  322:  message =  dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
call    0 returned 100%
        1:  323:  if (message == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  324:    _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  325:
        1:  326:  if (!dbus_message_set_error_name (message, "foo.bar"))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  327:    _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  328:  
        1:  329:  set_reply_serial (message);
call    0 returned 100%
        -:  330:  
        1:  331:  return message;
        -:  332:}
        -:  333:
        -:  334:static dbus_bool_t
        -:  335:generate_special (DBusMessageDataIter   *iter,
        -:  336:                  DBusString            *data,
        -:  337:                  DBusValidity          *expected_validity)
function generate_special called 21 returned 100% blocks executed 89%
       21:  338:{
        -:  339:  int item_seq;
        -:  340:  DBusMessage *message;
        -:  341:  int pos;
        -:  342:  dbus_int32_t v_INT32;
        -:  343:
       21:  344:  _dbus_assert (_dbus_string_get_length (data) == 0);
call    0 returned 100%
call    1 returned 100%
        -:  345:  
       21:  346:  message = NULL;
       21:  347:  pos = -1;
       21:  348:  v_INT32 = 42;
       21:  349:  item_seq = iter_get_sequence (iter);
call    0 returned 100%
        -:  350:
       21:  351:  if (item_seq == 0)
branch  0 taken 5% (fallthrough)
branch  1 taken 95%
        -:  352:    {
        1:  353:      message = simple_method_call ();
call    0 returned 100%
        1:  354:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  355:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  356:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  357:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  358:                                     DBUS_TYPE_INVALID))
    #####:  359:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  360:                                     
        1:  361:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  362:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  363:                                  NULL, &pos);
        1:  364:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  365:      
        -:  366:      /* set an invalid typecode */
        1:  367:      _dbus_string_set_byte (data, pos + 1, '$');
call    0 returned 100%
        -:  368:
        1:  369:      *expected_validity = DBUS_INVALID_UNKNOWN_TYPECODE;
        -:  370:    }
       20:  371:  else if (item_seq == 1)
branch  0 taken 5% (fallthrough)
branch  1 taken 95%
        -:  372:    {
        -:  373:      char long_sig[DBUS_MAXIMUM_TYPE_RECURSION_DEPTH+2];
        -:  374:      const char *v_STRING;
        -:  375:      int i;
        -:  376:      
        1:  377:      message = simple_method_call ();
call    0 returned 100%
        1:  378:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  379:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  380:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  381:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  382:                                     DBUS_TYPE_INVALID))
    #####:  383:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  384:
        1:  385:      i = 0;
       35:  386:      while (i < (DBUS_MAXIMUM_TYPE_RECURSION_DEPTH + 1))
branch  0 taken 97%
branch  1 taken 3% (fallthrough)
        -:  387:        {
       33:  388:          long_sig[i] = DBUS_TYPE_ARRAY;
       33:  389:          ++i;
        -:  390:        }
        1:  391:      long_sig[i] = DBUS_TYPE_INVALID;
        -:  392:
        1:  393:      v_STRING = long_sig;
        1:  394:      if (!_dbus_header_set_field_basic (&message->header,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  395:                                         DBUS_HEADER_FIELD_SIGNATURE,
        -:  396:                                         DBUS_TYPE_SIGNATURE,
        -:  397:                                         &v_STRING))
    #####:  398:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  399:      
        1:  400:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  401:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  402:                                  NULL, &pos);
        1:  403:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  404:      
        1:  405:      *expected_validity = DBUS_INVALID_EXCEEDED_MAXIMUM_ARRAY_RECURSION;
        -:  406:    }
       19:  407:  else if (item_seq == 2)
branch  0 taken 5% (fallthrough)
branch  1 taken 95%
        -:  408:    {
        -:  409:      char long_sig[DBUS_MAXIMUM_TYPE_RECURSION_DEPTH*2+4];
        -:  410:      const char *v_STRING;
        -:  411:      int i;
        -:  412:      
        1:  413:      message = simple_method_call ();
call    0 returned 100%
        1:  414:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  415:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  416:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  417:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  418:                                     DBUS_TYPE_INVALID))
    #####:  419:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  420:
        1:  421:      i = 0;
       36:  422:      while (i <= (DBUS_MAXIMUM_TYPE_RECURSION_DEPTH + 1))
branch  0 taken 97%
branch  1 taken 3% (fallthrough)
        -:  423:        {
       34:  424:          long_sig[i] = DBUS_STRUCT_BEGIN_CHAR;
       34:  425:          ++i;
        -:  426:        }
        -:  427:
        1:  428:      long_sig[i] = DBUS_TYPE_INT32;
        1:  429:      ++i;
        -:  430:
       34:  431:      while (i < (DBUS_MAXIMUM_TYPE_RECURSION_DEPTH*2 + 3))
branch  0 taken 97%
branch  1 taken 3% (fallthrough)
        -:  432:        {
       32:  433:          long_sig[i] = DBUS_STRUCT_END_CHAR;
       32:  434:          ++i;
        -:  435:        }
        1:  436:      long_sig[i] = DBUS_TYPE_INVALID;
        -:  437:      
        1:  438:      v_STRING = long_sig;
        1:  439:      if (!_dbus_header_set_field_basic (&message->header,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  440:                                         DBUS_HEADER_FIELD_SIGNATURE,
        -:  441:                                         DBUS_TYPE_SIGNATURE,
        -:  442:                                         &v_STRING))
    #####:  443:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  444:      
        1:  445:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  446:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  447:                                  NULL, &pos);
        1:  448:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  449:      
        1:  450:      *expected_validity = DBUS_INVALID_EXCEEDED_MAXIMUM_STRUCT_RECURSION;
        -:  451:    }
       18:  452:  else if (item_seq == 3)
branch  0 taken 6% (fallthrough)
branch  1 taken 94%
        -:  453:    {
        1:  454:      message = simple_method_call ();
call    0 returned 100%
        1:  455:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  456:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  457:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  458:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  459:                                     DBUS_TYPE_INVALID))
    #####:  460:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  461:                                     
        1:  462:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  463:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  464:                                  NULL, &pos);
        1:  465:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  466:      
        1:  467:      _dbus_string_set_byte (data, pos + 1, DBUS_STRUCT_BEGIN_CHAR);
call    0 returned 100%
        -:  468:      
        1:  469:      *expected_validity = DBUS_INVALID_STRUCT_STARTED_BUT_NOT_ENDED;
        -:  470:    }
       17:  471:  else if (item_seq == 4)
branch  0 taken 6% (fallthrough)
branch  1 taken 94%
        -:  472:    {
        1:  473:      message = simple_method_call ();
call    0 returned 100%
        1:  474:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  475:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  476:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  477:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  478:                                     DBUS_TYPE_INVALID))
    #####:  479:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  480:                                     
        1:  481:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  482:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  483:                                  NULL, &pos);
        1:  484:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  485:      
        1:  486:      _dbus_string_set_byte (data, pos + 1, DBUS_STRUCT_END_CHAR);
call    0 returned 100%
        -:  487:      
        1:  488:      *expected_validity = DBUS_INVALID_STRUCT_ENDED_BUT_NOT_STARTED;
        -:  489:    }
       16:  490:  else if (item_seq == 5)
branch  0 taken 6% (fallthrough)
branch  1 taken 94%
        -:  491:    {
        1:  492:      message = simple_method_call ();
call    0 returned 100%
        1:  493:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  494:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  495:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  496:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  497:                                     DBUS_TYPE_INVALID))
    #####:  498:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  499:                                     
        1:  500:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  501:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  502:                                  NULL, &pos);
        1:  503:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  504:      
        1:  505:      _dbus_string_set_byte (data, pos + 1, DBUS_STRUCT_BEGIN_CHAR);
call    0 returned 100%
        1:  506:      _dbus_string_set_byte (data, pos + 2, DBUS_STRUCT_END_CHAR);
call    0 returned 100%
        -:  507:      
        1:  508:      *expected_validity = DBUS_INVALID_STRUCT_HAS_NO_FIELDS;
        -:  509:    }
       15:  510:  else if (item_seq == 6)
branch  0 taken 7% (fallthrough)
branch  1 taken 93%
        -:  511:    {
        1:  512:      message = simple_method_call ();
call    0 returned 100%
        1:  513:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  514:      
        1:  515:      _dbus_string_set_byte (data, TYPE_OFFSET, DBUS_MESSAGE_TYPE_INVALID);
call    0 returned 100%
        -:  516:      
        1:  517:      *expected_validity = DBUS_INVALID_BAD_MESSAGE_TYPE;
        -:  518:    }
       14:  519:  else if (item_seq == 7)
branch  0 taken 7% (fallthrough)
branch  1 taken 93%
        -:  520:    {
        -:  521:      /* Messages of unknown type are considered valid */
        1:  522:      message = simple_method_call ();
call    0 returned 100%
        1:  523:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  524:      
        1:  525:      _dbus_string_set_byte (data, TYPE_OFFSET, 100);
call    0 returned 100%
        -:  526:      
        1:  527:      *expected_validity = DBUS_VALID;
        -:  528:    }
       13:  529:  else if (item_seq == 8)
branch  0 taken 8% (fallthrough)
branch  1 taken 92%
        -:  530:    {
        1:  531:      message = simple_method_call ();
call    0 returned 100%
        1:  532:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  533:      
        1:  534:      _dbus_marshal_set_uint32 (data, BODY_LENGTH_OFFSET,
call    0 returned 100%
        -:  535:                                DBUS_MAXIMUM_MESSAGE_LENGTH / 2 + 4,
        -:  536:                                message->byte_order);
        1:  537:      _dbus_marshal_set_uint32 (data, FIELDS_ARRAY_LENGTH_OFFSET,
call    0 returned 100%
        -:  538:                                DBUS_MAXIMUM_MESSAGE_LENGTH / 2 + 4,
        -:  539:                                message->byte_order);
        1:  540:      *expected_validity = DBUS_INVALID_MESSAGE_TOO_LONG;
        -:  541:    }
       12:  542:  else if (item_seq == 9)
branch  0 taken 8% (fallthrough)
branch  1 taken 92%
        -:  543:    {
        1:  544:      const char *v_STRING = "not a valid bus name";
        1:  545:      message = simple_method_call ();
call    0 returned 100%
        -:  546:
        1:  547:      if (!_dbus_header_set_field_basic (&message->header,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  548:                                         DBUS_HEADER_FIELD_SENDER,
        -:  549:                                         DBUS_TYPE_STRING, &v_STRING))
    #####:  550:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  551:      
        1:  552:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  553:
        1:  554:      *expected_validity = DBUS_INVALID_BAD_SENDER;
        -:  555:    }
       11:  556:  else if (item_seq == 10)
branch  0 taken 9% (fallthrough)
branch  1 taken 91%
        -:  557:    {
        1:  558:      message = simple_method_call ();
call    0 returned 100%
        -:  559:
        1:  560:      if (!dbus_message_set_interface (message, DBUS_INTERFACE_LOCAL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  561:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  562:      
        1:  563:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  564:
        1:  565:      *expected_validity = DBUS_INVALID_USES_LOCAL_INTERFACE;
        -:  566:    }
       10:  567:  else if (item_seq == 11)
branch  0 taken 10% (fallthrough)
branch  1 taken 90%
        -:  568:    {
        1:  569:      message = simple_method_call ();
call    0 returned 100%
        -:  570:
        1:  571:      if (!dbus_message_set_path (message, DBUS_PATH_LOCAL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  572:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  573:      
        1:  574:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  575:
        1:  576:      *expected_validity = DBUS_INVALID_USES_LOCAL_PATH;
        -:  577:    }
        9:  578:  else if (item_seq == 12)
branch  0 taken 11% (fallthrough)
branch  1 taken 89%
        -:  579:    {
        -:  580:      /* Method calls don't have to have interface */
        1:  581:      message = simple_method_call ();
call    0 returned 100%
        -:  582:
        1:  583:      if (!dbus_message_set_interface (message, NULL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  584:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  585:      
        1:  586:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  587:      
        1:  588:      *expected_validity = DBUS_VALID;
        -:  589:    }
        8:  590:  else if (item_seq == 13)
branch  0 taken 13% (fallthrough)
branch  1 taken 88%
        -:  591:    {
        -:  592:      /* Signals require an interface */
        1:  593:      message = simple_signal ();
call    0 returned 100%
        -:  594:
        1:  595:      if (!dbus_message_set_interface (message, NULL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  596:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  597:      
        1:  598:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  599:      
        1:  600:      *expected_validity = DBUS_INVALID_MISSING_INTERFACE;
        -:  601:    }
        7:  602:  else if (item_seq == 14)
branch  0 taken 14% (fallthrough)
branch  1 taken 86%
        -:  603:    {
        1:  604:      message = simple_method_return ();
call    0 returned 100%
        -:  605:
        1:  606:      if (!_dbus_header_delete_field (&message->header, DBUS_HEADER_FIELD_REPLY_SERIAL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  607:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  608:      
        1:  609:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  610:      
        1:  611:      *expected_validity = DBUS_INVALID_MISSING_REPLY_SERIAL;
        -:  612:    }
        6:  613:  else if (item_seq == 15)
branch  0 taken 17% (fallthrough)
branch  1 taken 83%
        -:  614:    {
        1:  615:      message = simple_error ();
call    0 returned 100%
        -:  616:
        1:  617:      if (!dbus_message_set_error_name (message, NULL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  618:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  619:      
        1:  620:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  621:      
        1:  622:      *expected_validity = DBUS_INVALID_MISSING_ERROR_NAME;
        -:  623:    }
        5:  624:  else if (item_seq == 16)
branch  0 taken 20% (fallthrough)
branch  1 taken 80%
        -:  625:    {
        -:  626:      char long_sig[DBUS_MAXIMUM_TYPE_RECURSION_DEPTH*4+8];
        -:  627:      const char *v_STRING;
        -:  628:      int i;
        -:  629:      int n_begins;
        -:  630:      
        1:  631:      message = simple_method_call ();
call    0 returned 100%
        1:  632:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  633:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  634:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  635:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  636:                                     DBUS_TYPE_INVALID))
    #####:  637:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  638:
        1:  639:      i = 0;
       36:  640:      while (i <= (DBUS_MAXIMUM_TYPE_RECURSION_DEPTH*3 + 3))
branch  0 taken 97%
branch  1 taken 3% (fallthrough)
        -:  641:        {
       34:  642:          long_sig[i] = DBUS_TYPE_ARRAY;
       34:  643:          ++i;
       34:  644:          long_sig[i] = DBUS_DICT_ENTRY_BEGIN_CHAR;
       34:  645:          ++i;
       34:  646:          long_sig[i] = DBUS_TYPE_INT32;
       34:  647:          ++i;
        -:  648:        }
        1:  649:      n_begins = i / 3;
        -:  650:
        1:  651:      long_sig[i] = DBUS_TYPE_INT32;
        1:  652:      ++i;
        -:  653:      
       36:  654:      while (n_begins > 0)
branch  0 taken 97%
branch  1 taken 3% (fallthrough)
        -:  655:        {
       34:  656:          long_sig[i] = DBUS_DICT_ENTRY_END_CHAR;
       34:  657:          ++i;
       34:  658:          n_begins -= 1;
        -:  659:        }
        1:  660:      long_sig[i] = DBUS_TYPE_INVALID;
        -:  661:      
        1:  662:      v_STRING = long_sig;
        1:  663:      if (!_dbus_header_set_field_basic (&message->header,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  664:                                         DBUS_HEADER_FIELD_SIGNATURE,
        -:  665:                                         DBUS_TYPE_SIGNATURE,
        -:  666:                                         &v_STRING))
    #####:  667:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  668:      
        1:  669:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  670:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  671:                                  NULL, &pos);
        1:  672:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  673:      
        1:  674:      *expected_validity = DBUS_INVALID_EXCEEDED_MAXIMUM_DICT_ENTRY_RECURSION;
        -:  675:    }
        4:  676:  else if (item_seq == 17)
branch  0 taken 25% (fallthrough)
branch  1 taken 75%
        -:  677:    {
        1:  678:      message = simple_method_call ();
call    0 returned 100%
        1:  679:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  680:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  681:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  682:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  683:                                     DBUS_TYPE_INVALID))
    #####:  684:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  685:                                     
        1:  686:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  687:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  688:                                  NULL, &pos);
        1:  689:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  690:
        1:  691:      _dbus_string_set_byte (data, pos + 1, DBUS_TYPE_ARRAY);
call    0 returned 100%
        1:  692:      _dbus_string_set_byte (data, pos + 2, DBUS_DICT_ENTRY_BEGIN_CHAR);
call    0 returned 100%
        -:  693:      
        1:  694:      *expected_validity = DBUS_INVALID_DICT_ENTRY_STARTED_BUT_NOT_ENDED;
        -:  695:    }
        3:  696:  else if (item_seq == 18)
branch  0 taken 33% (fallthrough)
branch  1 taken 67%
        -:  697:    {
        1:  698:      message = simple_method_call ();
call    0 returned 100%
        1:  699:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  700:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  701:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  702:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  703:                                     DBUS_TYPE_INVALID))
    #####:  704:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  705:                                     
        1:  706:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  707:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  708:                                  NULL, &pos);
        1:  709:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  710:      
        1:  711:      _dbus_string_set_byte (data, pos + 1, DBUS_DICT_ENTRY_END_CHAR);
call    0 returned 100%
        -:  712:      
        1:  713:      *expected_validity = DBUS_INVALID_DICT_ENTRY_ENDED_BUT_NOT_STARTED;
        -:  714:    }
        2:  715:  else if (item_seq == 19)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        -:  716:    {
        1:  717:      message = simple_method_call ();
call    0 returned 100%
        1:  718:      if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  719:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  720:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  721:                                     DBUS_TYPE_INT32, &v_INT32,
        -:  722:                                     DBUS_TYPE_INVALID))
    #####:  723:        _dbus_assert_not_reached ("oom");
call    0 never executed
        -:  724:                                     
        1:  725:      _dbus_header_get_field_raw (&message->header,
call    0 returned 100%
        -:  726:                                  DBUS_HEADER_FIELD_SIGNATURE,
        -:  727:                                  NULL, &pos);
        1:  728:      generate_from_message (data, expected_validity, message);
call    0 returned 100%
        -:  729:
        1:  730:      _dbus_string_set_byte (data, pos + 1, DBUS_TYPE_ARRAY);
call    0 returned 100%
        1:  731:      _dbus_string_set_byte (data, pos + 2, DBUS_DICT_ENTRY_BEGIN_CHAR);
call    0 returned 100%
        1:  732:      _dbus_string_set_byte (data, pos + 3, DBUS_DICT_ENTRY_END_CHAR);
call    0 returned 100%
        -:  733:      
        1:  734:      *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS;
        -:  735:    }
        -:  736:  else
        -:  737:    {
        1:  738:      return FALSE;
        -:  739:    }
        -:  740:
       20:  741:  if (message)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
       20:  742:    dbus_message_unref (message);
call    0 returned 100%
        -:  743:
       20:  744:  iter_next (iter);
call    0 returned 100%
       20:  745:  return TRUE;
        -:  746:}
        -:  747:
        -:  748:static dbus_bool_t
        -:  749:generate_wrong_length (DBusMessageDataIter *iter,
        -:  750:                       DBusString          *data,
        -:  751:                       DBusValidity        *expected_validity)
function generate_wrong_length called 3001 returned 100% blocks executed 94%
     3001:  752:{
        -:  753:  int lengths[] = { -42, -17, -16, -15, -9, -8, -7, -6, -5, -4, -3, -2, -1,
     3001:  754:                    1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 16, 30 };
        -:  755:  int adjust;
        -:  756:  int len_seq;
        -:  757:
     3026:  758: restart:
     3026:  759:  len_seq = iter_get_sequence (iter);
call    0 returned 100%
     3026:  760:  if (len_seq == _DBUS_N_ELEMENTS (lengths))
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        1:  761:    return FALSE;
        -:  762:
     3025:  763:  _dbus_assert (len_seq < _DBUS_N_ELEMENTS (lengths));
call    0 returned 100%
        -:  764:  
     3025:  765:  iter_recurse (iter);
call    0 returned 100%
     3025:  766:  if (!generate_many_bodies (iter, data, expected_validity))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  767:    {
       25:  768:      iter_set_sequence (iter, 0); /* reset to first body */
call    0 returned 100%
       25:  769:      iter_unrecurse (iter);
call    0 returned 100%
       25:  770:      iter_next (iter);            /* next length adjustment */
call    0 returned 100%
       25:  771:      goto restart;
        -:  772:    }
     3000:  773:  iter_unrecurse (iter);
call    0 returned 100%
        -:  774:
     3000:  775:  adjust = lengths[len_seq];
        -:  776:
     3000:  777:  if (adjust < 0)
branch  0 taken 52% (fallthrough)
branch  1 taken 48%
        -:  778:    {
     1560:  779:      if ((_dbus_string_get_length (data) + adjust) < DBUS_MINIMUM_HEADER_SIZE)
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  780:        _dbus_string_set_length (data, DBUS_MINIMUM_HEADER_SIZE);
call    0 never executed
        -:  781:      else
     1560:  782:        _dbus_string_shorten (data, - adjust);
call    0 returned 100%
     1560:  783:      *expected_validity = DBUS_INVALID_FOR_UNKNOWN_REASON;
        -:  784:    }
        -:  785:  else
        -:  786:    {      
     1440:  787:      if (!_dbus_string_lengthen (data, adjust))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  788:        _dbus_assert_not_reached ("oom");
call    0 never executed
     1440:  789:      *expected_validity = DBUS_INVALID_TOO_MUCH_DATA;
        -:  790:    }
        -:  791:
        -:  792:  /* Fixup lengths */
        -:  793:  {
        -:  794:    int old_body_len;
        -:  795:    int new_body_len;
        -:  796:    int byte_order;
        -:  797:    
     3000:  798:    _dbus_assert (_dbus_string_get_length (data) >= DBUS_MINIMUM_HEADER_SIZE);
call    0 returned 100%
call    1 returned 100%
        -:  799:    
     3000:  800:    byte_order = _dbus_string_get_byte (data, BYTE_ORDER_OFFSET);
call    0 returned 100%
     3000:  801:    old_body_len = _dbus_marshal_read_uint32 (data,
call    0 returned 100%
        -:  802:                                              BODY_LENGTH_OFFSET,
        -:  803:                                              byte_order,
        -:  804:                                              NULL);
     3000:  805:    _dbus_assert (old_body_len < _dbus_string_get_length (data));
call    0 returned 100%
call    1 returned 100%
     3000:  806:    new_body_len = old_body_len + adjust;
     3000:  807:    if (new_body_len < 0)
branch  0 taken 20% (fallthrough)
branch  1 taken 80%
        -:  808:      {
      607:  809:        new_body_len = 0;
        -:  810:        /* we just munged the header, and aren't sure how */
      607:  811:        *expected_validity = DBUS_VALIDITY_UNKNOWN;
        -:  812:      }
        -:  813:
     3000:  814:    _dbus_verbose ("changing body len from %u to %u by adjust %d\n",
call    0 returned 100%
        -:  815:                   old_body_len, new_body_len, adjust);
        -:  816:    
     3000:  817:    _dbus_marshal_set_uint32 (data, BODY_LENGTH_OFFSET,
call    0 returned 100%
        -:  818:                              new_body_len,
        -:  819:                              byte_order);
        -:  820:  }
        -:  821:
     3000:  822:  return TRUE;
        -:  823:}
        -:  824:
        -:  825:static dbus_bool_t
        -:  826:generate_byte_changed (DBusMessageDataIter *iter,
        -:  827:                       DBusString          *data,
        -:  828:                       DBusValidity        *expected_validity)
function generate_byte_changed called 13180 returned 100% blocks executed 100%
    13300:  829:{
        -:  830:  int byte_seq;
        -:  831:  int v_BYTE;
        -:  832:
        -:  833:  /* This is a little convoluted to make the bodies the
        -:  834:   * outer loop and each byte of each body the inner
        -:  835:   * loop
        -:  836:   */
        -:  837:
    13300:  838: restart:
    13300:  839:  if (!generate_many_bodies (iter, data, expected_validity))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        1:  840:    return FALSE;
        -:  841:
    13299:  842:  iter_recurse (iter);
call    0 returned 100%
    13299:  843:  byte_seq = iter_get_sequence (iter);
call    0 returned 100%
    13299:  844:  iter_next (iter);
call    0 returned 100%
    13299:  845:  iter_unrecurse (iter);
call    0 returned 100%
        -:  846:  
    13299:  847:  if (byte_seq == _dbus_string_get_length (data))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  848:    {
      120:  849:      _dbus_string_set_length (data, 0);
call    0 returned 100%
        -:  850:      /* reset byte count */
      120:  851:      iter_recurse (iter);
call    0 returned 100%
      120:  852:      iter_set_sequence (iter, 0);
call    0 returned 100%
      120:  853:      iter_unrecurse (iter);
call    0 returned 100%
      120:  854:      goto restart;
        -:  855:    }
        -:  856:  else
        -:  857:    {
        -:  858:      /* Undo the "next" in generate_many_bodies */
    13179:  859:      iter_set_sequence (iter, iter_get_sequence (iter) - 1);
call    0 returned 100%
call    1 returned 100%
        -:  860:    }
        -:  861:
    13179:  862:  _dbus_assert (byte_seq < _dbus_string_get_length (data));
call    0 returned 100%
call    1 returned 100%
    13179:  863:  v_BYTE = _dbus_string_get_byte (data, byte_seq);
call    0 returned 100%
    13179:  864:  v_BYTE += byte_seq; /* arbitrary but deterministic change to the byte */
    13179:  865:  _dbus_string_set_byte (data, byte_seq, v_BYTE);
call    0 returned 100%
    13179:  866:  *expected_validity = DBUS_VALIDITY_UNKNOWN;
        -:  867:
    13179:  868:  return TRUE;
        -:  869:}
        -:  870:
        -:  871:static dbus_bool_t
        -:  872:find_next_typecode (DBusMessageDataIter *iter,
        -:  873:                    DBusString          *data,
        -:  874:                    DBusValidity        *expected_validity)
function find_next_typecode called 0 returned 0% blocks executed 0%
    #####:  875:{
        -:  876:  int body_seq;
        -:  877:  int byte_seq;
        -:  878:  int base_depth;
        -:  879:
    #####:  880:  base_depth = iter->depth;
        -:  881:
    #####:  882: restart:
    #####:  883:  _dbus_assert (iter->depth == (base_depth + 0));
call    0 never executed
    #####:  884:  _dbus_string_set_length (data, 0);
call    0 never executed
        -:  885:
    #####:  886:  body_seq = iter_get_sequence (iter);
call    0 never executed
        -:  887:  
    #####:  888:  if (!generate_many_bodies (iter, data, expected_validity))
call    0 never executed
branch  1 never executed
branch  2 never executed
    #####:  889:    return FALSE;
        -:  890:  /* Undo the "next" in generate_many_bodies */
    #####:  891:  iter_set_sequence (iter, body_seq);
call    0 never executed
        -:  892:  
    #####:  893:  iter_recurse (iter);
call    0 never executed
        -:  894:  while (TRUE)
        -:  895:    {
    #####:  896:      _dbus_assert (iter->depth == (base_depth + 1));
call    0 never executed
        -:  897:      
    #####:  898:      byte_seq = iter_get_sequence (iter);
call    0 never executed
        -:  899:
    #####:  900:      _dbus_assert (byte_seq <= _dbus_string_get_length (data));
call    0 never executed
call    1 never executed
        -:  901:      
    #####:  902:      if (byte_seq == _dbus_string_get_length (data))
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  903:        {
        -:  904:          /* reset byte count */
    #####:  905:          iter_set_sequence (iter, 0);
call    0 never executed
    #####:  906:          iter_unrecurse (iter);
call    0 never executed
    #####:  907:          _dbus_assert (iter->depth == (base_depth + 0));
call    0 never executed
    #####:  908:          iter_next (iter); /* go to the next body */
call    0 never executed
    #####:  909:          goto restart;
        -:  910:        }
        -:  911:
    #####:  912:      _dbus_assert (byte_seq < _dbus_string_get_length (data));
call    0 never executed
call    1 never executed
        -:  913:
    #####:  914:      if (_dbus_type_is_valid (_dbus_string_get_byte (data, byte_seq)))
call    0 never executed
call    1 never executed
branch  2 never executed
branch  3 never executed
    #####:  915:        break;
        -:  916:      else
    #####:  917:        iter_next (iter);
call    0 never executed
    #####:  918:    }
        -:  919:
    #####:  920:  _dbus_assert (byte_seq == iter_get_sequence (iter));
call    0 never executed
call    1 never executed
    #####:  921:  _dbus_assert (byte_seq < _dbus_string_get_length (data));
call    0 never executed
call    1 never executed
        -:  922:
    #####:  923:  iter_unrecurse (iter);
call    0 never executed
        -:  924:
    #####:  925:  _dbus_assert (iter->depth == (base_depth + 0));
call    0 never executed
        -:  926:  
    #####:  927:  return TRUE;
        -:  928:}
        -:  929:
        -:  930:static const int typecodes[] = {
        -:  931:  DBUS_TYPE_INVALID,
        -:  932:  DBUS_TYPE_BYTE,
        -:  933:  DBUS_TYPE_BOOLEAN,
        -:  934:  DBUS_TYPE_INT16,
        -:  935:  DBUS_TYPE_UINT16,
        -:  936:  DBUS_TYPE_INT32,
        -:  937:  DBUS_TYPE_UINT32,
        -:  938:  DBUS_TYPE_INT64,
        -:  939:  DBUS_TYPE_UINT64,
        -:  940:  DBUS_TYPE_DOUBLE,
        -:  941:  DBUS_TYPE_STRING,
        -:  942:  DBUS_TYPE_OBJECT_PATH,
        -:  943:  DBUS_TYPE_SIGNATURE,
        -:  944:  DBUS_TYPE_ARRAY,
        -:  945:  DBUS_TYPE_VARIANT,
        -:  946:  DBUS_STRUCT_BEGIN_CHAR,
        -:  947:  DBUS_STRUCT_END_CHAR,
        -:  948:  DBUS_DICT_ENTRY_BEGIN_CHAR,
        -:  949:  DBUS_DICT_ENTRY_END_CHAR,
        -:  950:  255 /* random invalid typecode */
        -:  951:};
        -:  952:  
        -:  953:static dbus_bool_t
        -:  954:generate_typecode_changed (DBusMessageDataIter *iter,
        -:  955:                           DBusString          *data,
        -:  956:                           DBusValidity        *expected_validity)
function generate_typecode_changed called 0 returned 0% blocks executed 0%
    #####:  957:{
        -:  958:  int byte_seq;
        -:  959:  int typecode_seq;
        -:  960:  int base_depth;
        -:  961:
    #####:  962:  base_depth = iter->depth;
        -:  963:
    #####:  964: restart:
    #####:  965:  _dbus_assert (iter->depth == (base_depth + 0));
call    0 never executed
    #####:  966:  _dbus_string_set_length (data, 0);
call    0 never executed
        -:  967:  
    #####:  968:  if (!find_next_typecode (iter, data, expected_validity))
call    0 never executed
branch  1 never executed
branch  2 never executed
    #####:  969:    return FALSE;
        -:  970:
    #####:  971:  iter_recurse (iter);
call    0 never executed
    #####:  972:  byte_seq = iter_get_sequence (iter);
call    0 never executed
        -:  973:
    #####:  974:  _dbus_assert (byte_seq < _dbus_string_get_length (data));
call    0 never executed
call    1 never executed
        -:  975:  
    #####:  976:  iter_recurse (iter);
call    0 never executed
    #####:  977:  typecode_seq = iter_get_sequence (iter);
call    0 never executed
    #####:  978:  iter_next (iter);
call    0 never executed
        -:  979:
    #####:  980:  _dbus_assert (typecode_seq <= _DBUS_N_ELEMENTS (typecodes));
call    0 never executed
        -:  981:  
    #####:  982:  if (typecode_seq == _DBUS_N_ELEMENTS (typecodes))
branch  0 never executed
branch  1 never executed
        -:  983:    {
    #####:  984:      _dbus_assert (iter->depth == (base_depth + 2));
call    0 never executed
    #####:  985:      iter_set_sequence (iter, 0); /* reset typecode sequence */
call    0 never executed
    #####:  986:      iter_unrecurse (iter);
call    0 never executed
    #####:  987:      _dbus_assert (iter->depth == (base_depth + 1));
call    0 never executed
    #####:  988:      iter_next (iter); /* go to the next byte_seq */
call    0 never executed
    #####:  989:      iter_unrecurse (iter);
call    0 never executed
    #####:  990:      _dbus_assert (iter->depth == (base_depth + 0));
call    0 never executed
    #####:  991:      goto restart;
        -:  992:    }
        -:  993:
    #####:  994:  _dbus_assert (iter->depth == (base_depth + 2));
call    0 never executed
    #####:  995:  iter_unrecurse (iter);
call    0 never executed
    #####:  996:  _dbus_assert (iter->depth == (base_depth + 1));
call    0 never executed
    #####:  997:  iter_unrecurse (iter);
call    0 never executed
    #####:  998:  _dbus_assert (iter->depth == (base_depth + 0));
call    0 never executed
        -:  999:
        -: 1000:#if 0
        -: 1001:  printf ("Changing byte %d in message %d to %c\n",
        -: 1002:          byte_seq, iter_get_sequence (iter), typecodes[typecode_seq]);
        -: 1003:#endif
        -: 1004:  
    #####: 1005:  _dbus_string_set_byte (data, byte_seq, typecodes[typecode_seq]);
call    0 never executed
    #####: 1006:  *expected_validity = DBUS_VALIDITY_UNKNOWN;
    #####: 1007:  return TRUE;
        -: 1008:}
        -: 1009:
        -: 1010:typedef struct
        -: 1011:{
        -: 1012:  ChangeType type;
        -: 1013:  dbus_uint32_t value; /* cast to signed for adjusts */
        -: 1014:} UIntChange;
        -: 1015:
        -: 1016:static const UIntChange uint32_changes[] = {
        -: 1017:  { CHANGE_TYPE_ADJUST, (dbus_uint32_t) -1 },
        -: 1018:  { CHANGE_TYPE_ADJUST, (dbus_uint32_t) -2 },
        -: 1019:  { CHANGE_TYPE_ADJUST, (dbus_uint32_t) -3 },
        -: 1020:  { CHANGE_TYPE_ADJUST, (dbus_uint32_t) 1 },
        -: 1021:  { CHANGE_TYPE_ADJUST, (dbus_uint32_t) 2 },
        -: 1022:  { CHANGE_TYPE_ADJUST, (dbus_uint32_t) 3 },
        -: 1023:  { CHANGE_TYPE_ABSOLUTE, _DBUS_UINT32_MAX },
        -: 1024:  { CHANGE_TYPE_ABSOLUTE, 0 },
        -: 1025:  { CHANGE_TYPE_ABSOLUTE, 1 },
        -: 1026:  { CHANGE_TYPE_ABSOLUTE, _DBUS_UINT32_MAX - 1 },
        -: 1027:  { CHANGE_TYPE_ABSOLUTE, _DBUS_UINT32_MAX - 5 }
        -: 1028:};
        -: 1029:
        -: 1030:static dbus_bool_t
        -: 1031:generate_uint32_changed (DBusMessageDataIter *iter,
        -: 1032:                         DBusString          *data,
        -: 1033:                         DBusValidity        *expected_validity)
function generate_uint32_changed called 35223 returned 100% blocks executed 100%
    35223: 1034:{
        -: 1035:  int body_seq;
        -: 1036:  int byte_seq;
        -: 1037:  int change_seq;
        -: 1038:  dbus_uint32_t v_UINT32;
        -: 1039:  int byte_order;
        -: 1040:  const UIntChange *change;
        -: 1041:  int base_depth;
        -: 1042:
        -: 1043:  /* Outer loop is each body, next loop is each change,
        -: 1044:   * inner loop is each change location
        -: 1045:   */
        -: 1046:
    35223: 1047:  base_depth = iter->depth;
        -: 1048:  
    35343: 1049: next_body:
    35343: 1050:  _dbus_assert (iter->depth == (base_depth + 0));
call    0 returned 100%
    35343: 1051:  _dbus_string_set_length (data, 0);
call    0 returned 100%
    35343: 1052:  body_seq = iter_get_sequence (iter);
call    0 returned 100%
        -: 1053:  
    35343: 1054:  if (!generate_many_bodies (iter, data, expected_validity))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        1: 1055:    return FALSE;
        -: 1056:
    35342: 1057:  _dbus_assert (iter->depth == (base_depth + 0));
call    0 returned 100%
        -: 1058:
    35342: 1059:  iter_set_sequence (iter, body_seq); /* undo the "next" from generate_many_bodies */
call    0 returned 100%
    35342: 1060:  iter_recurse (iter);
call    0 returned 100%
    36662: 1061: next_change:
    36662: 1062:  _dbus_assert (iter->depth == (base_depth + 1));
call    0 returned 100%
    36662: 1063:  change_seq = iter_get_sequence (iter);
call    0 returned 100%
        -: 1064:  
    36662: 1065:  if (change_seq == _DBUS_N_ELEMENTS (uint32_changes))
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1066:    {
        -: 1067:      /* Reset change count */
      120: 1068:      iter_set_sequence (iter, 0);
call    0 returned 100%
      120: 1069:      iter_unrecurse (iter);
call    0 returned 100%
      120: 1070:      iter_next (iter);
call    0 returned 100%
      120: 1071:      goto next_body;
        -: 1072:    }
        -: 1073:
    36542: 1074:  _dbus_assert (iter->depth == (base_depth + 1));
call    0 returned 100%
        -: 1075:  
    36542: 1076:  iter_recurse (iter);
call    0 returned 100%
    36542: 1077:  _dbus_assert (iter->depth == (base_depth + 2));
call    0 returned 100%
    36542: 1078:  byte_seq = iter_get_sequence (iter);
call    0 returned 100%
        -: 1079:  /* skip 4 bytes at a time */
    36542: 1080:  iter_next (iter);
call    0 returned 100%
    36542: 1081:  iter_next (iter);
call    0 returned 100%
    36542: 1082:  iter_next (iter);
call    0 returned 100%
    36542: 1083:  iter_next (iter);
call    0 returned 100%
    36542: 1084:  iter_unrecurse (iter);
call    0 returned 100%
        -: 1085:
    36542: 1086:  _dbus_assert (_DBUS_ALIGN_VALUE (byte_seq, 4) == (unsigned) byte_seq);
call    0 returned 100%
    36542: 1087:  if (byte_seq >= (_dbus_string_get_length (data) - 4))
call    0 returned 100%
branch  1 taken 4% (fallthrough)
branch  2 taken 96%
        -: 1088:    {
        -: 1089:      /* reset byte count */
     1320: 1090:      _dbus_assert (iter->depth == (base_depth + 1));
call    0 returned 100%
     1320: 1091:      iter_recurse (iter);
call    0 returned 100%
     1320: 1092:      _dbus_assert (iter->depth == (base_depth + 2));
call    0 returned 100%
     1320: 1093:      iter_set_sequence (iter, 0);
call    0 returned 100%
     1320: 1094:      iter_unrecurse (iter);
call    0 returned 100%
     1320: 1095:      _dbus_assert (iter->depth == (base_depth + 1));
call    0 returned 100%
     1320: 1096:      iter_next (iter);
call    0 returned 100%
     1320: 1097:      goto next_change;
        -: 1098:    }
        -: 1099:  
    35222: 1100:  _dbus_assert (byte_seq <= (_dbus_string_get_length (data) - 4));
call    0 returned 100%
call    1 returned 100%
        -: 1101:
    35222: 1102:  byte_order = _dbus_string_get_byte (data, BYTE_ORDER_OFFSET);
call    0 returned 100%
        -: 1103:  
    35222: 1104:  v_UINT32 = _dbus_marshal_read_uint32 (data, byte_seq, byte_order, NULL);
call    0 returned 100%
        -: 1105:
    35222: 1106:  change = &uint32_changes[change_seq];
        -: 1107:
    35222: 1108:  if (change->type == CHANGE_TYPE_ADJUST)
branch  0 taken 55% (fallthrough)
branch  1 taken 45%
        -: 1109:    {
    19212: 1110:      v_UINT32 += (int) change->value;
        -: 1111:    }
        -: 1112:  else
        -: 1113:    {
    16010: 1114:      v_UINT32 = change->value;
        -: 1115:    }
        -: 1116:
        -: 1117:#if 0
        -: 1118:  printf ("body %d change %d pos %d ",
        -: 1119:          body_seq, change_seq, byte_seq);
        -: 1120:
        -: 1121:  if (change->type == CHANGE_TYPE_ADJUST)
        -: 1122:    printf ("adjust by %d", (int) change->value);
        -: 1123:  else
        -: 1124:    printf ("set to %u", change->value);
        -: 1125:  
        -: 1126:  printf (" \t%u -> %u\n",
        -: 1127:          _dbus_marshal_read_uint32 (data, byte_seq, byte_order, NULL),
        -: 1128:          v_UINT32);
        -: 1129:#endif
        -: 1130:  
    35222: 1131:  _dbus_marshal_set_uint32 (data, byte_seq, v_UINT32, byte_order);
call    0 returned 100%
    35222: 1132:  *expected_validity = DBUS_VALIDITY_UNKNOWN;
        -: 1133:
    35222: 1134:  _dbus_assert (iter->depth == (base_depth + 1));
call    0 returned 100%
    35222: 1135:  iter_unrecurse (iter);
call    0 returned 100%
    35222: 1136:  _dbus_assert (iter->depth == (base_depth + 0));
call    0 returned 100%
        -: 1137:          
    35222: 1138:  return TRUE;
        -: 1139:}
        -: 1140:
        -: 1141:typedef struct
        -: 1142:{
        -: 1143:  const char *name;
        -: 1144:  DBusMessageGeneratorFunc func;  
        -: 1145:} DBusMessageGenerator;
        -: 1146:
        -: 1147:static const DBusMessageGenerator generators[] = {
        -: 1148:  { "trivial example of each message type", generate_trivial },
        -: 1149:  { "assorted arguments", generate_many_bodies },
        -: 1150:  { "assorted special cases", generate_special },
        -: 1151:  { "each uint32 modified", generate_uint32_changed },
        -: 1152:  { "wrong body lengths", generate_wrong_length },
        -: 1153:  { "each byte modified", generate_byte_changed },
        -: 1154:#if 0
        -: 1155:  /* This is really expensive and doesn't add too much coverage */
        -: 1156:  { "change each typecode", generate_typecode_changed }
        -: 1157:#endif
        -: 1158:};
        -: 1159:
        -: 1160:void
        -: 1161:_dbus_message_data_free (DBusMessageData *data)
function _dbus_message_data_free called 51545 returned 100% blocks executed 100%
    51545: 1162:{
    51545: 1163:  _dbus_string_free (&data->data);
call    0 returned 100%
    51545: 1164:}
        -: 1165:
        -: 1166:void
        -: 1167:_dbus_message_data_iter_init (DBusMessageDataIter *iter)
function _dbus_message_data_iter_init called 1 returned 100% blocks executed 100%
        1: 1168:{
        -: 1169:  int i;
        -: 1170:  
        1: 1171:  iter->depth = 0;
        1: 1172:  i = 0;
       12: 1173:  while (i < _DBUS_MESSAGE_DATA_MAX_NESTING)
branch  0 taken 91%
branch  1 taken 9% (fallthrough)
        -: 1174:    {
       10: 1175:      iter->sequence_nos[i] = 0;
       10: 1176:      ++i;
        -: 1177:    }
        1: 1178:  iter->count = 0;
        1: 1179:}
        -: 1180:
        -: 1181:dbus_bool_t
        -: 1182:_dbus_message_data_iter_get_and_next (DBusMessageDataIter *iter,
        -: 1183:                                      DBusMessageData     *data)
function _dbus_message_data_iter_get_and_next called 51546 returned 100% blocks executed 95%
    51552: 1184:{
        -: 1185:  DBusMessageGeneratorFunc func;
        -: 1186:  int generator;
        -: 1187:
    51552: 1188: restart:
    51552: 1189:  generator = iter_get_sequence (iter);
call    0 returned 100%
        -: 1190:  
    51552: 1191:  if (generator == _DBUS_N_ELEMENTS (generators))
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        1: 1192:    return FALSE;
        -: 1193:
    51551: 1194:  iter_recurse (iter);
call    0 returned 100%
        -: 1195:  
    51551: 1196:  if (iter_first_in_series (iter))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1197:    {
        6: 1198:      printf (" testing message loading: %s ", generators[generator].name);
call    0 returned 100%
        6: 1199:      fflush (stdout);
call    0 returned 100%
        -: 1200:    }
        -: 1201:  
    51551: 1202:  func = generators[generator].func;
        -: 1203:
    51551: 1204:  if (!_dbus_string_init (&data->data))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1205:    _dbus_assert_not_reached ("oom");
call    0 never executed
        -: 1206:  
    51551: 1207:  if ((*func)(iter, &data->data, &data->expected_validity))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1208:    ;
        -: 1209:  else
        -: 1210:    {
        6: 1211:      iter_set_sequence (iter, 0);
call    0 returned 100%
        6: 1212:      iter_unrecurse (iter);
call    0 returned 100%
        6: 1213:      iter_next (iter); /* next generator */
call    0 returned 100%
        6: 1214:      _dbus_string_free (&data->data);
call    0 returned 100%
        6: 1215:      printf ("%d test loads cumulative\n", iter->count);
call    0 returned 100%
        6: 1216:      goto restart;
        -: 1217:    }
    51545: 1218:  iter_unrecurse (iter);
call    0 returned 100%
        -: 1219:
    51545: 1220:  iter->count += 1;
    51545: 1221:  return TRUE;
        -: 1222:}
        -: 1223:
        -: 1224:#endif /* DBUS_BUILD_TESTS */