summaryrefslogtreecommitdiff
path: root/src/tests/test-general-with-expect.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-04-23 12:51:01 +0200
committerThomas Haller <thaller@redhat.com>2015-04-23 16:38:51 +0200
commit842ec6163dd514bcf600df6f44542634e3aefe82 (patch)
tree12ed8b2b26516048af9386bb6fddcab716c81c92 /src/tests/test-general-with-expect.c
parentdbb3b44ca6ded4c4b810b85ffaa9f92d050369d2 (diff)
downloadNetworkManager-842ec6163dd514bcf600df6f44542634e3aefe82.tar.gz
core: refactor nm_ethernet_address_is_valid() and reject invalid addresses
nm_ethernet_address_is_valid() did not check whether @addr was a valid address in the first place. It only checked whether the address was not equal to a few notorious MAC addresses. At the same time, be more forgiving and accept %NULL as argument. This fixes an assertion nm_ap_match_in_hash().
Diffstat (limited to 'src/tests/test-general-with-expect.c')
-rw-r--r--src/tests/test-general-with-expect.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c
index 4d7548592e..4318b594c6 100644
--- a/src/tests/test-general-with-expect.c
+++ b/src/tests/test-general-with-expect.c
@@ -434,14 +434,17 @@ test_nm_utils_array_remove_at_indexes ()
static void
test_nm_ethernet_address_is_valid ()
{
+ g_assert (!nm_ethernet_address_is_valid (NULL, -1));
+ g_assert (!nm_ethernet_address_is_valid (NULL, ETH_ALEN));
+
g_assert (!nm_ethernet_address_is_valid ("FF:FF:FF:FF:FF:FF", -1));
g_assert (!nm_ethernet_address_is_valid ("00:00:00:00:00:00", -1));
g_assert (!nm_ethernet_address_is_valid ("44:44:44:44:44:44", -1));
g_assert (!nm_ethernet_address_is_valid ("00:30:b4:00:00:00", -1));
- g_assert ( nm_ethernet_address_is_valid ("", -1));
+ g_assert (!nm_ethernet_address_is_valid ("", -1));
g_assert (!nm_ethernet_address_is_valid ("1", -1));
- g_assert ( nm_ethernet_address_is_valid ("2", -1));
+ g_assert (!nm_ethernet_address_is_valid ("2", -1));
g_assert (!nm_ethernet_address_is_valid (((guint8[8]) { 0x00,0x30,0xb4,0x00,0x00,0x00 }), ETH_ALEN));
g_assert ( nm_ethernet_address_is_valid (((guint8[8]) { 0x00,0x30,0xb4,0x00,0x00,0x01 }), ETH_ALEN));