GCC Code Coverage Report


Directory: ./
File: libgsystemservice/tests/peer-manager.c
Date: 2024-04-09 14:29:48
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 4 4 100.0%
Branches: 4 8 50.0%

Line Branch Exec Source
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 *
3 * Copyright © 2018 Endless Mobile, Inc.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 * Authors:
22 * - Philip Withnall <withnall@endlessm.com>
23 */
24
25 #include <gio/gio.h>
26 #include <glib.h>
27 #include <libgsystemservice/peer-manager.h>
28 #include <libgsystemservice/peer-manager-dbus.h>
29 #include <locale.h>
30
31
32 typedef struct
33 {
34 GTestDBus *bus; /* (owned) */
35 } Fixture;
36
37 static void
38 2 setup (Fixture *fixture,
39 gconstpointer user_data)
40 {
41 2 fixture->bus = g_test_dbus_new (G_TEST_DBUS_NONE);
42 2 g_test_dbus_up (fixture->bus);
43 1 }
44
45 static void
46 1 teardown (Fixture *fixture,
47 gconstpointer user_data)
48 {
49
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (fixture->bus != NULL)
50 1 g_test_dbus_down (fixture->bus);
51
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 g_clear_object (&fixture->bus);
52 1 }
53
54 /* Test that the groups from all loaded files are returned. */
55 static void
56 1 test_construction (Fixture *fixture,
57 gconstpointer user_data)
58 {
59 1 g_autoptr(GError) local_error = NULL;
60
61 1 g_autoptr(GDBusConnection) connection = NULL;
62 1 connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &local_error);
63
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 g_assert_no_error (local_error);
64
65 1 g_autoptr(GssPeerManager) manager = NULL;
66 1 manager = GSS_PEER_MANAGER (gss_peer_manager_dbus_new (connection));
67
68
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 g_assert_null (gss_peer_manager_get_peer_credentials (manager, ":999.999"));
69 1 }
70
71 int
72 2 main (int argc,
73 char *argv[])
74 {
75 2 setlocale (LC_ALL, "");
76
77 2 g_test_init (&argc, &argv, NULL);
78
79 2 g_test_add ("/peer-manager/construction", Fixture, NULL, setup,
80 test_construction, teardown);
81
82 2 return g_test_run ();
83 }
84