[libvirt] [PATCH 0/2] Fix 'make check' on RHEL-5.10

There are two tests failing for me on RHEL-5.10 and current git HEAD. Fix them. Michal Privoznik (2): tests: Use lv_abs_top_builddir instead of bare abs_top_builddir vircgroupmock: Mock access() to some more files tests/Makefile.am | 2 +- tests/vircgroupmock.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) -- 1.8.1.5

As stated in the comment above introduction of the lv_abs_top_builddir variable, older automake doesn't provide abs_top_builddir variable. Hence, we are creating our own one with lv_ prefix. However, when exporting env variables to the tests, the variables are not evaluated but only substituted. Hence: LIBVIRT_DRIVER_DIR="$(abs_top_builddir)/src/.libs" is set to "/src/.libs" with old automake (even though we *think* we've set the $abs_top_builddir variable just a few line above). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index a47d376..866ecd4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -345,7 +345,7 @@ TESTS_ENVIRONMENT = \ CONFIG_HEADER="`cd '$(top_builddir)'; pwd`/config.h" \ PATH="$(path_add)$(PATH_SEPARATOR)$$PATH" \ SHELL="$(SHELL)" \ - LIBVIRT_DRIVER_DIR="$(abs_top_builddir)/src/.libs" \ + LIBVIRT_DRIVER_DIR="$(lv_abs_top_builddir)/src/.libs" \ LIBVIRT_AUTOSTART=0 \ LC_ALL=C \ VIR_TEST_EXPENSIVE=$(VIR_TEST_EXPENSIVE) \ -- 1.8.1.5

On 10/22/2013 01:21 PM, Michal Privoznik wrote:
As stated in the comment above introduction of the lv_abs_top_builddir variable, older automake doesn't provide abs_top_builddir variable. Hence, we are creating our own one with lv_ prefix. However, when exporting env variables to the tests, the variables are not evaluated but only substituted. Hence:
LIBVIRT_DRIVER_DIR="$(abs_top_builddir)/src/.libs"
is set to "/src/.libs" with old automake (even though we *think* we've set the $abs_top_builddir variable just a few line above).
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ACK.
diff --git a/tests/Makefile.am b/tests/Makefile.am index a47d376..866ecd4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -345,7 +345,7 @@ TESTS_ENVIRONMENT = \ CONFIG_HEADER="`cd '$(top_builddir)'; pwd`/config.h" \ PATH="$(path_add)$(PATH_SEPARATOR)$$PATH" \ SHELL="$(SHELL)" \ - LIBVIRT_DRIVER_DIR="$(abs_top_builddir)/src/.libs" \ + LIBVIRT_DRIVER_DIR="$(lv_abs_top_builddir)/src/.libs" \ LIBVIRT_AUTOSTART=0 \ LC_ALL=C \ VIR_TEST_EXPENSIVE=$(VIR_TEST_EXPENSIVE) \
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Currently, if access(path, mode) is invoked, we check if @path has this special prefix SYSFS_PREFIX. If it does, we modify the path a bit and call realaccess. If it doesn't we act just like a wrapper and call realaccess directly. However, we are mocking fopen() as well. And as one can clearly see there, fopen("/proc/cgroups") will succeed. Hence, we have an error in our mocked access(): We need to check whether @path is not equal to /proc/cgroups as it may not exists on real system we're running however we definitely know how to fopen() it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/vircgroupmock.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index adc1718..6d7083d 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -498,6 +498,14 @@ int access(const char *path, int mode) } ret = realaccess(newpath, mode); free(newpath); + } else if (STREQ(path, "/proc/cgroups") || + STREQ(path, "/proc/self/cgroup")) { + /* These files are readable for all. */ + ret = (mode == F_OK || mode & R_OK) ? 0 : -1; + } else if (STREQ(path, "/proc/mounts")) { + /* This one is accessible anytime for anybody. In fact, it's just + * a symlink to /proc/self/mounts. */ + ret = 0; } else { ret = realaccess(path, mode); } -- 1.8.1.5

On 10/22/2013 01:21 PM, Michal Privoznik wrote:
Currently, if access(path, mode) is invoked, we check if @path has this special prefix SYSFS_PREFIX. If it does, we modify the path a bit and call realaccess. If it doesn't we act just like a wrapper and call realaccess directly. However, we are mocking fopen() as well. And as one can clearly see there, fopen("/proc/cgroups") will succeed. Hence, we have an error in our mocked access(): We need to check whether @path is not equal to /proc/cgroups as it may not exists on real system we're running however we definitely know how to fopen() it.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/vircgroupmock.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Close.
diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index adc1718..6d7083d 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -498,6 +498,14 @@ int access(const char *path, int mode) } ret = realaccess(newpath, mode); free(newpath); + } else if (STREQ(path, "/proc/cgroups") || + STREQ(path, "/proc/self/cgroup")) { + /* These files are readable for all. */ + ret = (mode == F_OK || mode & R_OK) ? 0 : -1;
Our mock means the files are readable for all, but not writable for all. I'd feel safer with: ret = (mode == F_OK || mode == R_OK) ? 0 : -1; so that we explicitly reject attempts to probe for other combinations like 'mode == (R_OK|X_OK)'.
+ } else if (STREQ(path, "/proc/mounts")) { + /* This one is accessible anytime for anybody. In fact, it's just + * a symlink to /proc/self/mounts. */ + ret = 0; } else { ret = realaccess(path, mode); }
ACK if that change still passes testing (but there may be fallout from mocking non-writable, which in turn would require a v2). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Michal Privoznik