summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml9
-rw-r--r--src/buildstream/_platform/linux.py2
-rw-r--r--src/buildstream/_platform/platform.py7
-rw-r--r--src/buildstream/testing/_utils/site.py14
-rw-r--r--tests/sandboxes/fallback.py68
-rw-r--r--tests/sandboxes/missing_dependencies.py42
-rw-r--r--tests/sandboxes/selection.py6
7 files changed, 20 insertions, 128 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e9977ffb2..70be8026c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -24,7 +24,7 @@ variables:
# Our own variables
# Version of the docker images we should use for all the images.
# This is taken from buildstream/buildstream-docker-images
- DOCKER_IMAGE_VERSION: master-138527946
+ DOCKER_IMAGE_VERSION: master-140747994
PYTEST_ADDOPTS: "--color=yes"
INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
PYTEST_ARGS: "--color=yes --integration -n 2"
@@ -115,17 +115,16 @@ overnight-fedora-30-aarch64:
only:
- schedules
-tests-buildbox-run:
+tests-bwrap:
image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:31-${DOCKER_IMAGE_VERSION}
<<: *tests
variables:
- BST_FORCE_SANDBOX: "buildbox-run"
+ BST_FORCE_SANDBOX: "bwrap"
tests-userchroot:
image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:31-${DOCKER_IMAGE_VERSION}
<<: *tests
variables:
- BST_FORCE_SANDBOX: "buildbox-run"
BST_CAS_STAGING_ROOT: "/builds/userchroot"
script:
@@ -450,7 +449,7 @@ coverage:
- tox -e coverage
- cp -a .coverage-reports/ ./coverage-report
dependencies:
- - tests-buildbox-run
+ - tests-bwrap
- tests-centos-7.7
- tests-debian-10
- tests-fedora-30
diff --git a/src/buildstream/_platform/linux.py b/src/buildstream/_platform/linux.py
index 670cfc6b9..74d0e1227 100644
--- a/src/buildstream/_platform/linux.py
+++ b/src/buildstream/_platform/linux.py
@@ -35,7 +35,7 @@ class Linux(Platform):
}
preferred_sandboxes = [
- "bwrap",
+ "buildbox-run",
]
self._try_sandboxes(force_sandbox, sandbox_setups, preferred_sandboxes)
diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py
index dddb52bd4..d0debfc7b 100644
--- a/src/buildstream/_platform/platform.py
+++ b/src/buildstream/_platform/platform.py
@@ -47,7 +47,11 @@ class Platform:
def _setup_sandbox(self, force_sandbox):
# The buildbox-run interface is not platform-specific
sandbox_setups = {"buildbox-run": self.setup_buildboxrun_sandbox, "dummy": self._setup_dummy_sandbox}
- preferred_sandboxes = []
+
+ preferred_sandboxes = [
+ "buildbox-run",
+ ]
+
self._try_sandboxes(force_sandbox, sandbox_setups, preferred_sandboxes)
def _try_sandboxes(self, force_sandbox, sandbox_setups, preferred_sandboxes):
@@ -81,6 +85,7 @@ class Platform:
sandbox_setups["dummy"]()
def _check_sandbox(self, Sandbox):
+ Sandbox._dummy_reasons = []
try:
Sandbox.check_available()
except SandboxError as Error:
diff --git a/src/buildstream/testing/_utils/site.py b/src/buildstream/testing/_utils/site.py
index 0dfbce222..9f0e7aa41 100644
--- a/src/buildstream/testing/_utils/site.py
+++ b/src/buildstream/testing/_utils/site.py
@@ -5,7 +5,6 @@ import os
import stat
import subprocess
import sys
-import platform
from typing import Optional # pylint: disable=unused-import
from buildstream import _site, utils, ProgramNotFoundError
@@ -64,23 +63,18 @@ CASD_SEPARATE_USER = bool(os.stat(casd_path).st_mode & stat.S_ISUID)
del casd_path
IS_LINUX = os.getenv("BST_FORCE_BACKEND", sys.platform).startswith("linux")
-IS_WSL = IS_LINUX and "Microsoft" in platform.uname().release
IS_WINDOWS = os.name == "nt"
MACHINE_ARCH = Platform.get_host_arch()
HAVE_SANDBOX = os.getenv("BST_FORCE_SANDBOX")
-if HAVE_SANDBOX is not None:
- pass
-elif IS_LINUX and HAVE_BWRAP and (not IS_WSL):
- HAVE_SANDBOX = "bwrap"
-
-
BUILDBOX_RUN = None
-if HAVE_SANDBOX == "buildbox-run":
+if HAVE_SANDBOX is None:
try:
path = utils.get_host_tool("buildbox-run")
+ subprocess.run([path, "--capabilities"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
BUILDBOX_RUN = os.path.basename(os.readlink(path))
- except (ProgramNotFoundError, OSError):
+ HAVE_SANDBOX = "buildbox-run"
+ except (ProgramNotFoundError, OSError, subprocess.CalledProcessError):
pass
diff --git a/tests/sandboxes/fallback.py b/tests/sandboxes/fallback.py
deleted file mode 100644
index 0fd8ed4aa..000000000
--- a/tests/sandboxes/fallback.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Copyright (C) 2019 Bloomberg Finance LP
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-# Pylint doesn't play well with fixtures and dependency injection from pytest
-# pylint: disable=redefined-outer-name
-
-import os
-import pytest
-
-from buildstream import _yaml
-from buildstream.exceptions import ErrorDomain
-from buildstream.testing import cli # pylint: disable=unused-import
-
-pytestmark = pytest.mark.integration
-
-
-DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
-
-
-@pytest.mark.datafiles(DATA_DIR)
-def test_fallback_platform_fails(cli, datafiles):
- project = str(datafiles)
- element_path = os.path.join(project, "elements", "element.bst")
-
- # Write out our test target
- element = {
- "kind": "script",
- "depends": [{"filename": "base.bst", "type": "build",},],
- "config": {"commands": ["true",],},
- }
- _yaml.roundtrip_dump(element, element_path)
-
- result = cli.run(
- project=project,
- args=["build", "element.bst"],
- env={"BST_FORCE_BACKEND": "fallback", "BST_FORCE_SANDBOX": None},
- )
- result.assert_main_error(ErrorDomain.STREAM, None)
- assert "FallBack platform only implements dummy sandbox" in result.stderr
- # The dummy sandbox can not build the element but it can get the element read
- # There for the element should be `buildable` rather than `waiting`
- assert cli.get_element_state(project, "element.bst") == "buildable"
-
-
-@pytest.mark.datafiles(DATA_DIR)
-def test_fallback_platform_can_use_dummy(cli, datafiles):
- project = str(datafiles)
-
- result = cli.run(
- project=project,
- args=["build", "import-file1.bst"],
- env={"BST_FORCE_BACKEND": "fallback", "BST_FORCE_SANDBOX": None},
- )
- result.assert_success()
- # The fallback platform can still provide a dummy sandbox that alows simple elemnts that do not need
- # a full sandbox to still be built on new platforms.
diff --git a/tests/sandboxes/missing_dependencies.py b/tests/sandboxes/missing_dependencies.py
index 2e96a1b1f..fb9fdafb9 100644
--- a/tests/sandboxes/missing_dependencies.py
+++ b/tests/sandboxes/missing_dependencies.py
@@ -24,7 +24,7 @@ def _symlink_host_tools_to_dir(host_tools, dir_):
@pytest.mark.skipif(not IS_LINUX, reason="Only available on Linux")
@pytest.mark.datafiles(DATA_DIR)
-def test_missing_bwrap_has_nice_error_message(cli, datafiles, tmp_path):
+def test_missing_buildbox_run_has_nice_error_message(cli, datafiles, tmp_path):
# Create symlink to buildbox-casd and git to work with custom PATH
bin_dir = tmp_path / "bin"
_symlink_host_tools_to_dir(["buildbox-casd", "git"], bin_dir)
@@ -46,43 +46,3 @@ def test_missing_bwrap_has_nice_error_message(cli, datafiles, tmp_path):
)
result.assert_task_error(ErrorDomain.SANDBOX, "unavailable-local-sandbox")
assert "not found" in result.stderr
-
-
-@pytest.mark.skipif(not IS_LINUX, reason="Only available on Linux")
-@pytest.mark.datafiles(DATA_DIR)
-def test_old_brwap_has_nice_error_message(cli, datafiles, tmp_path):
- bwrap = tmp_path.joinpath("bin/bwrap")
- bwrap.parent.mkdir()
- with bwrap.open("w") as fp:
- fp.write(
- """
- #!/bin/sh
- echo bubblewrap 0.0.1
- """.strip()
- )
-
- bwrap.chmod(0o755)
-
- # Create symlink to buildbox-casd and git to work with custom PATH
- bin_dir = tmp_path / "bin"
- _symlink_host_tools_to_dir(["buildbox-casd", "git"], bin_dir)
-
- project = str(datafiles)
- element_path = os.path.join(project, "elements", "element3.bst")
-
- # Write out our test target
- element = {
- "kind": "script",
- "depends": [{"filename": "base.bst", "type": "build",},],
- "config": {"commands": ["false",],},
- }
- _yaml.roundtrip_dump(element, element_path)
-
- # Build without access to host tools, this should fail with a nice error
- result = cli.run(
- project=project,
- args=["--debug", "--verbose", "build", "element3.bst"],
- env={"PATH": str(bin_dir), "BST_FORCE_SANDBOX": None},
- )
- result.assert_task_error(ErrorDomain.SANDBOX, "unavailable-local-sandbox")
- assert "too old" in result.stderr
diff --git a/tests/sandboxes/selection.py b/tests/sandboxes/selection.py
index daee6dcdd..3e6e1c4f5 100644
--- a/tests/sandboxes/selection.py
+++ b/tests/sandboxes/selection.py
@@ -43,9 +43,11 @@ def test_force_sandbox(cli, datafiles):
_yaml.roundtrip_dump(element, element_path)
# Build without access to host tools, this will fail
- result = cli.run(project=project, args=["build", "element.bst"], env={"PATH": "", "BST_FORCE_SANDBOX": "bwrap"})
+ result = cli.run(
+ project=project, args=["build", "element.bst"], env={"PATH": "", "BST_FORCE_SANDBOX": "buildbox-run"}
+ )
result.assert_main_error(ErrorDomain.PLATFORM, None)
- assert "Bubblewrap not found" in result.stderr
+ assert "buildbox-run not found" in result.stderr
# we have asked for a spesific sand box, but it is not avalble so
# bst should fail early and the element should be waiting
assert cli.get_element_state(project, "element.bst") == "waiting"