summaryrefslogtreecommitdiff
path: root/tests/frontend
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2019-02-11 18:51:20 +0100
committerValentin David <valentin.david@gmail.com>2019-02-12 18:06:50 +0000
commit478e5c47ac96bbe165c4f2908f48754d4495804c (patch)
tree7e45f077b10db4e825b3aa021991d519895ff670 /tests/frontend
parente51116d5763edd98b9d7397c14c0e83dd432a8f3 (diff)
downloadbuildstream-478e5c47ac96bbe165c4f2908f48754d4495804c.tar.gz
buildstream/_cas/cascache.py: Set 0644 rights to pulled filesvalentindavid/pull-chmod-bug
This was broken by 5ef19a0b31df84caed1e41719ef7ea5c6bd8a8bc.
Diffstat (limited to 'tests/frontend')
-rw-r--r--tests/frontend/pull.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py
index 9579d9f27..2555355d3 100644
--- a/tests/frontend/pull.py
+++ b/tests/frontend/pull.py
@@ -1,5 +1,6 @@
import os
import shutil
+import stat
import pytest
from buildstream.plugintestutils import cli
from tests.testutils import create_artifact_share, generate_junction
@@ -462,3 +463,74 @@ def test_build_remote_option(caplog, cli, tmpdir, datafiles):
assert shareproject.repo not in result.stderr
assert shareuser.repo not in result.stderr
assert sharecli.repo in result.stderr
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_pull_access_rights(caplog, cli, tmpdir, datafiles):
+ project = str(datafiles)
+ checkout = os.path.join(str(tmpdir), 'checkout')
+
+ # Work-around datafiles not preserving mode
+ os.chmod(os.path.join(project, 'files/bin-files/usr/bin/hello'), 0o0755)
+
+ # We need a big file that does not go into a batch to test a different
+ # code path
+ os.makedirs(os.path.join(project, 'files/dev-files/usr/share'), exist_ok=True)
+ with open(os.path.join(project, 'files/dev-files/usr/share/big-file'), 'w') as f:
+ buf = ' ' * 4096
+ for _ in range(1024):
+ f.write(buf)
+
+ with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
+
+ cli.configure({
+ 'artifacts': {'url': share.repo, 'push': True}
+ })
+ result = cli.run(project=project, args=['build', 'compose-all.bst'])
+ result.assert_success()
+
+ result = cli.run(project=project,
+ args=['artifact', 'checkout',
+ '--hardlinks', '--no-integrate',
+ 'compose-all.bst',
+ '--directory', checkout])
+ result.assert_success()
+
+ st = os.lstat(os.path.join(checkout, 'usr/include/pony.h'))
+ assert stat.S_ISREG(st.st_mode)
+ assert stat.S_IMODE(st.st_mode) == 0o0644
+
+ st = os.lstat(os.path.join(checkout, 'usr/bin/hello'))
+ assert stat.S_ISREG(st.st_mode)
+ assert stat.S_IMODE(st.st_mode) == 0o0755
+
+ st = os.lstat(os.path.join(checkout, 'usr/share/big-file'))
+ assert stat.S_ISREG(st.st_mode)
+ assert stat.S_IMODE(st.st_mode) == 0o0644
+
+ shutil.rmtree(checkout)
+
+ artifacts = os.path.join(cli.directory, 'artifacts')
+ shutil.rmtree(artifacts)
+
+ result = cli.run(project=project, args=['artifact', 'pull', 'compose-all.bst'])
+ result.assert_success()
+
+ result = cli.run(project=project,
+ args=['artifact', 'checkout',
+ '--hardlinks', '--no-integrate',
+ 'compose-all.bst',
+ '--directory', checkout])
+ result.assert_success()
+
+ st = os.lstat(os.path.join(checkout, 'usr/include/pony.h'))
+ assert stat.S_ISREG(st.st_mode)
+ assert stat.S_IMODE(st.st_mode) == 0o0644
+
+ st = os.lstat(os.path.join(checkout, 'usr/bin/hello'))
+ assert stat.S_ISREG(st.st_mode)
+ assert stat.S_IMODE(st.st_mode) == 0o0755
+
+ st = os.lstat(os.path.join(checkout, 'usr/share/big-file'))
+ assert stat.S_ISREG(st.st_mode)
+ assert stat.S_IMODE(st.st_mode) == 0o0644