ether-addr-util: make ether_addr_from_string() stricter

This commit is contained in:
Yu Watanabe
2018-05-09 11:57:36 +09:00
parent 3c31f3a575
commit e5c1be89b5
4 changed files with 26 additions and 26 deletions
+5 -4
View File
@@ -58,10 +58,10 @@ static void test_config_parse_hwaddr_one(const char *rvalue, int ret, const stru
assert_se(ret == r);
if (expected) {
assert_se(actual);
assert(ether_addr_equal(expected, actual));
} else {
assert_se(ether_addr_equal(expected, actual));
} else
assert_se(actual == NULL);
}
free(actual);
}
@@ -90,12 +90,13 @@ static void test_config_parse_hwaddr(void) {
{ .ether_addr_octet = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff } },
{ .ether_addr_octet = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } },
};
test_config_parse_hwaddr_one("", 0, NULL);
test_config_parse_hwaddr_one("no:ta:ma:ca:dd:re", 0, NULL);
test_config_parse_hwaddr_one("aa:bb:cc:dd:ee:fx", 0, NULL);
test_config_parse_hwaddr_one("aa:bb:cc:dd:ee:ff", 0, &t[0]);
test_config_parse_hwaddr_one(" aa:bb:cc:dd:ee:ff", 0, &t[0]);
test_config_parse_hwaddr_one("aa:bb:cc:dd:ee:ff \t\n", 0, &t[0]);
test_config_parse_hwaddr_one("aa:bb:cc:dd:ee:ff \t\n", 0, NULL);
test_config_parse_hwaddr_one("aa:bb:cc:dd:ee:ff \t\nxxx", 0, NULL);
test_config_parse_hwaddr_one("aa:bb:cc: dd:ee:ff", 0, NULL);
test_config_parse_hwaddr_one("aa:bb:cc:d d:ee:ff", 0, NULL);