test valid parameters and data */
| 158 | |
| 159 | /* test valid parameters and data */ |
| 160 | int |
| 161 | test_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 | } |
no test coverage detected