summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-11-17 17:28:17 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-11-17 17:28:17 +0900
commit1e9207723ad5ad56731bd23eb696dfaf6e8af593 (patch)
tree741dcdb4412a449cd34e29763fa4a2ef4bfb6290
parent0c8b7b49eca1488e9dfd923275dff3b74a1d5383 (diff)
downloadbuildstream-1e9207723ad5ad56731bd23eb696dfaf6e8af593.tar.gz
tests/sources/tar.py: Test for tarballs containing links
This reproduces issue #155
-rw-r--r--tests/sources/tar.py36
-rw-r--r--tests/sources/tar/contains-links/content/base-directory/subdir1/file.txt1
-rw-r--r--tests/sources/tar/contains-links/target.bst6
3 files changed, 43 insertions, 0 deletions
diff --git a/tests/sources/tar.py b/tests/sources/tar.py
index f3f90d0f2..07d44be9e 100644
--- a/tests/sources/tar.py
+++ b/tests/sources/tar.py
@@ -185,3 +185,39 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles, srcdir):
original_contents = _list_dir_contents(original_dir)
checkout_contents = _list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
+
+
+# Test that we succeed to extract tarballs with hardlinks when stripping the
+# leading paths
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'contains-links'))
+def test_stage_contains_links(cli, tmpdir, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ generate_project(project, tmpdir)
+ checkoutdir = os.path.join(str(tmpdir), "checkout")
+
+ # Create a local tar
+ src_tar = os.path.join(str(tmpdir), "a.tar.gz")
+
+ # Create a hardlink, we wont trust git to store that info for us
+ os.makedirs(os.path.join(str(datafiles), "content", "base-directory", "subdir2"), exist_ok=True)
+ file1 = os.path.join(str(datafiles), "content", "base-directory", "subdir1", "file.txt")
+ file2 = os.path.join(str(datafiles), "content", "base-directory", "subdir2", "file.txt")
+ os.link(file1, file2)
+
+ _assemble_tar(os.path.join(str(datafiles), "content"), "base-directory", src_tar)
+
+ # Track, fetch, build, checkout
+ result = cli.run(project=project, args=['track', 'target.bst'])
+ assert result.exit_code == 0
+ result = cli.run(project=project, args=['fetch', 'target.bst'])
+ assert result.exit_code == 0
+ result = cli.run(project=project, args=['build', 'target.bst'])
+ assert result.exit_code == 0
+ result = cli.run(project=project, args=['checkout', 'target.bst', checkoutdir])
+ assert result.exit_code == 0
+
+ # Check that the content of the first directory is checked out (base-dir: '*')
+ original_dir = os.path.join(str(datafiles), "content", "base-directory")
+ original_contents = _list_dir_contents(original_dir)
+ checkout_contents = _list_dir_contents(checkoutdir)
+ assert(checkout_contents == original_contents)
diff --git a/tests/sources/tar/contains-links/content/base-directory/subdir1/file.txt b/tests/sources/tar/contains-links/content/base-directory/subdir1/file.txt
new file mode 100644
index 000000000..f62144808
--- /dev/null
+++ b/tests/sources/tar/contains-links/content/base-directory/subdir1/file.txt
@@ -0,0 +1 @@
+pony
diff --git a/tests/sources/tar/contains-links/target.bst b/tests/sources/tar/contains-links/target.bst
new file mode 100644
index 000000000..ad413a2f4
--- /dev/null
+++ b/tests/sources/tar/contains-links/target.bst
@@ -0,0 +1,6 @@
+kind: import
+description: The kind of this element is irrelevant.
+sources:
+- kind: tar
+ url: tmpdir:/a.tar.gz
+ ref: foo