+static int test_pci_sysfs(void)
+{
+ const char *orig;
+ const char *newpath;
+ int ret;
+
+ orig = pci_get_sysfs_path();
+ ret = setenv("SYSFS_PCI_DEVICES", "My Documents", 1);
+ TEST_ASSERT_SUCCESS(ret, "Failed setenv to My Documents");
+
+ newpath = pci_get_sysfs_path();
+ TEST_ASSERT(!strcmp(newpath, "My Documents"),
+ "pci_get_sysfs_path() should return 'My Documents' "
+ "but gives %s", newpath);
+
+ ret = setenv("SYSFS_PCI_DEVICES", orig, 1);
+ TEST_ASSERT_SUCCESS(ret, "Failed setenv back to '%s'", orig);
+
+ newpath = pci_get_sysfs_path();
+ TEST_ASSERT(!strcmp(orig, newpath),
+ "pci_get_sysfs_path returned unexpected path: "
+ "%s (expected: %s)", newpath, orig);
+ return 0;
+}
+