1
|
1
|
import os
|
2
|
2
|
import pytest
|
3
|
3
|
|
|
4
|
+from buildstream._exceptions import ErrorDomain
|
|
5
|
+
|
4
|
6
|
from tests.testutils import cli_integration as cli
|
5
|
7
|
from tests.testutils.integration import assert_contains
|
6
|
|
-from tests.testutils.site import HAVE_BWRAP
|
|
8
|
+from tests.testutils.site import HAVE_BWRAP, HAVE_BWRAP_JSON_STATUS
|
7
|
9
|
|
8
|
10
|
|
9
|
11
|
pytestmark = pytest.mark.integration
|
... |
... |
@@ -29,3 +31,32 @@ def test_sandbox_bwrap_cleanup_build(cli, tmpdir, datafiles): |
29
|
31
|
# Here, BuildStream should not attempt any rmdir etc.
|
30
|
32
|
result = cli.run(project=project, args=['build', element_name])
|
31
|
33
|
assert result.exit_code == 0
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+@pytest.mark.skipif(not HAVE_BWRAP, reason='Only available with bubblewrap')
|
|
37
|
+@pytest.mark.skipif(not HAVE_BWRAP_JSON_STATUS, reason='Only available with bubblewrap supporting --json-status-fd')
|
|
38
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
39
|
+def test_sandbox_bwrap_distinguish_setup_error(cli, tmpdir, datafiles):
|
|
40
|
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
41
|
+ element_name = 'sandbox-bwrap/non-executable-shell.bst'
|
|
42
|
+
|
|
43
|
+ result = cli.run(project=project, args=['build', element_name])
|
|
44
|
+ result.assert_task_error(error_domain=ErrorDomain.SANDBOX, error_reason="bwrap-sandbox-fail")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+@pytest.mark.integration
|
|
48
|
+@pytest.mark.skipif(not HAVE_BWRAP, reason='Only available with bubblewrap')
|
|
49
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
50
|
+def test_sandbox_bwrap_return_subprocess(cli, tmpdir, datafiles):
|
|
51
|
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
52
|
+ element_name = 'sandbox-bwrap/command-exit-42.bst'
|
|
53
|
+
|
|
54
|
+ cli.configure({
|
|
55
|
+ "logging": {
|
|
56
|
+ "message-format": "%{element}|%{message}",
|
|
57
|
+ },
|
|
58
|
+ })
|
|
59
|
+
|
|
60
|
+ result = cli.run(project=project, args=['build', element_name])
|
|
61
|
+ result.assert_task_error(error_domain=ErrorDomain.ELEMENT, error_reason=None)
|
|
62
|
+ assert "sandbox-bwrap/command-exit-42.bst|Command 'exit 42' failed with exitcode 42" in result.stderr
|