From 964ae8cc391520440cf5aa13e2b9cc34850ea6c2 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 26 Feb 2019 19:01:41 +0100 Subject: New upstream version 1.14.6 --- src/devices/tests/test-lldp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/devices/tests') diff --git a/src/devices/tests/test-lldp.c b/src/devices/tests/test-lldp.c index c2ac8e19..7227d082 100644 --- a/src/devices/tests/test-lldp.c +++ b/src/devices/tests/test-lldp.c @@ -219,11 +219,10 @@ TEST_RECV_FRAME_DEFINE (_test_recv_data1_frame0, 0x01, 0xe8, 0xfe, 0x07, 0x00, 0x80, 0xc2, 0x02, /* IEEE 802.1 - Port and Protocol VLAN ID */ 0x01, 0x00, 0x00, - 0xfe, 0x17, 0x00, 0x80, 0xc2, 0x03, /* IEEE 802.1 - VLAN Name */ - 0x01, 0xe8, 0x10, 0x76, 0x32, 0x2d, + 0xfe, 0x16, 0x00, 0x80, 0xc2, 0x03, /* IEEE 802.1 - VLAN Name */ + 0x01, 0xe8, 0x0f, 0x76, 0x32, 0x2d, 0x30, 0x34, 0x38, 0x38, 0x2d, 0x30, 0x33, 0x2d, 0x30, 0x35, 0x30, 0x35, - 0x00, 0xfe, 0x05, 0x00, 0x80, 0xc2, 0x04, /* IEEE 802.1 - Protocol Identity */ 0x00, 0x00, 0x00 /* End of LLDPDU */ -- cgit 1.3.0-6-gf8a5 From 9a6dcbf895f9da01768e64b73cec88c16157d91e Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 26 Mar 2019 23:25:23 +0100 Subject: New upstream version 1.16.0 --- src/devices/tests/meson.build | 7 ++-- src/devices/tests/test-acd.c | 88 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 79 insertions(+), 16 deletions(-) (limited to 'src/devices/tests') diff --git a/src/devices/tests/meson.build b/src/devices/tests/meson.build index 02c61ced..4702c656 100644 --- a/src/devices/tests/meson.build +++ b/src/devices/tests/meson.build @@ -1,18 +1,19 @@ test_units = [ 'test-acd', - 'test-lldp' + 'test-lldp', ] foreach test_unit: test_units exe = executable( test_unit, test_unit + '.c', - dependencies: test_nm_dep + dependencies: test_nm_dep, ) test( 'devices/' + test_unit, test_script, - args: test_args + [exe.full_path()] + args: test_args + [exe.full_path()], + timeout: default_test_timeout, ) endforeach diff --git a/src/devices/tests/test-acd.c b/src/devices/tests/test-acd.c index 8a2852a2..aff71825 100644 --- a/src/devices/tests/test-acd.c +++ b/src/devices/tests/test-acd.c @@ -20,6 +20,8 @@ #include "nm-default.h" +#include "n-acd/src/n-acd.h" + #include "devices/nm-acd-manager.h" #include "platform/tests/test-common.h" @@ -31,6 +33,46 @@ #define ADDR3 0x03030303 #define ADDR4 0x04040404 +/*****************************************************************************/ + +static gboolean +_skip_acd_test_check (void) +{ + NAcd *acd; + NAcdConfig *config; + const guint8 hwaddr[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; + int r; + static int skip = -1; + + if (skip == -1) { + r = n_acd_config_new (&config); + g_assert (r == 0); + + n_acd_config_set_ifindex (config, 1); + n_acd_config_set_transport (config, N_ACD_TRANSPORT_ETHERNET); + n_acd_config_set_mac (config, hwaddr, sizeof (hwaddr)); + + r = n_acd_new (&acd, config); + n_acd_config_free (config); + if (r == 0) + n_acd_unref (acd); + + skip = (r != 0); + } + return skip; +} + +#define _skip_acd_test() \ + ({ \ + gboolean _skip = _skip_acd_test_check (); \ + \ + if (_skip) \ + g_test_skip ("Cannot create NAcd. Running under valgind?"); \ + _skip; \ + }) + +/*****************************************************************************/ + typedef struct { int ifindex0; int ifindex1; @@ -61,20 +103,26 @@ typedef struct { } TestInfo; static void -acd_manager_probe_terminated (NMAcdManager *acd_manager, GMainLoop *loop) +acd_manager_probe_terminated (NMAcdManager *acd_manager, gpointer user_data) { - g_main_loop_quit (loop); + g_main_loop_quit (user_data); } static void test_acd_common (test_fixture *fixture, TestInfo *info) { - gs_unref_object NMAcdManager *manager = NULL; + NMAcdManager *manager; GMainLoop *loop; int i; const guint WAIT_TIME_OPTIMISTIC = 50; guint wait_time; - gulong signal_id; + static const NMAcdCallbacks callbacks = { + .probe_terminated_callback = acd_manager_probe_terminated, + .user_data_destroy = (GDestroyNotify) g_main_loop_unref, + }; + + if (_skip_acd_test ()) + return; /* first, try with a short waittime. We hope that this is long enough * to successfully complete the test. Only if that's not the case, we @@ -83,7 +131,13 @@ test_acd_common (test_fixture *fixture, TestInfo *info) wait_time = WAIT_TIME_OPTIMISTIC; again: - manager = nm_acd_manager_new (fixture->ifindex0, fixture->hwaddr0, fixture->hwaddr0_len); + loop = g_main_loop_new (NULL, FALSE); + + manager = nm_acd_manager_new (fixture->ifindex0, + fixture->hwaddr0, + fixture->hwaddr0_len, + &callbacks, + g_main_loop_ref (loop)); g_assert (manager != NULL); for (i = 0; info->addresses[i]; i++) @@ -94,16 +148,13 @@ again: 24, 0, 3600, 1800, 0, NULL); } - loop = g_main_loop_new (NULL, FALSE); - signal_id = g_signal_connect (manager, NM_ACD_MANAGER_PROBE_TERMINATED, - G_CALLBACK (acd_manager_probe_terminated), loop); g_assert (nm_acd_manager_start_probe (manager, wait_time)); g_assert (nmtst_main_loop_run (loop, 2000)); - g_signal_handler_disconnect (manager, signal_id); g_main_loop_unref (loop); for (i = 0; info->addresses[i]; i++) { gboolean val; + char sbuf[NM_UTILS_INET_ADDRSTRLEN]; val = nm_acd_manager_check_address (manager, info->addresses[i]); if (val == info->expected_result[i]) @@ -113,14 +164,16 @@ again: /* probably we just had a glitch and the system took longer than * expected. Re-verify with a large timeout this time. */ wait_time = 1000; - g_clear_object (&manager); + nm_clear_pointer (&manager, nm_acd_manager_free); goto again; } g_error ("expected check for address #%d (%s) to %s, but it didn't", - i, nm_utils_inet4_ntop (info->addresses[i], NULL), + i, nm_utils_inet4_ntop (info->addresses[i], sbuf), info->expected_result[i] ? "detect no duplicated" : "detect a duplicate"); } + + nm_acd_manager_free (manager); } static void @@ -146,10 +199,17 @@ test_acd_probe_2 (test_fixture *fixture, gconstpointer user_data) static void test_acd_announce (test_fixture *fixture, gconstpointer user_data) { - gs_unref_object NMAcdManager *manager = NULL; + NMAcdManager *manager; GMainLoop *loop; - manager = nm_acd_manager_new (fixture->ifindex0, fixture->hwaddr0, fixture->hwaddr0_len); + if (_skip_acd_test ()) + return; + + manager = nm_acd_manager_new (fixture->ifindex0, + fixture->hwaddr0, + fixture->hwaddr0_len, + NULL, + NULL); g_assert (manager != NULL); g_assert (nm_acd_manager_add_address (manager, ADDR1)); @@ -159,6 +219,8 @@ test_acd_announce (test_fixture *fixture, gconstpointer user_data) nm_acd_manager_announce_addresses (manager); g_assert (!nmtst_main_loop_run (loop, 200)); g_main_loop_unref (loop); + + nm_acd_manager_free (manager); } static void -- cgit 1.3.0-6-gf8a5 From 85563b7fc7ec2cd21e38debb9b28db342e2e8e7c Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Sun, 21 Apr 2019 21:09:51 +0200 Subject: New upstream version 1.18.0 --- src/devices/tests/test-acd.c | 26 +++++++-------- src/devices/tests/test-lldp.c | 76 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 83 insertions(+), 19 deletions(-) (limited to 'src/devices/tests') diff --git a/src/devices/tests/test-acd.c b/src/devices/tests/test-acd.c index aff71825..8b52ee2c 100644 --- a/src/devices/tests/test-acd.c +++ b/src/devices/tests/test-acd.c @@ -111,8 +111,8 @@ acd_manager_probe_terminated (NMAcdManager *acd_manager, gpointer user_data) static void test_acd_common (test_fixture *fixture, TestInfo *info) { - NMAcdManager *manager; - GMainLoop *loop; + nm_auto_free_acdmgr NMAcdManager *manager = NULL; + nm_auto_unref_gmainloop GMainLoop *loop = NULL; int i; const guint WAIT_TIME_OPTIMISTIC = 50; guint wait_time; @@ -120,6 +120,7 @@ test_acd_common (test_fixture *fixture, TestInfo *info) .probe_terminated_callback = acd_manager_probe_terminated, .user_data_destroy = (GDestroyNotify) g_main_loop_unref, }; + int r; if (_skip_acd_test ()) return; @@ -131,8 +132,10 @@ test_acd_common (test_fixture *fixture, TestInfo *info) wait_time = WAIT_TIME_OPTIMISTIC; again: + nm_clear_pointer (&loop, g_main_loop_unref); loop = g_main_loop_new (NULL, FALSE); + nm_clear_pointer (&manager, nm_acd_manager_free); manager = nm_acd_manager_new (fixture->ifindex0, fixture->hwaddr0, fixture->hwaddr0_len, @@ -148,9 +151,10 @@ again: 24, 0, 3600, 1800, 0, NULL); } - g_assert (nm_acd_manager_start_probe (manager, wait_time)); + r = nm_acd_manager_start_probe (manager, wait_time); + g_assert_cmpint (r, ==, 0); + g_assert (nmtst_main_loop_run (loop, 2000)); - g_main_loop_unref (loop); for (i = 0; info->addresses[i]; i++) { gboolean val; @@ -164,7 +168,6 @@ again: /* probably we just had a glitch and the system took longer than * expected. Re-verify with a large timeout this time. */ wait_time = 1000; - nm_clear_pointer (&manager, nm_acd_manager_free); goto again; } @@ -172,8 +175,6 @@ again: i, nm_utils_inet4_ntop (info->addresses[i], sbuf), info->expected_result[i] ? "detect no duplicated" : "detect a duplicate"); } - - nm_acd_manager_free (manager); } static void @@ -199,8 +200,9 @@ test_acd_probe_2 (test_fixture *fixture, gconstpointer user_data) static void test_acd_announce (test_fixture *fixture, gconstpointer user_data) { - NMAcdManager *manager; - GMainLoop *loop; + nm_auto_free_acdmgr NMAcdManager *manager = NULL; + nm_auto_unref_gmainloop GMainLoop *loop = NULL; + int r; if (_skip_acd_test ()) return; @@ -216,11 +218,9 @@ test_acd_announce (test_fixture *fixture, gconstpointer user_data) g_assert (nm_acd_manager_add_address (manager, ADDR2)); loop = g_main_loop_new (NULL, FALSE); - nm_acd_manager_announce_addresses (manager); + r = nm_acd_manager_announce_addresses (manager); + g_assert_cmpint (r, ==, 0); g_assert (!nmtst_main_loop_run (loop, 200)); - g_main_loop_unref (loop); - - nm_acd_manager_free (manager); } static void diff --git a/src/devices/tests/test-lldp.c b/src/devices/tests/test-lldp.c index 7227d082..7b135f58 100644 --- a/src/devices/tests/test-lldp.c +++ b/src/devices/tests/test-lldp.c @@ -231,8 +231,10 @@ TEST_RECV_FRAME_DEFINE (_test_recv_data1_frame0, static void _test_recv_data1_check (GMainLoop *loop, NMLldpListener *listener) { - GVariant *neighbors, *attr; + GVariant *neighbors, *attr, *child; gs_unref_variant GVariant *neighbor = NULL; + guint v_uint = 0; + const char *v_str = NULL; neighbors = nm_lldp_listener_get_neighbors (listener); nmtst_assert_variant_is_of_type (neighbors, G_VARIANT_TYPE ("aa{sv}")); @@ -242,7 +244,7 @@ _test_recv_data1_check (GMainLoop *loop, NMLldpListener *listener) SD_LLDP_CHASSIS_SUBTYPE_MAC_ADDRESS, "00:01:30:F9:AD:A0", SD_LLDP_PORT_SUBTYPE_INTERFACE_NAME, "1/1"); g_assert (neighbor); - g_assert_cmpint (g_variant_n_children (neighbor), ==, 4 + 10); + g_assert_cmpint (g_variant_n_children (neighbor), ==, 4 + 16); attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_DESTINATION, G_VARIANT_TYPE_STRING); nmtst_assert_variant_string (attr, NM_LLDP_DEST_NEAREST_BRIDGE); @@ -270,11 +272,49 @@ _test_recv_data1_check (GMainLoop *loop, NMLldpListener *listener) nmtst_assert_variant_uint32 (attr, 20); nm_clear_g_variant (&attr); - /* unsupported: Management Address */ - /* unsupported: IEEE 802.3 - Power Via MDI */ - /* unsupported: IEEE 802.3 - MAC/PHY Configuration/Status */ + /* Management Address */ + attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_MANAGEMENT_ADDRESSES, G_VARIANT_TYPE ("aa{sv}")); + g_assert (attr); + g_assert_cmpuint (g_variant_n_children (attr), ==, 1); + child = g_variant_get_child_value (attr, 0); + g_assert (child); + g_variant_lookup (child, "interface-number", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 1001); + g_variant_lookup (child, "interface-number-subtype", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 2); + g_variant_lookup (child, "address-subtype", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 6); + nm_clear_g_variant (&child); + nm_clear_g_variant (&attr); + + /* IEEE 802.3 - Power Via MDI */ + attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_IEEE_802_3_POWER_VIA_MDI, G_VARIANT_TYPE_VARDICT); + g_assert (attr); + g_variant_lookup (attr, "mdi-power-support", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 7); + g_variant_lookup (attr, "pse-power-pair", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 1); + g_variant_lookup (attr, "power-class", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 0); + nm_clear_g_variant (&attr); + + /* IEEE 802.3 - MAC/PHY Configuration/Status */ + attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_IEEE_802_3_MAC_PHY_CONF, G_VARIANT_TYPE_VARDICT); + g_assert (attr); + g_variant_lookup (attr, "autoneg", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 3); + g_variant_lookup (attr, "pmd-autoneg-cap", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 0x6c00); + g_variant_lookup (attr, "operational-mau-type", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 16); + nm_clear_g_variant (&attr); + /* unsupported: IEEE 802.3 - Link Aggregation */ - /* unsupported: IEEE 802.3 - Maximum Frame Size*/ + + /* Maximum Frame Size */ + attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_IEEE_802_3_MAX_FRAME_SIZE, G_VARIANT_TYPE_UINT32); + nmtst_assert_variant_uint32 (attr, 1522); + nm_clear_g_variant (&attr); /* IEEE 802.1 - Port VLAN ID */ attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_IEEE_802_1_PVID, G_VARIANT_TYPE_UINT32); @@ -289,6 +329,18 @@ _test_recv_data1_check (GMainLoop *loop, NMLldpListener *listener) nmtst_assert_variant_uint32 (attr, 1); nm_clear_g_variant (&attr); + /* new PPVID attributes */ + attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_IEEE_802_1_PPVIDS, G_VARIANT_TYPE ("aa{sv}")); + g_assert_cmpuint (g_variant_n_children (attr), ==, 1); + child = g_variant_get_child_value (attr, 0); + g_assert (child); + g_variant_lookup (child, "ppvid", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 0); + g_variant_lookup (child, "flags", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 1); + nm_clear_g_variant (&child); + nm_clear_g_variant (&attr); + /* IEEE 802.1 - VLAN Name */ attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME, G_VARIANT_TYPE_STRING); nmtst_assert_variant_string (attr, "v2-0488-03-0505"); @@ -297,6 +349,18 @@ _test_recv_data1_check (GMainLoop *loop, NMLldpListener *listener) nmtst_assert_variant_uint32 (attr, 488); nm_clear_g_variant (&attr); + /* new VLAN attributes */ + attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_IEEE_802_1_VLANS, G_VARIANT_TYPE ("aa{sv}")); + g_assert_cmpuint (g_variant_n_children (attr), ==, 1); + child = g_variant_get_child_value (attr, 0); + g_assert (child); + g_variant_lookup (child, "vid", "u", &v_uint); + g_assert_cmpint (v_uint, ==, 488); + g_variant_lookup (child, "name", "&s", &v_str); + g_assert_cmpstr (v_str, ==, "v2-0488-03-0505"); + nm_clear_g_variant (&child); + nm_clear_g_variant (&attr); + /* unsupported: IEEE 802.1 - Protocol Identity */ } -- cgit 1.3.0-6-gf8a5