| 64 | } |
| 65 | |
| 66 | static int |
| 67 | test_unformat_addr(void) |
| 68 | { |
| 69 | const struct rte_ether_addr expected = { |
| 70 | .addr_bytes = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc }, |
| 71 | }; |
| 72 | const struct rte_ether_addr nozero_ea = { |
| 73 | .addr_bytes = { 1, 2, 3, 4, 5, 6 }, |
| 74 | }; |
| 75 | struct rte_ether_addr result; |
| 76 | int ret; |
| 77 | |
| 78 | /* Test IETF format */ |
| 79 | memset(&result, 0, sizeof(result)); |
| 80 | ret = rte_ether_unformat_addr("12:34:56:78:9a:bc", &result); |
| 81 | RTE_TEST_ASSERT(ret == 0, "IETF unformat failed"); |
| 82 | RTE_TEST_ASSERT(rte_is_same_ether_addr(&expected, &result), |
| 83 | "IETF unformat mismatch"); |
| 84 | |
| 85 | /* Test IEEE format */ |
| 86 | memset(&result, 0, sizeof(result)); |
| 87 | ret = rte_ether_unformat_addr("12-34-56-78-9A-BC", &result); |
| 88 | RTE_TEST_ASSERT(ret == 0, "IEEE unformat failed"); |
| 89 | RTE_TEST_ASSERT(rte_is_same_ether_addr(&expected, &result), |
| 90 | "IEEE unformat mismatch"); |
| 91 | |
| 92 | /* Test Cisco format */ |
| 93 | memset(&result, 0, sizeof(result)); |
| 94 | ret = rte_ether_unformat_addr("1234.5678.9ABC", &result); |
| 95 | RTE_TEST_ASSERT(ret == 0, "Cisco unformat failed"); |
| 96 | RTE_TEST_ASSERT(rte_is_same_ether_addr(&expected, &result), |
| 97 | "Cisco unformat mismatch"); |
| 98 | |
| 99 | /* Test no leading zeros - IETF */ |
| 100 | memset(&result, 0, sizeof(result)); |
| 101 | ret = rte_ether_unformat_addr("1:2:3:4:5:6", &result); |
| 102 | RTE_TEST_ASSERT(ret == 0, "IETF leading zero failed"); |
| 103 | RTE_TEST_ASSERT(rte_is_same_ether_addr(&nozero_ea, &result), |
| 104 | "IETF leading zero mismatch"); |
| 105 | |
| 106 | /* Test no-leading zero - IEEE format */ |
| 107 | memset(&result, 0, sizeof(result)); |
| 108 | ret = rte_ether_unformat_addr("1-2-3-4-5-6", &result); |
| 109 | RTE_TEST_ASSERT(ret == 0, "IEEE leading zero failed"); |
| 110 | RTE_TEST_ASSERT(rte_is_same_ether_addr(&nozero_ea, &result), |
| 111 | "IEEE leading zero mismatch"); |
| 112 | |
| 113 | |
| 114 | return 0; |
| 115 | } |
| 116 | |
| 117 | static int |
| 118 | test_invalid_addr(void) |
no test coverage detected