Coverage report for dbus/dbus-auth-util.c.gcov
-: 0:Source:dbus-auth-util.c
-: 0:Graph:.libs/dbus-auth-util.gcno
-: 0:Data:.libs/dbus-auth-util.gcda
-: 0:Runs:768
-: 0:Programs:1
-: 1:/* -*- mode: C; c-file-style: "gnu" -*- */
-: 2:/* dbus-auth-util.c Would be in dbus-auth.c, but only used for tests/bus
-: 3: *
-: 4: * Copyright (C) 2002, 2003, 2004 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 "dbus-internals.h"
-: 24:#include "dbus-test.h"
-: 25:#include "dbus-auth.h"
-: 26:
-: 27:/**
-: 28: * @addtogroup DBusAuth
-: 29: * @{
-: 30: */
-: 31:
-: 32:/** @} */
-: 33:
-: 34:#ifdef DBUS_BUILD_TESTS
-: 35:#include "dbus-test.h"
-: 36:#include "dbus-auth-script.h"
-: 37:#include <stdio.h>
-: 38:
-: 39:static dbus_bool_t
-: 40:process_test_subdir (const DBusString *test_base_dir,
-: 41: const char *subdir)
function process_test_subdir called 1 returned 100% blocks executed 71%
1: 42:{
-: 43: DBusString test_directory;
-: 44: DBusString filename;
-: 45: DBusDirIter *dir;
-: 46: dbus_bool_t retval;
-: 47: DBusError error;
-: 48:
1: 49: retval = FALSE;
1: 50: dir = NULL;
-: 51:
1: 52: if (!_dbus_string_init (&test_directory))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 53: _dbus_assert_not_reached ("didn't allocate test_directory\n");
call 0 never executed
-: 54:
1: 55: _dbus_string_init_const (&filename, subdir);
call 0 returned 100%
-: 56:
1: 57: if (!_dbus_string_copy (test_base_dir, 0,
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 58: &test_directory, 0))
#####: 59: _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
call 0 never executed
-: 60:
1: 61: if (!_dbus_concat_dir_and_file (&test_directory, &filename))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 62: _dbus_assert_not_reached ("couldn't allocate full path");
call 0 never executed
-: 63:
1: 64: _dbus_string_free (&filename);
call 0 returned 100%
1: 65: if (!_dbus_string_init (&filename))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 66: _dbus_assert_not_reached ("didn't allocate filename string\n");
call 0 never executed
-: 67:
1: 68: dbus_error_init (&error);
call 0 returned 100%
1: 69: dir = _dbus_directory_open (&test_directory, &error);
call 0 returned 100%
1: 70: if (dir == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 71: {
#####: 72: _dbus_warn ("Could not open %s: %s\n",
call 0 never executed
call 1 never executed
-: 73: _dbus_string_get_const_data (&test_directory),
-: 74: error.message);
#####: 75: dbus_error_free (&error);
call 0 never executed
#####: 76: goto failed;
-: 77: }
-: 78:
1: 79: printf ("Testing %s:\n", subdir);
call 0 returned 100%
-: 80:
2: 81: next:
17: 82: while (_dbus_directory_get_next_file (dir, &filename, &error))
call 0 returned 100%
branch 1 taken 93%
branch 2 taken 7% (fallthrough)
-: 83: {
-: 84: DBusString full_path;
-: 85:
14: 86: if (!_dbus_string_init (&full_path))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 87: _dbus_assert_not_reached ("couldn't init string");
call 0 never executed
-: 88:
14: 89: if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 90: _dbus_assert_not_reached ("couldn't copy dir to full_path");
call 0 never executed
-: 91:
14: 92: if (!_dbus_concat_dir_and_file (&full_path, &filename))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 93: _dbus_assert_not_reached ("couldn't concat file to dir");
call 0 never executed
-: 94:
14: 95: if (!_dbus_string_ends_with_c_str (&filename, ".auth-script"))
call 0 returned 100%
branch 1 taken 7% (fallthrough)
branch 2 taken 93%
-: 96: {
1: 97: _dbus_verbose ("Skipping non-.auth-script file %s\n",
call 0 returned 100%
call 1 returned 100%
-: 98: _dbus_string_get_const_data (&filename));
1: 99: _dbus_string_free (&full_path);
call 0 returned 100%
1: 100: goto next;
-: 101: }
-: 102:
13: 103: printf (" %s\n", _dbus_string_get_const_data (&filename));
call 0 returned 100%
call 1 returned 100%
-: 104:
13: 105: if (!_dbus_auth_script_run (&full_path))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 106: {
#####: 107: _dbus_string_free (&full_path);
call 0 never executed
#####: 108: goto failed;
-: 109: }
-: 110: else
13: 111: _dbus_string_free (&full_path);
call 0 returned 100%
-: 112: }
-: 113:
1: 114: if (dbus_error_is_set (&error))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 115: {
#####: 116: _dbus_warn ("Could not get next file in %s: %s\n",
call 0 never executed
call 1 never executed
-: 117: _dbus_string_get_const_data (&test_directory), error.message);
#####: 118: dbus_error_free (&error);
call 0 never executed
#####: 119: goto failed;
-: 120: }
-: 121:
1: 122: retval = TRUE;
-: 123:
1: 124: failed:
-: 125:
1: 126: if (dir)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
1: 127: _dbus_directory_close (dir);
call 0 returned 100%
1: 128: _dbus_string_free (&test_directory);
call 0 returned 100%
1: 129: _dbus_string_free (&filename);
call 0 returned 100%
-: 130:
1: 131: return retval;
-: 132:}
-: 133:
-: 134:static dbus_bool_t
-: 135:process_test_dirs (const char *test_data_dir)
function process_test_dirs called 1 returned 100% blocks executed 86%
1: 136:{
-: 137: DBusString test_directory;
-: 138: dbus_bool_t retval;
-: 139:
1: 140: retval = FALSE;
-: 141:
1: 142: _dbus_string_init_const (&test_directory, test_data_dir);
call 0 returned 100%
-: 143:
1: 144: if (!process_test_subdir (&test_directory, "auth"))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 145: goto failed;
-: 146:
1: 147: retval = TRUE;
-: 148:
1: 149: failed:
-: 150:
1: 151: _dbus_string_free (&test_directory);
call 0 returned 100%
-: 152:
1: 153: return retval;
-: 154:}
-: 155:
-: 156:dbus_bool_t
-: 157:_dbus_auth_test (const char *test_data_dir)
function _dbus_auth_test called 1 returned 100% blocks executed 71%
1: 158:{
-: 159:
1: 160: if (test_data_dir == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 161: return TRUE;
-: 162:
1: 163: if (!process_test_dirs (test_data_dir))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 164: return FALSE;
-: 165:
1: 166: return TRUE;
-: 167:}
-: 168:
-: 169:#endif /* DBUS_BUILD_TESTS */