diff options
Diffstat (limited to 'src/platform/tests')
| -rw-r--r-- | src/platform/tests/monitor.c | 23 | ||||
| -rw-r--r-- | src/platform/tests/test-address.c | 28 | ||||
| -rw-r--r-- | src/platform/tests/test-cleanup.c | 24 | ||||
| -rw-r--r-- | src/platform/tests/test-common.c | 30 | ||||
| -rw-r--r-- | src/platform/tests/test-link.c | 36 | ||||
| -rw-r--r-- | src/platform/tests/test-nmp-object.c | 4 | ||||
| -rw-r--r-- | src/platform/tests/test-route.c | 25 |
7 files changed, 150 insertions, 20 deletions
diff --git a/src/platform/tests/monitor.c b/src/platform/tests/monitor.c index 5cc3114c..3af34be4 100644 --- a/src/platform/tests/monitor.c +++ b/src/platform/tests/monitor.c @@ -1,9 +1,28 @@ -#include "config.h" +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager audit support + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2015 Red Hat, Inc. + */ + +#include "nm-default.h" #include <stdlib.h> #include <syslog.h> -#include "nm-default.h" #include "nm-linux-platform.h" #include "nm-test-utils.h" diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c index 566bb479..3b52a7be 100644 --- a/src/platform/tests/test-address.c +++ b/src/platform/tests/test-address.c @@ -1,4 +1,24 @@ -#include "config.h" +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager audit support + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2015 Red Hat, Inc. + */ + +#include "nm-default.h" #include "test-common.h" @@ -255,7 +275,8 @@ test_ip4_address_peer (void) /* Add/delete notification */ nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr_peer, lifetime, preferred, NULL); accept_signal (address_added); - g_assert ((a = nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer))); + a = nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer); + g_assert (a); g_assert (!nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer2)); nmtstp_ip_address_assert_lifetime ((NMPlatformIPAddress *) a, -1, lifetime, preferred); @@ -263,7 +284,8 @@ test_ip4_address_peer (void) nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr_peer2, lifetime, preferred, NULL); accept_signal (address_added); g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer)); - g_assert ((a = nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer2))); + a = nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer2); + g_assert (a); nmtstp_ip_address_assert_lifetime ((NMPlatformIPAddress *) a, -1, lifetime, preferred); diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c index 9e624a02..6ad24478 100644 --- a/src/platform/tests/test-cleanup.c +++ b/src/platform/tests/test-cleanup.c @@ -1,4 +1,24 @@ -#include "config.h" +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager audit support + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2016 Red Hat, Inc. + */ + +#include "nm-default.h" #include "test-common.h" @@ -25,7 +45,7 @@ test_cleanup_internal (void) int preferred = NM_PLATFORM_LIFETIME_PERMANENT; int metric = 20; int mss = 1000; - guint flags = 0; + guint32 flags = 0; inet_pton (AF_INET, "192.0.2.1", &addr4); inet_pton (AF_INET, "192.0.3.0", &network4); diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 09a57f87..268a5c92 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -1,4 +1,24 @@ -#include "config.h" +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager audit support + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2016 Red Hat, Inc. + */ + +#include "nm-default.h" #include <sys/mount.h> #include <sched.h> @@ -39,7 +59,7 @@ add_signal_full (const char *name, NMPlatformSignalChangeType change_type, GCall data->ifindex = ifindex; data->ifname = ifname; - g_assert (data->handler_id >= 0); + g_assert (data->handler_id > 0); return data; } @@ -544,7 +564,7 @@ _ip_address_add (gboolean external_command, guint32 lifetime, guint32 preferred, const char *label, - guint flags) + guint32 flags) { gint64 end_time; @@ -1008,7 +1028,7 @@ nmtstp_ip6_address_add (gboolean external_command, struct in6_addr peer_address, guint32 lifetime, guint32 preferred, - guint flags) + guint32 flags) { _ip_address_add (external_command, FALSE, @@ -1262,7 +1282,7 @@ nmtstp_link_set_updown (gboolean external_command, plink = nm_platform_link_get (NM_PLATFORM_GET, ifindex); g_assert (plink); - if (NM_FLAGS_HAS (plink->flags, IFF_UP) == !!up) + if (NM_FLAGS_HAS (plink->n_ifi_flags, IFF_UP) == !!up) break; /* for internal command, we expect not to reach this line.*/ diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index 8b496262..3fa5ad50 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -1,4 +1,24 @@ -#include "config.h" +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager audit support + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2016 Red Hat, Inc. + */ + +#include "nm-default.h" #include <sched.h> @@ -290,9 +310,17 @@ test_slave (int master, int type, SignalData *master_changed) ensure_no_signal (link_removed); g_assert (nm_platform_link_release (NM_PLATFORM_GET, master, ifindex)); g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, 0); - accept_signals (link_added, 0, 1); - accept_signals (link_changed, 1, 3); - accept_signals (link_removed, 0, 1); + if (link_changed->received_count > 0) { + accept_signals (link_added, 0, 1); + accept_signals (link_changed, 1, 3); + accept_signals (link_removed, 0, 1); + } else { + /* Due to https://bugzilla.redhat.com/show_bug.cgi?id=1285719 , kernel might send a + * wrong RTM_DELLINK message so that we instead see an removed+added signal. */ + accept_signal (link_added); + ensure_no_signal (link_changed); + accept_signal (link_removed); + } accept_signals (master_changed, 1, 2); ensure_no_signal (master_changed); diff --git a/src/platform/tests/test-nmp-object.c b/src/platform/tests/test-nmp-object.c index eba2383b..3b44abb8 100644 --- a/src/platform/tests/test-nmp-object.c +++ b/src/platform/tests/test-nmp-object.c @@ -18,10 +18,10 @@ * Copyright (C) 2015 Red Hat, Inc. */ -#include "nmp-object.h" - #include "nm-default.h" +#include "nmp-object.h" + #include "nm-test-utils.h" struct { diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c index 60a0c15c..f5fa024b 100644 --- a/src/platform/tests/test-route.c +++ b/src/platform/tests/test-route.c @@ -1,10 +1,31 @@ -#include "config.h" +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager audit support + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2016 Red Hat, Inc. + */ + +#include "nm-default.h" #include <linux/rtnetlink.h> +#include "nm-core-utils.h" #include "test-common.h" + #include "nm-test-utils.h" -#include "NetworkManagerUtils.h" #define DEVICE_NAME "nm-test-device" |