summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-02-27 18:18:22 +0000
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-03-23 14:37:38 +0000
commit7d61e8c1c4cf8d07f17892843ea8d029ad892f05 (patch)
tree7445c15fc1c22c43de7250424585719624951d40 /tests/integration
parentf4d3892e4b7276f25599ce6e9fbae840ab10c833 (diff)
downloadbuildstream-7d61e8c1c4cf8d07f17892843ea8d029ad892f05.tar.gz
Add simple tests of builder UID.
tests/integration/build-uid: Add tests. tests/integration/project/elements/build-uid/build-uid-default.bst: A test for the default uid/gid of 0 in the sandbox. tests/integration/project/elements/build-uid/build-uid.bst: Tests for nonzero uid/gid values supplied in the element. tests/integration/project/elements/build-uid/build-uid-1023.bst: Tests for nonzero uid/gid values supplied in project.conf.
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/build-uid.py64
-rw-r--r--tests/integration/project/elements/build-uid/build-uid-1023.bst9
-rw-r--r--tests/integration/project/elements/build-uid/build-uid-default.bst9
-rw-r--r--tests/integration/project/elements/build-uid/build-uid.bst13
4 files changed, 95 insertions, 0 deletions
diff --git a/tests/integration/build-uid.py b/tests/integration/build-uid.py
new file mode 100644
index 000000000..689430454
--- /dev/null
+++ b/tests/integration/build-uid.py
@@ -0,0 +1,64 @@
+import os
+import pytest
+
+from buildstream import _yaml
+
+from tests.testutils import cli_integration as cli
+from tests.testutils.integration import assert_contains
+from tests.testutils.site import IS_LINUX
+
+
+pytestmark = pytest.mark.integration
+
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "project"
+)
+
+
+@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
+@pytest.mark.datafiles(DATA_DIR)
+def test_build_uid_overridden(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkout = os.path.join(cli.directory, 'checkout')
+ element_name = 'build-uid/build-uid.bst'
+
+ project_config = {
+ 'name': 'build-uid-test',
+ 'sandbox': {
+ 'build-uid': 800,
+ 'build-gid': 900
+ }
+ }
+
+ result = cli.run(project=project, project_config=project_config, args=['build', element_name])
+ assert result.exit_code == 0
+
+
+@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
+@pytest.mark.datafiles(DATA_DIR)
+def test_build_uid_in_project(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkout = os.path.join(cli.directory, 'checkout')
+ element_name = 'build-uid/build-uid-1023.bst'
+
+ project_config = {
+ 'name': 'build-uid-test',
+ 'sandbox': {
+ 'build-uid': 1023,
+ 'build-gid': 3490
+ }
+ }
+
+ result = cli.run(project=project, project_config=project_config, args=['build', element_name])
+ assert result.exit_code == 0
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_build_uid_default(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkout = os.path.join(cli.directory, 'checkout')
+ element_name = 'build-uid/build-uid-default.bst'
+
+ result = cli.run(project=project, args=['build', element_name])
+ assert result.exit_code == 0
diff --git a/tests/integration/project/elements/build-uid/build-uid-1023.bst b/tests/integration/project/elements/build-uid/build-uid-1023.bst
new file mode 100644
index 000000000..9466aa193
--- /dev/null
+++ b/tests/integration/project/elements/build-uid/build-uid-1023.bst
@@ -0,0 +1,9 @@
+kind: manual
+
+depends:
+ - filename: base.bst
+ type: build
+
+config:
+ build-commands:
+ - "[ `id -u` = 1023 -a `id -g` = 3490 ]"
diff --git a/tests/integration/project/elements/build-uid/build-uid-default.bst b/tests/integration/project/elements/build-uid/build-uid-default.bst
new file mode 100644
index 000000000..52f72b89e
--- /dev/null
+++ b/tests/integration/project/elements/build-uid/build-uid-default.bst
@@ -0,0 +1,9 @@
+kind: manual
+
+depends:
+ - filename: base.bst
+ type: build
+
+config:
+ build-commands:
+ - "[ `id -u` = 0 -a `id -g` = 0 ]" \ No newline at end of file
diff --git a/tests/integration/project/elements/build-uid/build-uid.bst b/tests/integration/project/elements/build-uid/build-uid.bst
new file mode 100644
index 000000000..8dc2924bf
--- /dev/null
+++ b/tests/integration/project/elements/build-uid/build-uid.bst
@@ -0,0 +1,13 @@
+kind: manual
+
+depends:
+ - filename: base.bst
+ type: build
+
+sandbox:
+ build-uid: 1024
+ build-gid: 1048
+
+config:
+ build-commands:
+ - "[ `id -u` = 1024 -a `id -g` = 1048 ]"