diff options
| author | Michael Biebl <biebl@debian.org> | 2015-05-05 17:48:57 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2015-05-05 17:48:57 +0200 |
| commit | f408e27bccfacf347605a8d98649975a68f38a17 (patch) | |
| tree | 654fd6695c31511baf919b1c0870d119a352ed75 /src/tests/test-general-with-expect.c | |
| parent | 2c032d8f1c6292c1338a615e6ec40252889ba85c (diff) | |
Imported Upstream version 1.0.2 upstream/1.0.2
Diffstat (limited to 'src/tests/test-general-with-expect.c')
| -rw-r--r-- | src/tests/test-general-with-expect.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index f5010dae..4a0627c9 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -333,16 +333,42 @@ test_nm_utils_kill_child (void) /*******************************************/ +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", -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 (); int main (int argc, char **argv) { - nmtst_init_assert_logging (&argc, &argv); - - nm_logging_setup ("DEBUG", "DEFAULT", NULL, NULL); + 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 (); } |