summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 5d67395889..5034587429 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -28,7 +28,7 @@ import sys
28import unittest 28import unittest
29 29
30from glob import glob 30from glob import glob
31from shutil import rmtree 31from shutil import rmtree, copy
32from functools import wraps, lru_cache 32from functools import wraps, lru_cache
33from tempfile import NamedTemporaryFile 33from tempfile import NamedTemporaryFile
34 34
@@ -811,3 +811,47 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
811 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) 811 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
812 self.assertEqual(0, result.status) 812 self.assertEqual(0, result.status)
813 self.assertEqual(6, len(result.output.split('\n'))) 813 self.assertEqual(6, len(result.output.split('\n')))
814
815 def test_wic_cp(self):
816 """Test copy files and directories to the the wic image."""
817 self.assertEqual(0, runCmd("wic create wictestdisk "
818 "--image-name=core-image-minimal "
819 "-D -o %s" % self.resultdir).status)
820 images = glob(self.resultdir + "wictestdisk-*.direct")
821 self.assertEqual(1, len(images))
822
823 sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')
824
825 # list directory content of the first partition
826 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
827 self.assertEqual(0, result.status)
828 self.assertEqual(6, len(result.output.split('\n')))
829
830 with NamedTemporaryFile("w", suffix=".wic-cp") as testfile:
831 testfile.write("test")
832
833 # copy file to the partition
834 result = runCmd("wic cp %s %s:1/ -n %s" % (testfile.name, images[0], sysroot))
835 self.assertEqual(0, result.status)
836
837 # check if file is there
838 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
839 self.assertEqual(0, result.status)
840 self.assertEqual(7, len(result.output.split('\n')))
841 self.assertTrue(os.path.basename(testfile.name) in result.output)
842
843 # prepare directory
844 testdir = os.path.join(self.resultdir, 'wic-test-cp-dir')
845 testsubdir = os.path.join(testdir, 'subdir')
846 os.makedirs(os.path.join(testsubdir))
847 copy(testfile.name, testdir)
848
849 # copy directory to the partition
850 result = runCmd("wic cp %s %s:1/ -n %s" % (testdir, images[0], sysroot))
851 self.assertEqual(0, result.status)
852
853 # check if directory is there
854 result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
855 self.assertEqual(0, result.status)
856 self.assertEqual(8, len(result.output.split('\n')))
857 self.assertTrue(os.path.basename(testdir) in result.output)