diff options
author | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-07-05 14:16:34 +0100 |
---|---|---|
committer | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-07-05 14:16:34 +0100 |
commit | 5d1009b0af1d30584708ffdd5192408106ae6ede (patch) | |
tree | 0e696df1c097c82accb42e20c71610b1e37444ab /tests/integration | |
parent | 8c82f22f2bdbcbb623d24d80d2e72070e03e2080 (diff) | |
parent | af993bbb5319cc0568695b9f3ea26b738ef6f76f (diff) | |
download | buildstream-5d1009b0af1d30584708ffdd5192408106ae6ede.tar.gz |
Merge branch 'jmac/virtual_directories' into jmac/googlecas_and_virtual_directories_3jmac/googlecas_and_virtual_directories_3
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/make.py | 47 | ||||
-rw-r--r-- | tests/integration/project/elements/make/makehello.bst | 10 | ||||
-rw-r--r-- | tests/integration/project/elements/sandbox-bwrap/base-with-tmp.bst | 6 | ||||
-rw-r--r-- | tests/integration/project/elements/sandbox-bwrap/test-cleanup.bst | 13 | ||||
-rw-r--r-- | tests/integration/project/files/base-with-tmp/tmp/dummy | 1 | ||||
-rw-r--r-- | tests/integration/project/files/makehello.tar.gz | bin | 0 -> 432 bytes | |||
-rw-r--r-- | tests/integration/sandbox-bwrap.py | 31 |
7 files changed, 108 insertions, 0 deletions
diff --git a/tests/integration/make.py b/tests/integration/make.py new file mode 100644 index 000000000..6928cfdc2 --- /dev/null +++ b/tests/integration/make.py @@ -0,0 +1,47 @@ +import os +import pytest + +from tests.testutils import cli_integration as cli +from tests.testutils.integration import assert_contains + + +pytestmark = pytest.mark.integration + + +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "project" +) + + +# Test that a make build 'works' - we use the make sample +# makehello project for this. +@pytest.mark.integration +@pytest.mark.datafiles(DATA_DIR) +def test_make_build(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + checkout = os.path.join(cli.directory, 'checkout') + element_name = 'make/makehello.bst' + + result = cli.run(project=project, args=['build', element_name]) + assert result.exit_code == 0 + + result = cli.run(project=project, args=['checkout', element_name, checkout]) + assert result.exit_code == 0 + + assert_contains(checkout, ['/usr', '/usr/bin', + '/usr/bin/hello']) + + +# Test running an executable built with make +@pytest.mark.datafiles(DATA_DIR) +def test_make_run(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + element_name = 'make/makehello.bst' + + result = cli.run(project=project, args=['build', element_name]) + assert result.exit_code == 0 + + result = cli.run(project=project, args=['shell', element_name, '/usr/bin/hello']) + assert result.exit_code == 0 + assert result.output == 'Hello, world\n' diff --git a/tests/integration/project/elements/make/makehello.bst b/tests/integration/project/elements/make/makehello.bst new file mode 100644 index 000000000..4b5c5ac3b --- /dev/null +++ b/tests/integration/project/elements/make/makehello.bst @@ -0,0 +1,10 @@ +kind: make +description: make test + +depends: +- base.bst + +sources: +- kind: tar + url: project_dir:/files/makehello.tar.gz + ref: fd342a36503a0a0dd37b81ddb4d2b78bd398d912d813339e0de44a6b6c393b8e diff --git a/tests/integration/project/elements/sandbox-bwrap/base-with-tmp.bst b/tests/integration/project/elements/sandbox-bwrap/base-with-tmp.bst new file mode 100644 index 000000000..5c9fa6083 --- /dev/null +++ b/tests/integration/project/elements/sandbox-bwrap/base-with-tmp.bst @@ -0,0 +1,6 @@ +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/test-cleanup.bst b/tests/integration/project/elements/sandbox-bwrap/test-cleanup.bst new file mode 100644 index 000000000..2a89dd3ee --- /dev/null +++ b/tests/integration/project/elements/sandbox-bwrap/test-cleanup.bst @@ -0,0 +1,13 @@ +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/project/files/base-with-tmp/tmp/dummy b/tests/integration/project/files/base-with-tmp/tmp/dummy new file mode 100644 index 000000000..d18f28449 --- /dev/null +++ b/tests/integration/project/files/base-with-tmp/tmp/dummy @@ -0,0 +1 @@ +dummy!
\ No newline at end of file diff --git a/tests/integration/project/files/makehello.tar.gz b/tests/integration/project/files/makehello.tar.gz Binary files differnew file mode 100644 index 000000000..d0edcb29c --- /dev/null +++ b/tests/integration/project/files/makehello.tar.gz diff --git a/tests/integration/sandbox-bwrap.py b/tests/integration/sandbox-bwrap.py new file mode 100644 index 000000000..7d2a18498 --- /dev/null +++ b/tests/integration/sandbox-bwrap.py @@ -0,0 +1,31 @@ +import os +import pytest + +from tests.testutils import cli_integration as cli +from tests.testutils.integration import assert_contains +from tests.testutils.site import HAVE_BWRAP + + +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.integration +@pytest.mark.skipif(not HAVE_BWRAP, reason='Only available with bubblewrap') +@pytest.mark.datafiles(DATA_DIR) +def test_sandbox_bwrap_cleanup_build(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + # 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 |