test/assembler: verify the tar'ed content
In the test case for the tar assembler, actually verify the content by un-tar-ing the result again and comparing it to the tree. This would have spotted missing SELinux labels.
This commit is contained in:
parent
920f46880b
commit
89c3df8de4
1 changed files with 20 additions and 1 deletions
|
|
@ -207,6 +207,7 @@ class TestAssemblers(test.TestBase):
|
||||||
with loop_open(loctl, target, offset=start, size=size) as dev:
|
with loop_open(loctl, target, offset=start, size=size) as dev:
|
||||||
self.assertFilesystem(dev, options["root_fs_uuid"], fs_type, tree)
|
self.assertFilesystem(dev, options["root_fs_uuid"], fs_type, tree)
|
||||||
|
|
||||||
|
@unittest.skipUnless(test.TestBase.have_tree_diff(), "tree-diff missing")
|
||||||
def test_tar(self):
|
def test_tar(self):
|
||||||
cases = [
|
cases = [
|
||||||
("tree.tar.gz", None, ["application/x-tar"]),
|
("tree.tar.gz", None, ["application/x-tar"]),
|
||||||
|
|
@ -220,11 +221,29 @@ class TestAssemblers(test.TestBase):
|
||||||
with self.run_assembler(osb,
|
with self.run_assembler(osb,
|
||||||
"org.osbuild.tar",
|
"org.osbuild.tar",
|
||||||
options,
|
options,
|
||||||
filename) as (_, image):
|
filename) as (tree, image):
|
||||||
output = subprocess.check_output(["file", "--mime-type", image], encoding="utf-8")
|
output = subprocess.check_output(["file", "--mime-type", image], encoding="utf-8")
|
||||||
_, mimetype = output.strip().split(": ") # "filename: mimetype"
|
_, mimetype = output.strip().split(": ") # "filename: mimetype"
|
||||||
self.assertIn(mimetype, expected_mimetypes)
|
self.assertIn(mimetype, expected_mimetypes)
|
||||||
|
|
||||||
|
if compression:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# In the non-compression case, we verify the tree's content
|
||||||
|
with tempfile.TemporaryDirectory(dir="/var/tmp") as tmp:
|
||||||
|
args = [
|
||||||
|
"tar",
|
||||||
|
"--numeric-owner",
|
||||||
|
"--selinux",
|
||||||
|
"--acls",
|
||||||
|
"--xattrs", "--xattrs-include", "*",
|
||||||
|
"-xaf", image,
|
||||||
|
"-C", tmp]
|
||||||
|
subprocess.check_output(args, encoding="utf-8")
|
||||||
|
diff = self.tree_diff(tree, tmp)
|
||||||
|
self.assertEqual(diff["added_files"], [])
|
||||||
|
self.assertEqual(diff["deleted_files"], [])
|
||||||
|
self.assertEqual(diff["differences"], {})
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def loop_create_device(ctl, fd, offset=None, sizelimit=None):
|
def loop_create_device(ctl, fd, offset=None, sizelimit=None):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue