diff options
8 files changed, 1 insertions, 132 deletions
diff --git a/src/buildstream/_site.py b/src/buildstream/_site.py index db0587120..2bdf45b02 100644 --- a/src/buildstream/_site.py +++ b/src/buildstream/_site.py @@ -18,8 +18,6 @@ # Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> import os -import shutil -import subprocess # # Private module declaring some info about where the buildstream @@ -46,22 +44,3 @@ build_all_template = os.path.join(root, "data", "build-all.sh.in") # Module building script template build_module_template = os.path.join(root, "data", "build-module.sh.in") - - -def get_bwrap_version(): - # Get the current bwrap version - # - # returns None if no bwrap was found - # otherwise returns a tuple of 3 int: major, minor, patch - bwrap_path = shutil.which("bwrap") - - if not bwrap_path: - return None - - cmd = [bwrap_path, "--version"] - try: - version = str(subprocess.check_output(cmd).split()[1], "utf-8") - except subprocess.CalledProcessError: - return None - - return tuple(int(x) for x in version.split(".")) diff --git a/src/buildstream/testing/_utils/site.py b/src/buildstream/testing/_utils/site.py index 9f0e7aa41..70d23a5cc 100644 --- a/src/buildstream/testing/_utils/site.py +++ b/src/buildstream/testing/_utils/site.py @@ -7,7 +7,7 @@ import subprocess import sys from typing import Optional # pylint: disable=unused-import -from buildstream import _site, utils, ProgramNotFoundError +from buildstream import utils, ProgramNotFoundError from buildstream._platform import Platform @@ -45,14 +45,6 @@ except ProgramNotFoundError: BZR_ENV = {} try: - utils.get_host_tool("bwrap") - HAVE_BWRAP = True - HAVE_BWRAP_JSON_STATUS = _site.get_bwrap_version() >= (0, 3, 2) -except ProgramNotFoundError: - HAVE_BWRAP = False - HAVE_BWRAP_JSON_STATUS = False - -try: utils.get_host_tool("lzip") HAVE_LZIP = True except ProgramNotFoundError: diff --git a/tests/integration/project/elements/sandbox-bwrap/base-with-tmp.bst b/tests/integration/project/elements/sandbox-bwrap/base-with-tmp.bst deleted file mode 100644 index 5c9fa6083..000000000 --- a/tests/integration/project/elements/sandbox-bwrap/base-with-tmp.bst +++ /dev/null @@ -1,6 +0,0 @@ -kind: import -description: Base for after-sandbox cleanup test - -sources: - - kind: local - path: files/base-with-tmp/ diff --git a/tests/integration/project/elements/sandbox-bwrap/break-shell.bst b/tests/integration/project/elements/sandbox-bwrap/break-shell.bst deleted file mode 100644 index c93a92350..000000000 --- a/tests/integration/project/elements/sandbox-bwrap/break-shell.bst +++ /dev/null @@ -1,9 +0,0 @@ -kind: manual -depends: - - base/base-alpine.bst - -public: - bst: - integration-commands: - - | - chmod a-x /bin/sh diff --git a/tests/integration/project/elements/sandbox-bwrap/command-exit-42.bst b/tests/integration/project/elements/sandbox-bwrap/command-exit-42.bst deleted file mode 100644 index c633334ae..000000000 --- a/tests/integration/project/elements/sandbox-bwrap/command-exit-42.bst +++ /dev/null @@ -1,8 +0,0 @@ -kind: manual -depends: - - base/base-alpine.bst - -config: - build-commands: - - | - exit 42 diff --git a/tests/integration/project/elements/sandbox-bwrap/non-executable-shell.bst b/tests/integration/project/elements/sandbox-bwrap/non-executable-shell.bst deleted file mode 100644 index a57177bb3..000000000 --- a/tests/integration/project/elements/sandbox-bwrap/non-executable-shell.bst +++ /dev/null @@ -1,9 +0,0 @@ -kind: manual - -depends: - - sandbox-bwrap/break-shell.bst - -config: - build-commands: - - | - exit 42 diff --git a/tests/integration/project/elements/sandbox-bwrap/test-cleanup.bst b/tests/integration/project/elements/sandbox-bwrap/test-cleanup.bst deleted file mode 100644 index 2a89dd3ee..000000000 --- a/tests/integration/project/elements/sandbox-bwrap/test-cleanup.bst +++ /dev/null @@ -1,13 +0,0 @@ -kind: manual -description: A dummy project to utilize a base with existing /tmp folder. - -depends: - - filename: base.bst - type: build - - - filename: sandbox-bwrap/base-with-tmp.bst - -config: - build-commands: - - | - true diff --git a/tests/integration/sandbox-bwrap.py b/tests/integration/sandbox-bwrap.py deleted file mode 100644 index 3bf734edb..000000000 --- a/tests/integration/sandbox-bwrap.py +++ /dev/null @@ -1,57 +0,0 @@ -# Pylint doesn't play well with fixtures and dependency injection from pytest -# pylint: disable=redefined-outer-name - -import os -import pytest - -from buildstream.exceptions import ErrorDomain - -from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from buildstream.testing._utils.site import HAVE_SANDBOX, HAVE_BWRAP_JSON_STATUS - - -pytestmark = pytest.mark.integration - - -DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project") - - -# Bubblewrap sandbox doesn't remove the dirs it created during its execution, -# so BuildStream tries to remove them to do good. BuildStream should be extra -# careful when those folders already exist and should not touch them, though. -@pytest.mark.skipif(HAVE_SANDBOX != "bwrap", reason="Only available with bubblewrap") -@pytest.mark.datafiles(DATA_DIR) -def test_sandbox_bwrap_cleanup_build(cli, datafiles): - project = str(datafiles) - # This element depends on a base image with non-empty `/tmp` folder. - element_name = "sandbox-bwrap/test-cleanup.bst" - - # Here, BuildStream should not attempt any rmdir etc. - result = cli.run(project=project, args=["build", element_name]) - assert result.exit_code == 0 - - -@pytest.mark.skipif(HAVE_SANDBOX != "bwrap", reason="Only available with bubblewrap") -@pytest.mark.skipif(not HAVE_BWRAP_JSON_STATUS, reason="Only available with bubblewrap supporting --json-status-fd") -@pytest.mark.datafiles(DATA_DIR) -def test_sandbox_bwrap_distinguish_setup_error(cli, datafiles): - project = str(datafiles) - element_name = "sandbox-bwrap/non-executable-shell.bst" - - result = cli.run(project=project, args=["build", element_name]) - result.assert_task_error(error_domain=ErrorDomain.SANDBOX, error_reason="bwrap-sandbox-fail") - - -@pytest.mark.skipif(HAVE_SANDBOX != "bwrap", reason="Only available with bubblewrap") -@pytest.mark.datafiles(DATA_DIR) -def test_sandbox_bwrap_return_subprocess(cli, datafiles): - project = str(datafiles) - element_name = "sandbox-bwrap/command-exit-42.bst" - - cli.configure( - {"logging": {"message-format": "%{element}|%{message}",},} - ) - - result = cli.run(project=project, args=["build", element_name]) - result.assert_task_error(error_domain=ErrorDomain.SANDBOX, error_reason="command-failed") - assert "sandbox-bwrap/command-exit-42.bst|Command failed with exitcode 42" in result.stderr |