diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2019-02-12 18:38:55 +0100 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2019-02-12 19:26:23 +0100 |
commit | da80724e93acf662fb1b58b9f34918b91911437a (patch) | |
tree | d34ccb4392bb61214ed1d1ba908e75ebb510edb4 /tests/frontend/buildcheckout.py | |
parent | 5f50d3bde19b43852eba724e72e4c581a0e85e9a (diff) | |
download | buildstream-da80724e93acf662fb1b58b9f34918b91911437a.tar.gz |
Deduplicate files in local cache with or without exec rightsvalentindavid/local-cache-exec-leak-2
If we introduce an exact same object with execution rights as existing
file without execution right, we should not expect that the files
suddenly get execution rights. This breaks reproducibility and it is
easy to encounter. For example install an empty file with execution
rights. Or copy files from another artifact and `chmod +x` it.
Diffstat (limited to 'tests/frontend/buildcheckout.py')
-rw-r--r-- | tests/frontend/buildcheckout.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 80d710f6f..4875f0280 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -2,6 +2,8 @@ import os import tarfile import hashlib import pytest +import shutil +import stat import subprocess from tests.testutils.site import IS_WINDOWS from tests.testutils import create_repo, ALL_REPO_KINDS, generate_junction @@ -709,3 +711,34 @@ def test_build_checkout_cross_junction(datafiles, cli, tmpdir): filename = os.path.join(checkout, 'etc', 'animal.conf') assert os.path.exists(filename) + + +@pytest.mark.datafiles(DATA_DIR) +def test_access_rights(datafiles, cli): + project = str(datafiles) + checkout = os.path.join(cli.directory, 'checkout') + + shutil.copyfile(os.path.join(project, 'files', 'bin-files', 'usr', 'bin', 'hello'), + os.path.join(project, 'files', 'bin-files', 'usr', 'bin', 'hello-2')) + os.chmod(os.path.join(project, 'files', 'bin-files', 'usr', 'bin', 'hello'), + 0o0755) + os.chmod(os.path.join(project, 'files', 'bin-files', 'usr', 'bin', 'hello-2'), + 0o0644) + + result = cli.run(project=project, args=['build', 'target.bst']) + result.assert_success() + + checkout_args = ['artifact', 'checkout', 'target.bst', + '--directory', checkout] + + # Now check it out + result = cli.run(project=project, args=checkout_args) + result.assert_success() + + 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', 'bin', 'hello-2')) + assert stat.S_ISREG(st.st_mode) + assert stat.S_IMODE(st.st_mode) == 0o0644 |