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

Function test_parse_etheraddr_valid

dpdk/app/test/test_cmdline_etheraddr.c:160–206  ·  view source on GitHub ↗

test valid parameters and data */

Source from the content-addressed store, hash-verified

158
159/* test valid parameters and data */
160int
161test_parse_etheraddr_valid(void)
162{
163 int ret = 0;
164 unsigned i;
165 struct rte_ether_addr result;
166
167 /* test full strings */
168 for (i = 0; i < RTE_DIM(ether_addr_valid_strs); i++) {
169
170 memset(&result, 0, sizeof(struct rte_ether_addr));
171
172 ret = cmdline_parse_etheraddr(NULL, ether_addr_valid_strs[i].str,
173 (void*)&result, sizeof(result));
174 if (ret < 0) {
175 printf("Error: parsing %s failed!\n",
176 ether_addr_valid_strs[i].str);
177 return -1;
178 }
179 if (is_addr_different(result, ether_addr_valid_strs[i].address)) {
180 printf("Error: parsing %s failed: address mismatch!\n",
181 ether_addr_valid_strs[i].str);
182 return -1;
183 }
184 }
185
186 /* test garbage strings */
187 for (i = 0; i < RTE_DIM(ether_addr_garbage_strs); i++) {
188
189 memset(&result, 0, sizeof(struct rte_ether_addr));
190
191 ret = cmdline_parse_etheraddr(NULL, ether_addr_garbage_strs[i],
192 (void*)&result, sizeof(result));
193 if (ret < 0) {
194 printf("Error: parsing %s failed!\n",
195 ether_addr_garbage_strs[i]);
196 return -1;
197 }
198 if (is_addr_different(result, GARBAGE_ETHERADDR)) {
199 printf("Error: parsing %s failed: address mismatch!\n",
200 ether_addr_garbage_strs[i]);
201 return -1;
202 }
203 }
204
205 return 0;
206}

Callers 1

test_cmdlineFunction · 0.85

Calls 4

memsetFunction · 0.85
cmdline_parse_etheraddrFunction · 0.85
is_addr_differentFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected