summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index b616759209..1ba180ff0e 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -12,6 +12,7 @@ import os
12import sys 12import sys
13import unittest 13import unittest
14import hashlib 14import hashlib
15import filecmp
15 16
16from glob import glob 17from glob import glob
17from shutil import rmtree, copy 18from shutil import rmtree, copy
@@ -1662,6 +1663,70 @@ class ModifyTests(WicTestCase):
1662 runCmd("wic cp %s:2/etc/fstab %s -n %s" % (images[0], testfile.name, sysroot)) 1663 runCmd("wic cp %s:2/etc/fstab %s -n %s" % (images[0], testfile.name, sysroot))
1663 self.assertTrue(os.stat(testfile.name).st_size > 0, msg="Filesize not as expected %s" % os.stat(testfile.name).st_size) 1664 self.assertTrue(os.stat(testfile.name).st_size > 0, msg="Filesize not as expected %s" % os.stat(testfile.name).st_size)
1664 1665
1666 # prepare directory structure
1667 testdir = os.path.join(self.resultdir, "wic-test-cp-ext-dir")
1668 testsubdir = os.path.join(testdir, "subdir")
1669 os.makedirs(testsubdir)
1670
1671 # add a file in the top-level of the directory
1672 src_file = os.path.join(testdir, "topfile.txt")
1673 with open(src_file, "w") as f:
1674 f.write("top-level\n")
1675
1676 # add file in the subdir
1677 src_subfile = os.path.join(testsubdir, "subfile.txt")
1678 with open(src_subfile, "w") as f:
1679 f.write("sub-level\n")
1680
1681 # copy directory to the partition root
1682 runCmd("wic cp %s %s:2/ -n %s" % (testdir, images[0], sysroot))
1683 basedir = os.path.basename(testdir)
1684
1685 # check if directory is there at partition root
1686 result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot))
1687 root_entries = set(line.split()[-1] for line in result.output.split('\n') if line)
1688 self.assertIn(basedir, root_entries, msg="Expected directory not present at root: %s" % root_entries)
1689
1690 # list INSIDE the copied directory
1691 result = runCmd("wic ls %s:2/%s/ -n %s" % (images[0], basedir, sysroot))
1692 self.assertEqual(0, result.status,
1693 msg="wic ls inside copied directory failed. Output:\n%s" % result.output)
1694 self.assertNotIn("Ext2 inode is not a directory", result.output,
1695 msg="Regression detected (inode not a directory). Output:\n%s" % result.output)
1696
1697 inside_entries = set(line.split()[-1] for line in result.output.split('\n') if line)
1698 self.assertTrue(set(["subdir", "topfile.txt"]).issubset(inside_entries),
1699 msg="Expected entries missing inside dir: %s" % inside_entries)
1700
1701 # list inside the subdir
1702 result = runCmd("wic ls %s:2/%s/subdir/ -n %s" % (images[0], basedir, sysroot))
1703 self.assertEqual(0, result.status,
1704 msg="wic ls inside copied subdir failed. Output:\n%s" % result.output)
1705 self.assertNotIn("Ext2 inode is not a directory", result.output,
1706 msg="Regression detected (inode not a directory). Output:\n%s" % result.output)
1707
1708 sub_entries = set(line.split()[-1] for line in result.output.split('\n') if line)
1709 self.assertIn("subfile.txt", sub_entries, msg="Expected file missing in subdir: %s" % sub_entries)
1710
1711 # copy directory from the partition and compare with original
1712 outparent = os.path.join(self.resultdir, "wic-test-cp-ext-out")
1713 os.makedirs(outparent)
1714 runCmd("wic cp %s:2/%s %s -n %s" % (images[0], basedir, outparent, sysroot))
1715
1716 copied_dir = os.path.join(outparent, basedir)
1717 self.assertTrue(os.path.isdir(copied_dir), msg="Copied-back directory not created: %s" % copied_dir)
1718
1719 copied_file = os.path.join(copied_dir, "topfile.txt")
1720 copied_subfile = os.path.join(copied_dir, "subdir", "subfile.txt")
1721
1722 self.assertTrue(os.path.isfile(copied_file), msg="Missing copied-back file: %s" % copied_file)
1723 self.assertTrue(os.path.isfile(copied_subfile), msg="Missing copied-back subfile: %s" % copied_subfile)
1724
1725 self.assertTrue(filecmp.cmp(src_file, copied_file, shallow=False),
1726 msg="topfile.txt differs after round-trip copy")
1727 self.assertTrue(filecmp.cmp(src_subfile, copied_subfile, shallow=False),
1728 msg="subfile.txt differs after round-trip copy")
1729
1665 1730
1666 def test_wic_rm_ext(self): 1731 def test_wic_rm_ext(self):
1667 """Test removing files from the ext partition.""" 1732 """Test removing files from the ext partition."""