+
+ return 0;
+}
+
+static int
+test_pci_cleanup(void)
+{
+ struct rte_pci_device *dev;
+ struct rte_pci_driver *dr;
+ const struct resource *r;
+ int ret;
+
+ unsetenv("SYSFS_PCI_DEVICES");
+
+ r = resource_find("test_pci_sysfs");
+ TEST_ASSERT_NOT_NULL(r, "missing resource test_pci_sysfs");
+
+ ret = resource_rm_by_tar(r);
+ TEST_ASSERT_SUCCESS(ret, "Failed to delete resource %s", r->name);
+
+ /*
+ * FIXME: there is no API in DPDK to free a rte_pci_device so we
+ * cannot free the devices in the right way. Let's assume that we
+ * don't care for tests.
+ */
+ while (!TAILQ_EMPTY(&pci_device_list)) {
+ dev = TAILQ_FIRST(&pci_device_list);
+ TAILQ_REMOVE(&pci_device_list, dev, next);
+ }
+
+ /* Restore original devices & drivers lists */
+ while (!TAILQ_EMPTY(&real_pci_driver_list)) {
+ dr = TAILQ_FIRST(&real_pci_driver_list);
+ TAILQ_REMOVE(&real_pci_driver_list, dr, next);
+ rte_eal_pci_register(dr);
+ }
+
+ while (!TAILQ_EMPTY(&real_pci_device_list)) {
+ dev = TAILQ_FIRST(&real_pci_device_list);
+ TAILQ_REMOVE(&real_pci_device_list, dev, next);
+ TAILQ_INSERT_TAIL(&pci_device_list, dev, next);