]> xenbits.xensource.com Git - libvirt.git/commitdiff
vircgroupmock: Mock access("/sys/devices/system/cpu/present")
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Feb 2016 07:44:46 +0000 (08:44 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Feb 2016 10:14:29 +0000 (11:14 +0100)
There's been a report on the upstream list [1] describing we
access /sys/devices/system/cpu/present directly on the host from
within our test suite. This may end up in unpredictable results
as no all linux systems are required to have that file. Mock
access to the file.

libvirt.git/tests $ ../run strace vircgrouptest
...
access("/sys/devices/system/cpu/present", F_OK) = 0
...

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tests/vircgroupmock.c

index 9ce7d41cad226ac4458706332dac4452e92c06d2..756ac51679b49d2643f81a484761ec76cabbdfe5 100644 (file)
@@ -541,7 +541,8 @@ int access(const char *path, int mode)
         ret = realaccess(newpath, mode);
         free(newpath);
     } else if (STREQ(path, "/proc/cgroups") ||
-               STREQ(path, "/proc/self/cgroup")) {
+               STREQ(path, "/proc/self/cgroup") ||
+               STREQ(path, SYSFS_CPU_PRESENT)) {
         /* These files are readable for all. */
         ret = (mode == F_OK || mode == R_OK) ? 0 : -1;
     } else if (STREQ(path, "/proc/mounts")) {