summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/containerimage.py
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2017-05-12 14:40:21 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-06 19:02:43 +0100
commit157c3be2ca93f076033f725ec1ee912df91f7488 (patch)
tree8ef896ff7adf78d63b34059cd5b017a4f0a3419a /meta/lib/oeqa/selftest/cases/containerimage.py
parent10c512b60d1167122b5fe778b93838dca3def717 (diff)
downloadpoky-157c3be2ca93f076033f725ec1ee912df91f7488.tar.gz
oeqa/selftest/cases: Migrate test cases into the new oe-qa framework
New framework has different classes/decorators so adapt current test cases to support these. Changes include changes on base classes and decorators. Also include paths in selftest/__init__.py isn't needed because the loader is the standard unittest one. (From OE-Core rev: ddbbefdd124604d10bd47dd0266b55a764fcc0ab) Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/containerimage.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/containerimage.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/containerimage.py b/meta/lib/oeqa/selftest/cases/containerimage.py
new file mode 100644
index 0000000000..73162fa600
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/containerimage.py
@@ -0,0 +1,83 @@
1import os
2
3from oeqa.selftest.case import OESelftestTestCase
4from oeqa.utils.commands import bitbake, get_bb_vars, runCmd
5
6# This test builds an image with using the "container" IMAGE_FSTYPE, and
7# ensures that then files in the image are only the ones expected.
8#
9# The only package added to the image is container_image_testpkg, which
10# contains one file. However, due to some other things not cleaning up during
11# rootfs creation, there is some cruft. Ideally bugs will be filed and the
12# cruft removed, but for now we whitelist some known set.
13#
14# Also for performance reasons we're only checking the cruft when using ipk.
15# When using deb, and rpm it is a bit different and we could test all
16# of them, but this test is more to catch if other packages get added by
17# default other than what is in ROOTFS_BOOTSTRAP_INSTALL.
18#
19class ContainerImageTests(OESelftestTestCase):
20
21 # Verify that when specifying a IMAGE_TYPEDEP_ of the form "foo.bar" that
22 # the conversion type bar gets added as a dep as well
23 def test_expected_files(self):
24
25 def get_each_path_part(path):
26 if path:
27 part = [ '.' + path + '/' ]
28 result = get_each_path_part(path.rsplit('/', 1)[0])
29 if result:
30 return part + result
31 else:
32 return part
33 else:
34 return None
35
36 self.write_config("""PREFERRED_PROVIDER_virtual/kernel = "linux-dummy"
37IMAGE_FSTYPES = "container"
38PACKAGE_CLASSES = "package_ipk"
39IMAGE_FEATURES = ""
40""")
41
42 bbvars = get_bb_vars(['bindir', 'sysconfdir', 'localstatedir',
43 'DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME'],
44 target='container-test-image')
45 expected_files = [
46 './',
47 '.{bindir}/theapp',
48 '.{sysconfdir}/default/',
49 '.{sysconfdir}/default/postinst',
50 '.{sysconfdir}/ld.so.cache',
51 '.{sysconfdir}/timestamp',
52 '.{sysconfdir}/version',
53 './run/',
54 '.{localstatedir}/cache/',
55 '.{localstatedir}/cache/ldconfig/',
56 '.{localstatedir}/cache/ldconfig/aux-cache',
57 '.{localstatedir}/cache/opkg/',
58 '.{localstatedir}/lib/',
59 '.{localstatedir}/lib/opkg/'
60 ]
61
62 expected_files = [ x.format(bindir=bbvars['bindir'],
63 sysconfdir=bbvars['sysconfdir'],
64 localstatedir=bbvars['localstatedir'])
65 for x in expected_files ]
66
67 # Since tar lists all directories individually, make sure each element
68 # from bindir, sysconfdir, etc is added
69 expected_files += get_each_path_part(bbvars['bindir'])
70 expected_files += get_each_path_part(bbvars['sysconfdir'])
71 expected_files += get_each_path_part(bbvars['localstatedir'])
72
73 expected_files = sorted(expected_files)
74
75 # Build the image of course
76 bitbake('container-test-image')
77
78 image = os.path.join(bbvars['DEPLOY_DIR_IMAGE'],
79 bbvars['IMAGE_LINK_NAME'] + '.tar.bz2')
80
81 # Ensure the files in the image are what we expect
82 result = runCmd("tar tf {} | sort".format(image), shell=True)
83 self.assertEqual(result.output.split('\n'), expected_files)