[PATCH] tests: Fix PCI test data filenames for Windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Windows doesn't allow : in filenames.

Commit 21685c955e546676a5b2a01f7b788d222e0ee0f5 added files with a : in
their names. This broke git operations on Windows as git is not able to
create those files on clone or pull.

Replace : with - in the offending filenames and adapt the test case.
---
 tests/virpcimock.c                                   |  19 ++++++++++++++++++-
 .../{0000:00:01.0.config => 0000-00-01.0.config}     | Bin
 .../{0000:00:02.0.config => 0000-00-02.0.config}     | Bin
 .../{0000:00:03.0.config => 0000-00-03.0.config}     | Bin
 .../{0001:00:00.0.config => 0001-00-00.0.config}     | Bin
 .../{0001:01:00.0.config => 0001-01-00.0.config}     | Bin
 .../{0001:01:00.1.config => 0001-01-00.1.config}     | Bin
 .../{0005:80:00.0.config => 0005-80-00.0.config}     | Bin
 .../{0005:90:01.0.config => 0005-90-01.0.config}     | Bin
 .../{0005:90:01.1.config => 0005-90-01.1.config}     | Bin
 .../{0005:90:01.2.config => 0005-90-01.2.config}     | Bin
 11 files changed, 18 insertions(+), 1 deletion(-)
 rename tests/virpcitestdata/{0000:00:01.0.config => 0000-00-01.0.config} (100%)
 rename tests/virpcitestdata/{0000:00:02.0.config => 0000-00-02.0.config} (100%)
 rename tests/virpcitestdata/{0000:00:03.0.config => 0000-00-03.0.config} (100%)
 rename tests/virpcitestdata/{0001:00:00.0.config => 0001-00-00.0.config} (100%)
 rename tests/virpcitestdata/{0001:01:00.0.config => 0001-01-00.0.config} (100%)
 rename tests/virpcitestdata/{0001:01:00.1.config => 0001-01-00.1.config} (100%)
 rename tests/virpcitestdata/{0005:80:00.0.config => 0005-80-00.0.config} (100%)
 rename tests/virpcitestdata/{0005:90:01.0.config => 0005-90-01.0.config} (100%)
 rename tests/virpcitestdata/{0005:90:01.1.config => 0005-90-01.1.config} (100%)
 rename tests/virpcitestdata/{0005:90:01.2.config => 0005-90-01.2.config} (100%)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 1efcd33..b42e8bf 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -320,16 +320,33 @@ pci_device_new_from_stub(const struct pciDevice *data)
 {
     struct pciDevice *dev;
     char *devpath;
+    char *id;
+    char *c;
     char *configSrc;
     char tmp[32];
     struct stat sb;
 
+    if (VIR_STRDUP_QUIET(id, data->id) < 0)
+        ABORT_OOM();
+
+    /* Replace ':' with '-' to create the config filename from the
+     * device ID. The device ID cannot be used directly as filename
+     * because it contains ':' and Windows does not allow ':' in
+     * filenames. */
+    c = strchr(id, ':');
+
+    while (c) {
+        *c = '-';
+        c = strchr(c, ':');
+    }
+
     if (VIR_ALLOC_QUIET(dev) < 0 ||
         virAsprintfQuiet(&configSrc, "%s/virpcitestdata/%s.config",
-                         abs_srcdir, data->id) < 0 ||
+                         abs_srcdir, id) < 0 ||
         virAsprintfQuiet(&devpath, "%s/devices/%s", fakesysfsdir, data->id) < 0)
         ABORT_OOM();
 
+    VIR_FREE(id);
     memcpy(dev, data, sizeof(*dev));
 
     if (virFileMakePath(devpath) < 0)
diff --git a/tests/virpcitestdata/0000:00:01.0.config b/tests/virpcitestdata/0000-00-01.0.config
similarity index 100%
rename from tests/virpcitestdata/0000:00:01.0.config
rename to tests/virpcitestdata/0000-00-01.0.config
diff --git a/tests/virpcitestdata/0000:00:02.0.config b/tests/virpcitestdata/0000-00-02.0.config
similarity index 100%
rename from tests/virpcitestdata/0000:00:02.0.config
rename to tests/virpcitestdata/0000-00-02.0.config
diff --git a/tests/virpcitestdata/0000:00:03.0.config b/tests/virpcitestdata/0000-00-03.0.config
similarity index 100%
rename from tests/virpcitestdata/0000:00:03.0.config
rename to tests/virpcitestdata/0000-00-03.0.config
diff --git a/tests/virpcitestdata/0001:00:00.0.config b/tests/virpcitestdata/0001-00-00.0.config
similarity index 100%
rename from tests/virpcitestdata/0001:00:00.0.config
rename to tests/virpcitestdata/0001-00-00.0.config
diff --git a/tests/virpcitestdata/0001:01:00.0.config b/tests/virpcitestdata/0001-01-00.0.config
similarity index 100%
rename from tests/virpcitestdata/0001:01:00.0.config
rename to tests/virpcitestdata/0001-01-00.0.config
diff --git a/tests/virpcitestdata/0001:01:00.1.config b/tests/virpcitestdata/0001-01-00.1.config
similarity index 100%
rename from tests/virpcitestdata/0001:01:00.1.config
rename to tests/virpcitestdata/0001-01-00.1.config
diff --git a/tests/virpcitestdata/0005:80:00.0.config b/tests/virpcitestdata/0005-80-00.0.config
similarity index 100%
rename from tests/virpcitestdata/0005:80:00.0.config
rename to tests/virpcitestdata/0005-80-00.0.config
diff --git a/tests/virpcitestdata/0005:90:01.0.config b/tests/virpcitestdata/0005-90-01.0.config
similarity index 100%
rename from tests/virpcitestdata/0005:90:01.0.config
rename to tests/virpcitestdata/0005-90-01.0.config
diff --git a/tests/virpcitestdata/0005:90:01.1.config b/tests/virpcitestdata/0005-90-01.1.config
similarity index 100%
rename from tests/virpcitestdata/0005:90:01.1.config
rename to tests/virpcitestdata/0005-90-01.1.config
diff --git a/tests/virpcitestdata/0005:90:01.2.config b/tests/virpcitestdata/0005-90-01.2.config
similarity index 100%
rename from tests/virpcitestdata/0005:90:01.2.config
rename to tests/virpcitestdata/0005-90-01.2.config
-- 
1.8.1.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]