| 61 | }; |
| 62 | |
| 63 | static int |
| 64 | test_valid_devargs_cases(const struct devargs_case *list, size_t n) |
| 65 | { |
| 66 | struct rte_devargs da; |
| 67 | uint32_t i; |
| 68 | int ret; |
| 69 | int fail = TEST_SUCCESS; |
| 70 | struct rte_bus *pci_bus = rte_bus_find_by_name("pci"); |
| 71 | struct rte_bus *vdev_bus = rte_bus_find_by_name("vdev"); |
| 72 | struct rte_class *eth_class = rte_class_find_by_name("eth"); |
| 73 | |
| 74 | for (i = 0; i < n; i++) { |
| 75 | if (pci_bus == NULL && list[i].bus != NULL && |
| 76 | strcmp(list[i].bus, "pci") == 0) |
| 77 | continue; |
| 78 | if (vdev_bus == NULL && list[i].bus != NULL && |
| 79 | strcmp(list[i].bus, "vdev") == 0) |
| 80 | continue; |
| 81 | if (eth_class == NULL && list[i].class != NULL && |
| 82 | strcmp(list[i].class, "eth") == 0) |
| 83 | continue; |
| 84 | memset(&da, 0, sizeof(da)); |
| 85 | ret = rte_devargs_parse(&da, list[i].devargs); |
| 86 | if (ret < 0) { |
| 87 | printf("rte_devargs_parse(%s) returned %d (but should not)\n", |
| 88 | list[i].devargs, ret); |
| 89 | goto fail; |
| 90 | } |
| 91 | if ((list[i].bus_kv > 0 || list[i].bus != NULL) && |
| 92 | da.bus == NULL) { |
| 93 | printf("rte_devargs_parse(%s) bus not parsed\n", |
| 94 | list[i].devargs); |
| 95 | goto fail; |
| 96 | } |
| 97 | if (test_args(list[i].devargs, "bus", da.bus_str, |
| 98 | list[i].bus_kv) != 0) |
| 99 | goto fail; |
| 100 | if (list[i].bus != NULL && |
| 101 | strcmp(rte_bus_name(da.bus), list[i].bus) != 0) { |
| 102 | printf("rte_devargs_parse(%s) bus name (%s) not expected (%s)\n", |
| 103 | list[i].devargs, rte_bus_name(da.bus), list[i].bus); |
| 104 | goto fail; |
| 105 | } |
| 106 | if ((list[i].class_kv > 0 || list[i].class != NULL) && |
| 107 | da.cls == NULL) { |
| 108 | printf("rte_devargs_parse(%s) class not parsed\n", |
| 109 | list[i].devargs); |
| 110 | goto fail; |
| 111 | } |
| 112 | if (test_args(list[i].devargs, "class", da.cls_str, |
| 113 | list[i].class_kv) != 0) |
| 114 | goto fail; |
| 115 | if (list[i].class != NULL && |
| 116 | strcmp(da.cls->name, list[i].class) != 0) { |
| 117 | printf("rte_devargs_parse(%s) class name (%s) not expected (%s)\n", |
| 118 | list[i].devargs, da.cls->name, list[i].class); |
| 119 | goto fail; |
| 120 | } |
no test coverage detected