Jonathan Maw pushed to branch jonathan/debug-remote-failed-builds at BuildStream / buildstream
Commits:
-
f1aa0974
by Javier Jardón at 2018-10-18T14:13:35Z
-
f1550c8e
by Valentin David at 2018-10-18T16:02:45Z
-
89992cb1
by Jonathan Maw at 2018-10-19T11:50:52Z
-
95c1956d
by Jonathan Maw at 2018-10-19T11:50:53Z
-
07081b6a
by Jonathan Maw at 2018-10-19T11:50:53Z
-
c5a25f8e
by Jonathan Maw at 2018-10-19T11:50:53Z
-
e6482060
by Jonathan Maw at 2018-10-19T11:51:26Z
-
75ebc1b6
by Jonathan Maw at 2018-10-19T11:51:30Z
-
dcf14ebb
by Jonathan Maw at 2018-10-19T11:51:30Z
-
88348218
by Jonathan Maw at 2018-10-19T11:51:30Z
-
d9fecdb4
by Jonathan Maw at 2018-10-19T11:51:30Z
20 changed files:
- NEWS
- buildstream/_artifactcache/artifactcache.py
- buildstream/_context.py
- buildstream/_frontend/app.py
- buildstream/_includes.py
- buildstream/_loader/loadelement.py
- buildstream/_loader/loader.py
- buildstream/_options/optionpool.py
- buildstream/_project.py
- buildstream/element.py
- buildstream/plugins/elements/junction.py
- buildstream/plugins/sources/git.py
- buildstream/sandbox/_mount.py
- buildstream/sandbox/sandbox.py
- buildstream/source.py
- dev-requirements.txt
- + tests/integration/build-tree.py
- + tests/integration/project/elements/build-shell/buildtree.bst
- tests/integration/shell.py
- tests/yaml/yaml.py
Changes:
... | ... | @@ -31,6 +31,15 @@ buildstream 1.3.1 |
31 | 31 |
new the `conf-root` variable to make the process easier. And there has been
|
32 | 32 |
a bug fix to workspaces so they can be build in workspaces too.
|
33 | 33 |
|
34 |
+ o Creating a build shell through the interactive mode or `bst shell --build`
|
|
35 |
+ will now use the cached build tree. It is now *easier* to debug local build
|
|
36 |
+ failures, and *possible* to debug remote build failures.
|
|
37 |
+ |
|
38 |
+ o `bst shell --sysroot` now takes any directory that contains a sysroot,
|
|
39 |
+ instead of just a specially-formatted build-root with a `root` and `scratch`
|
|
40 |
+ subdirectory.
|
|
41 |
+ |
|
42 |
+ |
|
34 | 43 |
=================
|
35 | 44 |
buildstream 1.1.5
|
36 | 45 |
=================
|
... | ... | @@ -19,7 +19,8 @@ |
19 | 19 |
|
20 | 20 |
import os
|
21 | 21 |
import string
|
22 |
-from collections import Mapping, namedtuple
|
|
22 |
+from collections import namedtuple
|
|
23 |
+from collections.abc import Mapping
|
|
23 | 24 |
|
24 | 25 |
from ..types import _KeyStrength
|
25 | 26 |
from .._exceptions import ArtifactError, ImplError, LoadError, LoadErrorReason
|
... | ... | @@ -19,7 +19,8 @@ |
19 | 19 |
|
20 | 20 |
import os
|
21 | 21 |
import datetime
|
22 |
-from collections import deque, Mapping
|
|
22 |
+from collections import deque
|
|
23 |
+from collections.abc import Mapping
|
|
23 | 24 |
from contextlib import contextmanager
|
24 | 25 |
from . import utils
|
25 | 26 |
from . import _cachekey
|
... | ... | @@ -564,18 +564,15 @@ class App(): |
564 | 564 |
" (c)ontinue - Continue queueing jobs as much as possible\n" +
|
565 | 565 |
" (q)uit - Exit after all ongoing jobs complete\n" +
|
566 | 566 |
" (t)erminate - Terminate any ongoing jobs and exit\n" +
|
567 |
- " (r)etry - Retry this job\n")
|
|
567 |
+ " (r)etry - Retry this job\n" +
|
|
568 |
+ " (s)hell - Drop into a shell in the failed build sandbox\n")
|
|
568 | 569 |
if failure.logfile:
|
569 | 570 |
summary += " (l)og - View the full log file\n"
|
570 |
- if failure.sandbox:
|
|
571 |
- summary += " (s)hell - Drop into a shell in the failed build sandbox\n"
|
|
572 | 571 |
summary += "\nPressing ^C will terminate jobs and exit\n"
|
573 | 572 |
|
574 |
- choices = ['continue', 'quit', 'terminate', 'retry']
|
|
573 |
+ choices = ['continue', 'quit', 'terminate', 'retry', 'shell']
|
|
575 | 574 |
if failure.logfile:
|
576 | 575 |
choices += ['log']
|
577 |
- if failure.sandbox:
|
|
578 |
- choices += ['shell']
|
|
579 | 576 |
|
580 | 577 |
choice = ''
|
581 | 578 |
while choice not in ['continue', 'quit', 'terminate', 'retry']:
|
... | ... | @@ -595,10 +592,10 @@ class App(): |
595 | 592 |
# Handle choices which you can come back from
|
596 | 593 |
#
|
597 | 594 |
if choice == 'shell':
|
598 |
- click.echo("\nDropping into an interactive shell in the failed build sandbox\n", err=True)
|
|
595 |
+ click.echo("\nDropping into an interactive shell in the failed build tree\n", err=True)
|
|
599 | 596 |
try:
|
600 | 597 |
prompt = self.shell_prompt(element)
|
601 |
- self.stream.shell(element, Scope.BUILD, prompt, directory=failure.sandbox, isolate=True)
|
|
598 |
+ self.stream.shell(element, Scope.BUILD, prompt, isolate=True)
|
|
602 | 599 |
except BstError as e:
|
603 | 600 |
click.echo("Error while attempting to create interactive shell: {}".format(e), err=True)
|
604 | 601 |
elif choice == 'log':
|
1 | 1 |
import os
|
2 |
-from collections import Mapping
|
|
2 |
+from collections.abc import Mapping
|
|
3 | 3 |
from . import _yaml
|
4 | 4 |
from ._exceptions import LoadError, LoadErrorReason
|
5 | 5 |
|
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 |
# Tristan Van Berkom <tristan vanberkom codethink co uk>
|
19 | 19 |
|
20 | 20 |
# System imports
|
21 |
-from collections import Mapping
|
|
21 |
+from collections.abc import Mapping
|
|
22 | 22 |
|
23 | 23 |
# BuildStream toplevel imports
|
24 | 24 |
from .._exceptions import LoadError, LoadErrorReason
|
... | ... | @@ -19,7 +19,8 @@ |
19 | 19 |
|
20 | 20 |
import os
|
21 | 21 |
from functools import cmp_to_key
|
22 |
-from collections import Mapping, namedtuple
|
|
22 |
+from collections import namedtuple
|
|
23 |
+from collections.abc import Mapping
|
|
23 | 24 |
import tempfile
|
24 | 25 |
import shutil
|
25 | 26 |
|
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 |
# Tristan Van Berkom <tristan vanberkom codethink co uk>
|
19 | 19 |
#
|
20 | 20 |
|
21 |
-from collections import Mapping
|
|
21 |
+from collections.abc import Mapping
|
|
22 | 22 |
import jinja2
|
23 | 23 |
|
24 | 24 |
from .. import _yaml
|
... | ... | @@ -19,7 +19,8 @@ |
19 | 19 |
# Tiago Gomes <tiago gomes codethink co uk>
|
20 | 20 |
|
21 | 21 |
import os
|
22 |
-from collections import Mapping, OrderedDict
|
|
22 |
+from collections import OrderedDict
|
|
23 |
+from collections.abc import Mapping
|
|
23 | 24 |
from pluginbase import PluginBase
|
24 | 25 |
from . import utils
|
25 | 26 |
from . import _cachekey
|
... | ... | @@ -76,7 +76,8 @@ import os |
76 | 76 |
import re
|
77 | 77 |
import stat
|
78 | 78 |
import copy
|
79 |
-from collections import Mapping, OrderedDict
|
|
79 |
+from collections import OrderedDict
|
|
80 |
+from collections.abc import Mapping
|
|
80 | 81 |
from contextlib import contextmanager
|
81 | 82 |
import tempfile
|
82 | 83 |
import shutil
|
... | ... | @@ -1317,7 +1318,9 @@ class Element(Plugin): |
1317 | 1318 |
@contextmanager
|
1318 | 1319 |
def _prepare_sandbox(self, scope, directory, deps='run', integrate=True):
|
1319 | 1320 |
# bst shell and bst checkout require a local sandbox.
|
1320 |
- with self.__sandbox(directory, config=self.__sandbox_config, allow_remote=False) as sandbox:
|
|
1321 |
+ bare_directory = True if directory else False
|
|
1322 |
+ with self.__sandbox(directory, config=self.__sandbox_config, allow_remote=False,
|
|
1323 |
+ bare_directory=True if directory else False) as sandbox:
|
|
1321 | 1324 |
|
1322 | 1325 |
# Configure always comes first, and we need it.
|
1323 | 1326 |
self.configure_sandbox(sandbox)
|
... | ... | @@ -1384,6 +1387,7 @@ class Element(Plugin): |
1384 | 1387 |
# the same filing system as the rest of our cache.
|
1385 | 1388 |
temp_staging_location = os.path.join(self._get_context().artifactdir, "staging_temp")
|
1386 | 1389 |
temp_staging_directory = tempfile.mkdtemp(prefix=temp_staging_location)
|
1390 |
+ import_dir = temp_staging_directory
|
|
1387 | 1391 |
|
1388 | 1392 |
try:
|
1389 | 1393 |
workspace = self._get_workspace()
|
... | ... | @@ -1394,12 +1398,16 @@ class Element(Plugin): |
1394 | 1398 |
with self.timed_activity("Staging local files at {}"
|
1395 | 1399 |
.format(workspace.get_absolute_path())):
|
1396 | 1400 |
workspace.stage(temp_staging_directory)
|
1401 |
+ elif self._cached():
|
|
1402 |
+ # We have a cached buildtree to use, instead
|
|
1403 |
+ artifact_base, _ = self.__extract()
|
|
1404 |
+ import_dir = os.path.join(artifact_base, 'buildtree')
|
|
1397 | 1405 |
else:
|
1398 | 1406 |
# No workspace, stage directly
|
1399 | 1407 |
for source in self.sources():
|
1400 | 1408 |
source._stage(temp_staging_directory)
|
1401 | 1409 |
|
1402 |
- vdirectory.import_files(temp_staging_directory)
|
|
1410 |
+ vdirectory.import_files(import_dir)
|
|
1403 | 1411 |
|
1404 | 1412 |
finally:
|
1405 | 1413 |
# Staging may produce directories with less than 'rwx' permissions
|
... | ... | @@ -1565,10 +1573,6 @@ class Element(Plugin): |
1565 | 1573 |
collect = self.assemble(sandbox)
|
1566 | 1574 |
self.__set_build_result(success=True, description="succeeded")
|
1567 | 1575 |
except BstError as e:
|
1568 |
- # If an error occurred assembling an element in a sandbox,
|
|
1569 |
- # then tack on the sandbox directory to the error
|
|
1570 |
- e.sandbox = rootdir
|
|
1571 |
- |
|
1572 | 1576 |
# If there is a workspace open on this element, it will have
|
1573 | 1577 |
# been mounted for sandbox invocations instead of being staged.
|
1574 | 1578 |
#
|
... | ... | @@ -1682,8 +1686,8 @@ class Element(Plugin): |
1682 | 1686 |
"unable to collect artifact contents"
|
1683 | 1687 |
.format(collect))
|
1684 | 1688 |
|
1685 |
- # Finally cleanup the build dir
|
|
1686 |
- cleanup_rootdir()
|
|
1689 |
+ # Finally cleanup the build dir
|
|
1690 |
+ cleanup_rootdir()
|
|
1687 | 1691 |
|
1688 | 1692 |
return artifact_size
|
1689 | 1693 |
|
... | ... | @@ -2151,12 +2155,14 @@ class Element(Plugin): |
2151 | 2155 |
# stderr (fileobject): The stream for stderr for the sandbox
|
2152 | 2156 |
# config (SandboxConfig): The SandboxConfig object
|
2153 | 2157 |
# allow_remote (bool): Whether the sandbox is allowed to be remote
|
2158 |
+ # bare_directory (bool): Whether the directory is bare i.e. doesn't have
|
|
2159 |
+ # a separate 'root' subdir
|
|
2154 | 2160 |
#
|
2155 | 2161 |
# Yields:
|
2156 | 2162 |
# (Sandbox): A usable sandbox
|
2157 | 2163 |
#
|
2158 | 2164 |
@contextmanager
|
2159 |
- def __sandbox(self, directory, stdout=None, stderr=None, config=None, allow_remote=True):
|
|
2165 |
+ def __sandbox(self, directory, stdout=None, stderr=None, config=None, allow_remote=True, bare_directory=False):
|
|
2160 | 2166 |
context = self._get_context()
|
2161 | 2167 |
project = self._get_project()
|
2162 | 2168 |
platform = Platform.get_platform()
|
... | ... | @@ -2187,6 +2193,7 @@ class Element(Plugin): |
2187 | 2193 |
stdout=stdout,
|
2188 | 2194 |
stderr=stderr,
|
2189 | 2195 |
config=config,
|
2196 |
+ bare_directory=bare_directory,
|
|
2190 | 2197 |
allow_real_directory=not self.BST_VIRTUAL_DIRECTORY)
|
2191 | 2198 |
yield sandbox
|
2192 | 2199 |
|
... | ... | @@ -2196,7 +2203,7 @@ class Element(Plugin): |
2196 | 2203 |
|
2197 | 2204 |
# Recursive contextmanager...
|
2198 | 2205 |
with self.__sandbox(rootdir, stdout=stdout, stderr=stderr, config=config,
|
2199 |
- allow_remote=allow_remote) as sandbox:
|
|
2206 |
+ allow_remote=allow_remote, bare_directory=False) as sandbox:
|
|
2200 | 2207 |
yield sandbox
|
2201 | 2208 |
|
2202 | 2209 |
# Cleanup the build dir
|
... | ... | @@ -124,7 +124,7 @@ the user to resolve possibly conflicting nested junctions by creating a junction |
124 | 124 |
with the same name in the top-level project, which then takes precedence.
|
125 | 125 |
"""
|
126 | 126 |
|
127 |
-from collections import Mapping
|
|
127 |
+from collections.abc import Mapping
|
|
128 | 128 |
from buildstream import Element
|
129 | 129 |
from buildstream._pipeline import PipelineError
|
130 | 130 |
|
... | ... | @@ -89,7 +89,7 @@ import os |
89 | 89 |
import errno
|
90 | 90 |
import re
|
91 | 91 |
import shutil
|
92 |
-from collections import Mapping
|
|
92 |
+from collections.abc import Mapping
|
|
93 | 93 |
from io import StringIO
|
94 | 94 |
|
95 | 95 |
from configparser import RawConfigParser
|
... | ... | @@ -31,7 +31,6 @@ from .._fuse import SafeHardlinks |
31 | 31 |
#
|
32 | 32 |
class Mount():
|
33 | 33 |
def __init__(self, sandbox, mount_point, safe_hardlinks, fuse_mount_options={}):
|
34 |
- scratch_directory = sandbox._get_scratch_directory()
|
|
35 | 34 |
# Getting _get_underlying_directory() here is acceptable as
|
36 | 35 |
# we're part of the sandbox code. This will fail if our
|
37 | 36 |
# directory is CAS-based.
|
... | ... | @@ -51,6 +50,7 @@ class Mount(): |
51 | 50 |
# a regular mount point within the parent's redirected mount.
|
52 | 51 |
#
|
53 | 52 |
if self.safe_hardlinks:
|
53 |
+ scratch_directory = sandbox._get_scratch_directory()
|
|
54 | 54 |
# Redirected mount
|
55 | 55 |
self.mount_origin = os.path.join(root_directory, mount_point.lstrip(os.sep))
|
56 | 56 |
self.mount_base = os.path.join(scratch_directory, utils.url_directory_name(mount_point))
|
... | ... | @@ -98,16 +98,23 @@ class Sandbox(): |
98 | 98 |
self.__config = kwargs['config']
|
99 | 99 |
self.__stdout = kwargs['stdout']
|
100 | 100 |
self.__stderr = kwargs['stderr']
|
101 |
+ self.__bare_directory = kwargs['bare_directory']
|
|
101 | 102 |
|
102 | 103 |
# Setup the directories. Root and output_directory should be
|
103 | 104 |
# available to subclasses, hence being single-underscore. The
|
104 | 105 |
# others are private to this class.
|
105 |
- self._root = os.path.join(directory, 'root')
|
|
106 |
+ # If the directory is bare, it probably doesn't need scratch
|
|
107 |
+ if self.__bare_directory:
|
|
108 |
+ self._root = directory
|
|
109 |
+ self.__scratch = None
|
|
110 |
+ os.makedirs(self._root, exist_ok=True)
|
|
111 |
+ else:
|
|
112 |
+ self._root = os.path.join(directory, 'root')
|
|
113 |
+ self.__scratch = os.path.join(directory, 'scratch')
|
|
114 |
+ for directory_ in [self._root, self.__scratch]:
|
|
115 |
+ os.makedirs(directory_, exist_ok=True)
|
|
116 |
+ |
|
106 | 117 |
self._output_directory = None
|
107 |
- self.__directory = directory
|
|
108 |
- self.__scratch = os.path.join(self.__directory, 'scratch')
|
|
109 |
- for directory_ in [self._root, self.__scratch]:
|
|
110 |
- os.makedirs(directory_, exist_ok=True)
|
|
111 | 118 |
self._vdir = None
|
112 | 119 |
|
113 | 120 |
# This is set if anyone requests access to the underlying
|
... | ... | @@ -334,6 +341,7 @@ class Sandbox(): |
334 | 341 |
# Returns:
|
335 | 342 |
# (str): The sandbox scratch directory
|
336 | 343 |
def _get_scratch_directory(self):
|
344 |
+ assert not self.__bare_directory, "Scratch is not going to work with bare directories"
|
|
337 | 345 |
return self.__scratch
|
338 | 346 |
|
339 | 347 |
# _get_output()
|
... | ... | @@ -155,7 +155,7 @@ Class Reference |
155 | 155 |
"""
|
156 | 156 |
|
157 | 157 |
import os
|
158 |
-from collections import Mapping
|
|
158 |
+from collections.abc import Mapping
|
|
159 | 159 |
from contextlib import contextmanager
|
160 | 160 |
|
161 | 161 |
from . import Plugin, Consistency
|
... | ... | @@ -9,3 +9,4 @@ pytest-pep8 |
9 | 9 |
pytest-pylint
|
10 | 10 |
pytest-xdist
|
11 | 11 |
pytest-timeout
|
12 |
+pexpect
|
1 |
+import os
|
|
2 |
+import pytest
|
|
3 |
+import shutil
|
|
4 |
+import pexpect
|
|
5 |
+ |
|
6 |
+from tests.testutils import cli, cli_integration, create_artifact_share
|
|
7 |
+ |
|
8 |
+ |
|
9 |
+pytestmark = pytest.mark.integration
|
|
10 |
+ |
|
11 |
+ |
|
12 |
+DATA_DIR = os.path.join(
|
|
13 |
+ os.path.dirname(os.path.realpath(__file__)),
|
|
14 |
+ "project"
|
|
15 |
+)
|
|
16 |
+ |
|
17 |
+ |
|
18 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
19 |
+def test_buildtree_staged(cli_integration, tmpdir, datafiles):
|
|
20 |
+ # i.e. tests that cached build trees are staged by `bst shell --build`
|
|
21 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
22 |
+ element_name = 'build-shell/buildtree.bst'
|
|
23 |
+ |
|
24 |
+ res = cli_integration.run(project=project, args=['build', element_name])
|
|
25 |
+ res.assert_success()
|
|
26 |
+ |
|
27 |
+ res = cli_integration.run(project=project, args=[
|
|
28 |
+ 'shell', '--build', element_name, '--', 'grep', '-q', 'Hi', 'test'
|
|
29 |
+ ])
|
|
30 |
+ res.assert_success()
|
|
31 |
+ |
|
32 |
+ |
|
33 |
+# Check that a failed build causes a shell that stages the buildtree
|
|
34 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
35 |
+def test_buildtree_staged_interactive(cli_integration, tmpdir, datafiles):
|
|
36 |
+ # i.e. tests that cached build trees are staged by `bst shell --build`
|
|
37 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
38 |
+ element_name = 'build-shell/buildtree-fail.bst'
|
|
39 |
+ |
|
40 |
+ # Start an interactive session and intercept the interactive prompt
|
|
41 |
+ child = pexpect.spawn('bst', ['--no-colors', 'build', element_name], cwd=project)
|
|
42 |
+ |
|
43 |
+ # Ensure starting a shell is a valid option
|
|
44 |
+ child.expect('\(s\)hell')
|
|
45 |
+ |
|
46 |
+ # Wait for the interactive prompt
|
|
47 |
+ child.expect('Choice: \[continue\]:')
|
|
48 |
+ |
|
49 |
+ # Start a shell and wait for the shell's prompt
|
|
50 |
+ child.sendline('s')
|
|
51 |
+ child.expect('\]\$')
|
|
52 |
+ |
|
53 |
+ # Read the contents of the file we added
|
|
54 |
+ child.sendline('cat test')
|
|
55 |
+ child.expect('Hi')
|
|
56 |
+ |
|
57 |
+ |
|
58 |
+# Check that build shells work when pulled from a remote cache
|
|
59 |
+# This is to roughly simulate remote execution
|
|
60 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
61 |
+def test_buildtree_pulled(cli, tmpdir, datafiles):
|
|
62 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
63 |
+ element_name = 'build-shell/buildtree.bst'
|
|
64 |
+ |
|
65 |
+ with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
|
|
66 |
+ # Build the element to push it to cache
|
|
67 |
+ cli.configure({
|
|
68 |
+ 'artifacts': {'url': share.repo, 'push': True}
|
|
69 |
+ })
|
|
70 |
+ result = cli.run(project=project, args=['build', element_name])
|
|
71 |
+ result.assert_success()
|
|
72 |
+ assert cli.get_element_state(project, element_name) == 'cached'
|
|
73 |
+ |
|
74 |
+ # Discard the cache
|
|
75 |
+ cli.configure({
|
|
76 |
+ 'artifacts': {'url': share.repo, 'push': True},
|
|
77 |
+ 'artifactdir': os.path.join(cli.directory, 'artifacts2')
|
|
78 |
+ })
|
|
79 |
+ assert cli.get_element_state(project, element_name) != 'cached'
|
|
80 |
+ |
|
81 |
+ # Pull from cache
|
|
82 |
+ result = cli.run(project=project, args=['pull', '--deps', 'all', element_name])
|
|
83 |
+ result.assert_success()
|
|
84 |
+ |
|
85 |
+ # Check it's using the cached build tree
|
|
86 |
+ res = cli.run(project=project, args=[
|
|
87 |
+ 'shell', '--build', element_name, '--', 'grep', '-q', 'Hi', 'test'
|
|
88 |
+ ])
|
|
89 |
+ res.assert_success()
|
1 |
+kind: manual
|
|
2 |
+description: |
|
|
3 |
+ Puts a file in the build tree so that build tree caching and staging can be tested.
|
|
4 |
+ |
|
5 |
+depends:
|
|
6 |
+ - filename: base.bst
|
|
7 |
+ type: build
|
|
8 |
+ |
|
9 |
+config:
|
|
10 |
+ build-commands:
|
|
11 |
+ - "echo 'Hi' > %{build-root}/test"
|
... | ... | @@ -302,46 +302,33 @@ def test_workspace_visible(cli, tmpdir, datafiles): |
302 | 302 |
assert result.output == workspace_hello
|
303 | 303 |
|
304 | 304 |
|
305 |
-# Test that we can see the workspace files in a shell
|
|
306 |
-@pytest.mark.integration
|
|
305 |
+# Test that '--sysroot' works
|
|
307 | 306 |
@pytest.mark.datafiles(DATA_DIR)
|
308 |
-def test_sysroot_workspace_visible(cli, tmpdir, datafiles):
|
|
307 |
+def test_sysroot(cli, tmpdir, datafiles):
|
|
309 | 308 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
310 |
- workspace = os.path.join(cli.directory, 'workspace')
|
|
311 |
- element_name = 'workspace/workspace-mount-fail.bst'
|
|
312 |
- |
|
313 |
- # Open a workspace on our build failing element
|
|
314 |
- #
|
|
315 |
- res = cli.run(project=project, args=['workspace', 'open', element_name, workspace])
|
|
316 |
- assert res.exit_code == 0
|
|
317 |
- |
|
318 |
- # Ensure the dependencies of our build failing element are built
|
|
319 |
- result = cli.run(project=project, args=['build', element_name])
|
|
320 |
- result.assert_main_error(ErrorDomain.STREAM, None)
|
|
321 |
- |
|
322 |
- # Discover the sysroot of the failed build directory, after one
|
|
323 |
- # failed build, there should be only one directory there.
|
|
324 |
- #
|
|
325 |
- build_base = os.path.join(cli.directory, 'build')
|
|
326 |
- build_dirs = os.listdir(path=build_base)
|
|
327 |
- assert len(build_dirs) == 1
|
|
328 |
- build_dir = os.path.join(build_base, build_dirs[0])
|
|
329 |
- |
|
330 |
- # Obtain a copy of the hello.c content from the workspace
|
|
331 |
- #
|
|
332 |
- workspace_hello_path = os.path.join(cli.directory, 'workspace', 'hello.c')
|
|
333 |
- assert os.path.exists(workspace_hello_path)
|
|
334 |
- with open(workspace_hello_path, 'r') as f:
|
|
335 |
- workspace_hello = f.read()
|
|
336 |
- |
|
337 |
- # Cat the hello.c file from a bst shell command, and assert
|
|
338 |
- # that we got the same content here
|
|
339 |
- #
|
|
340 |
- result = cli.run(project=project, args=[
|
|
341 |
- 'shell', '--build', '--sysroot', build_dir, element_name, '--', 'cat', 'hello.c'
|
|
309 |
+ base_element = "base/base-alpine.bst"
|
|
310 |
+ # test element only needs to be something lightweight for this test
|
|
311 |
+ test_element = "script/script.bst"
|
|
312 |
+ checkout_dir = os.path.join(str(tmpdir), 'alpine-sysroot')
|
|
313 |
+ test_file = 'hello'
|
|
314 |
+ |
|
315 |
+ # Build and check out a sysroot
|
|
316 |
+ res = cli.run(project=project, args=['build', base_element])
|
|
317 |
+ res.assert_success()
|
|
318 |
+ res = cli.run(project=project, args=['checkout', base_element, checkout_dir])
|
|
319 |
+ res.assert_success()
|
|
320 |
+ |
|
321 |
+ # Mutate the sysroot
|
|
322 |
+ test_path = os.path.join(checkout_dir, test_file)
|
|
323 |
+ with open(test_path, 'w') as f:
|
|
324 |
+ f.write('hello\n')
|
|
325 |
+ |
|
326 |
+ # Shell into the sysroot and check the test file exists
|
|
327 |
+ res = cli.run(project=project, args=[
|
|
328 |
+ 'shell', '--build', '--sysroot', checkout_dir, test_element, '--',
|
|
329 |
+ 'grep', '-q', 'hello', '/' + test_file
|
|
342 | 330 |
])
|
343 |
- assert result.exit_code == 0
|
|
344 |
- assert result.output == workspace_hello
|
|
331 |
+ res.assert_success()
|
|
345 | 332 |
|
346 | 333 |
|
347 | 334 |
# Test system integration commands can access devices in /dev
|
1 | 1 |
import os
|
2 | 2 |
import pytest
|
3 | 3 |
import tempfile
|
4 |
-from collections import Mapping
|
|
4 |
+from collections.abc import Mapping
|
|
5 | 5 |
|
6 | 6 |
from buildstream import _yaml
|
7 | 7 |
from buildstream._exceptions import LoadError, LoadErrorReason
|