summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-06-13 14:22:08 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-14 10:18:21 +0100
commitcb416d1feea042bcdedc9f522d588fef2c4929bc (patch)
tree1d03c2aa3e3414745d42d17a689d29717047c68e
parent416e4599960987f0ce31b3f16f3c6af0bf633a26 (diff)
downloadopenembedded-core-contrib-cb416d1feea042bcdedc9f522d588fef2c4929bc.tar.gz
openembedded-core-contrib-cb416d1feea042bcdedc9f522d588fef2c4929bc.tar.bz2
openembedded-core-contrib-cb416d1feea042bcdedc9f522d588fef2c4929bc.zip
selftest: add test_wic_cp test case
Added test case for "wic cp" functionality. - copy file to vfat partition - copy directory to vfat partition Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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
import unittest
from glob import glob
-from shutil import rmtree
+from shutil import rmtree, copy
from functools import wraps, lru_cache
from tempfile import NamedTemporaryFile
@@ -811,3 +811,47 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
self.assertEqual(0, result.status)
self.assertEqual(6, len(result.output.split('\n')))
+
+ def test_wic_cp(self):
+ """Test copy files and directories to the the wic image."""
+ self.assertEqual(0, runCmd("wic create wictestdisk "
+ "--image-name=core-image-minimal "
+ "-D -o %s" % self.resultdir).status)
+ images = glob(self.resultdir + "wictestdisk-*.direct")
+ self.assertEqual(1, len(images))
+
+ sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')
+
+ # list directory content of the first partition
+ result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
+ self.assertEqual(0, result.status)
+ self.assertEqual(6, len(result.output.split('\n')))
+
+ with NamedTemporaryFile("w", suffix=".wic-cp") as testfile:
+ testfile.write("test")
+
+ # copy file to the partition
+ result = runCmd("wic cp %s %s:1/ -n %s" % (testfile.name, images[0], sysroot))
+ self.assertEqual(0, result.status)
+
+ # check if file is there
+ result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
+ self.assertEqual(0, result.status)
+ self.assertEqual(7, len(result.output.split('\n')))
+ self.assertTrue(os.path.basename(testfile.name) in result.output)
+
+ # prepare directory
+ testdir = os.path.join(self.resultdir, 'wic-test-cp-dir')
+ testsubdir = os.path.join(testdir, 'subdir')
+ os.makedirs(os.path.join(testsubdir))
+ copy(testfile.name, testdir)
+
+ # copy directory to the partition
+ result = runCmd("wic cp %s %s:1/ -n %s" % (testdir, images[0], sysroot))
+ self.assertEqual(0, result.status)
+
+ # check if directory is there
+ result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot))
+ self.assertEqual(0, result.status)
+ self.assertEqual(8, len(result.output.split('\n')))
+ self.assertTrue(os.path.basename(testdir) in result.output)