1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2013 Tom Gundersen <teg@jklm.no>
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 static void test_link(struct udev_device *loopback) {
25 _cleanup_manager_free_ Manager *manager = NULL;
28 manager_new(&manager);
30 assert(link_new(manager, loopback, &link) >= 0);
34 static void test_load_config(Manager *manager) {
35 /* TODO: should_reload, is false if the config dirs do not exist, so
36 * so we can't do this test here, move it to a test for paths_check_timestamps
39 * assert(network_should_reload(manager) == true);
41 assert(manager_load_config(manager) >= 0);
42 assert(manager_should_reload(manager) == false);
45 static void test_network_get(Manager *manager, struct udev_device *loopback) {
48 /* let's assume that the test machine does not have a .network file
49 that applies to the loopback device... */
50 assert(network_get(manager, loopback, &network) == -ENOENT);
55 _cleanup_manager_free_ Manager *manager = NULL;
57 struct udev_device *loopback;
59 assert(manager_new(&manager) >= 0);
61 test_load_config(manager);
66 loopback = udev_device_new_from_syspath(udev, "/sys/class/net/lo");
68 assert(udev_device_get_ifindex(loopback) == 1);
70 test_network_get(manager, loopback);
74 assert(manager_udev_listen(manager) >= 0);
75 assert(manager_udev_enumerate_links(manager) >= 0);
76 assert(manager_rtnl_listen(manager) >= 0);
78 udev_device_unref(loopback);