diff options
| author | Dragomir, Daniel <daniel.dragomir@windriver.com> | 2026-01-28 16:35:47 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2026-02-27 17:45:06 +0000 |
| commit | 77f60c11655b0a5b74f7407e3cd57dba3bf201e3 (patch) | |
| tree | d8149d6b91916be394a989ac0517476b0f23d6c6 /meta | |
| parent | 6c2a243d6cfb8277324904ab6b29e4e69ef68e21 (diff) | |
| download | poky-77f60c11655b0a5b74f7407e3cd57dba3bf201e3.tar.gz | |
oeqa/selftest/wic: test recursive dir copy on ext partitions
Extend the wic selftests to cover recursive directory copying
into ext partitions.
Previously, copying a directory into an ext partition could
appear to succeed, but attempting to access the directory
contents would fail with:
-l: Ext2 inode is not a directory
This was fixed in commit 4fc3b42774 ("wic/engine: fix copying
directories into wic image with ext* partition").
This test now verifies that directories copied with "wic cp"
into an ext4 partition:
- are created with correct inode types
- can be listed recursively with "wic ls"
- preserve files and subdirectories
- can be copied back out of the image without data loss
A simple directory structure is used in this test:
wic-test-cp-ext-dir/
├── topfile.txt
└── subdir/
└── subfile.txt
(From OE-Core rev: 1e051c02bc05367d6b911ac9486403029f6f7cd8)
Signed-off-by: Daniel Dragomir <daniel.dragomir@windriver.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 6de3d2602f4f4a8192d6a6040e89e814187dcf93)
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Paul Barker <paul@pbarker.dev>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/wic.py | 65 |
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 | |||
| 12 | import sys | 12 | import sys |
| 13 | import unittest | 13 | import unittest |
| 14 | import hashlib | 14 | import hashlib |
| 15 | import filecmp | ||
| 15 | 16 | ||
| 16 | from glob import glob | 17 | from glob import glob |
| 17 | from shutil import rmtree, copy | 18 | from 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.""" |
