diff options
Diffstat (limited to 'tests/sources/local.py')
-rw-r--r-- | tests/sources/local.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/sources/local.py b/tests/sources/local.py index 94d45b3e9..28ed8f5fc 100644 --- a/tests/sources/local.py +++ b/tests/sources/local.py @@ -4,9 +4,11 @@ import os import pytest +from buildstream import _yaml from buildstream._exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils import filetypegenerator +from tests.testutils.site import HAVE_SANDBOX DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), @@ -158,3 +160,61 @@ def test_stage_directory_symlink(cli, tmpdir, datafiles): assert os.path.exists(os.path.join(checkoutdir, 'subdir', 'anotherfile.txt')) assert os.path.exists(os.path.join(checkoutdir, 'symlink-to-subdir', 'anotherfile.txt')) assert os.path.islink(os.path.join(checkoutdir, 'symlink-to-subdir')) + + +@pytest.mark.integration +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'deterministic-umask')) +@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox') +def test_deterministic_source_umask(cli, tmpdir, datafiles): + + def create_test_file(*path, mode=0o644, content='content\n'): + path = os.path.join(*path) + os.makedirs(os.path.dirname(path), exist_ok=True) + with open(path, 'w') as f: + f.write(content) + os.fchmod(f.fileno(), mode) + + def create_test_directory(*path, mode=0o644): + create_test_file(*path, '.keep', content='') + path = os.path.join(*path) + os.chmod(path, mode) + + project = str(datafiles) + element_name = 'list.bst' + element_path = os.path.join(project, 'elements', element_name) + sourcedir = os.path.join(project, 'source') + + create_test_file(sourcedir, 'a.txt', mode=0o700) + create_test_file(sourcedir, 'b.txt', mode=0o755) + create_test_file(sourcedir, 'c.txt', mode=0o600) + create_test_file(sourcedir, 'd.txt', mode=0o400) + create_test_file(sourcedir, 'e.txt', mode=0o644) + create_test_file(sourcedir, 'f.txt', mode=0o4755) + create_test_file(sourcedir, 'g.txt', mode=0o2755) + create_test_file(sourcedir, 'h.txt', mode=0o1755) + create_test_directory(sourcedir, 'dir-a', mode=0o0700) + create_test_directory(sourcedir, 'dir-c', mode=0o0755) + create_test_directory(sourcedir, 'dir-d', mode=0o4755) + create_test_directory(sourcedir, 'dir-e', mode=0o2755) + create_test_directory(sourcedir, 'dir-f', mode=0o1755) + + source = {'kind': 'local', + 'path': 'source'} + element = { + 'kind': 'manual', + 'depends': [ + { + 'filename': 'base.bst', + 'type': 'build' + } + ], + 'sources': [ + source + ], + 'config': { + 'install-commands': [ + 'ls -l >"%{install-root}/ls-l"' + ] + } + } + _yaml.dump(element, element_path) |