From 1769f8e8dcff34320ff7d7c7900645589d59d73a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 7 Sep 2016 13:30:59 +0100 Subject: [PATCH] Tell build-time tests which bwrap we are going to use In autobuilder environments that deprive the build of capabilities, it is entirely possible that we have a system bwrap(1) but cannot run it, for example because CAP_SYS_ADMIN has been excluded from the capability bounding set. Tell the tests which bwrap we are going to run, so we can run it in a simpler way and see whether it works. Debian's sbuild autobuilder currently suffers from a different issue in which pivot_root(2) returns EINVAL, possibly caused by sbuild being chroot-based and so not having the mount point structure that is required for pivot_root. This avoids the problematic build-time tests there too; they work on ci.debian.net, which uses lxc instead of chroots, and in virtual machines. Because $(BWRAP) might be non-absolute, we need to search PATH for it. Signed-off-by: Simon McVittie --- tests/Makefile.am.inc | 4 +++- tests/testlibrary.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc index ec8e9f2c4..2f83c1167 100644 --- a/tests/Makefile.am.inc +++ b/tests/Makefile.am.inc @@ -6,7 +6,9 @@ TESTS_ENVIRONMENT += FLATPAK_TESTS_DEBUG=1 \ PATH=$$(cd $(top_builddir) && pwd):$${PATH} \ $(NULL) -if !WITH_SYSTEM_BWRAP +if WITH_SYSTEM_BWRAP +TESTS_ENVIRONMENT += FLATPAK_BWRAP=$(BWRAP) +else TESTS_ENVIRONMENT += FLATPAK_BWRAP=$$(cd $(top_builddir) && pwd)/flatpak-bwrap endif diff --git a/tests/testlibrary.c b/tests/testlibrary.c index 06a16250a..e6baf44c7 100644 --- a/tests/testlibrary.c +++ b/tests/testlibrary.c @@ -276,7 +276,7 @@ test_install_launch_uninstall (void) { gint exit_code = 0; char *argv[] = { (char *)bwrap, "--ro-bind", "/", "/", "/bin/true", NULL }; - g_spawn_sync (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, &exit_code, &error); + g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, &exit_code, &error); g_assert_no_error (error); if (exit_code != 0) {