oe-selftest: test wic sparse_copy API

Added new parameter 'api' to sparse_copy function to specify
underlying filemap API to use. By default sparse_copy will
try both available APIs.

Added test case for sparse_copy to wic test suite.

(From OE-Core rev: 88701cef6ba399e82f96ed1b0eef9a44ed8c1687)

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ed Bartosh
2017-04-06 14:58:49 +03:00
committed by Richard Purdie
parent 7792688ac2
commit 8838dd2dbd
2 changed files with 33 additions and 2 deletions

View File

@@ -530,9 +530,11 @@ def filemap(image, log=None):
except ErrorNotSupp:
return FilemapSeek(image, log)
def sparse_copy(src_fname, dst_fname, offset=0, skip=0):
def sparse_copy(src_fname, dst_fname, offset=0, skip=0, api=None):
"""Efficiently copy sparse file to or into another file."""
fmap = filemap(src_fname)
if not api:
api = filemap
fmap = api(src_fname)
try:
dst_file = open(dst_fname, 'r+b')
except IOError: