MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_unformat_addr

Function test_unformat_addr

dpdk/app/test/test_net_ether.c:66–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66static int
67test_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
117static int
118test_invalid_addr(void)

Callers 1

test_net_etherFunction · 0.85

Calls 3

memsetFunction · 0.85
rte_ether_unformat_addrFunction · 0.85
rte_is_same_ether_addrFunction · 0.85

Tested by

no test coverage detected