mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-15 13:50:36 +01:00
core/test: add test for nm_ethernet_address_is_valid()
(cherry picked from commit dbb3b44ca6)
Conflicts:
src/tests/test-general-with-expect.c
This commit is contained in:
parent
1e5d009367
commit
5fd1c12569
1 changed files with 25 additions and 0 deletions
|
|
@ -331,6 +331,30 @@ test_nm_utils_kill_child (void)
|
|||
}
|
||||
|
||||
|
||||
/*******************************************/
|
||||
|
||||
static void
|
||||
test_nm_ethernet_address_is_valid ()
|
||||
{
|
||||
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", -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));
|
||||
|
||||
/* some Broad cast addresses (with MSB of first octet set). */
|
||||
g_assert (!nm_ethernet_address_is_valid ("57:44:44:44:44:44", -1));
|
||||
g_assert ( nm_ethernet_address_is_valid ("56:44:44:44:44:44", -1));
|
||||
g_assert (!nm_ethernet_address_is_valid (((guint8[8]) { 0x03,0x30,0xb4,0x00,0x00,0x00 }), ETH_ALEN));
|
||||
g_assert ( nm_ethernet_address_is_valid (((guint8[8]) { 0x02,0x30,0xb4,0x00,0x00,0x01 }), ETH_ALEN));
|
||||
}
|
||||
|
||||
/*******************************************/
|
||||
|
||||
NMTST_DEFINE ();
|
||||
|
|
@ -341,6 +365,7 @@ main (int argc, char **argv)
|
|||
nmtst_init_assert_logging (&argc, &argv, "DEBUG", "DEFAULT");
|
||||
|
||||
g_test_add_func ("/general/nm_utils_kill_child", test_nm_utils_kill_child);
|
||||
g_test_add_func ("/general/nm_ethernet_address_is_valid", test_nm_ethernet_address_is_valid);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue