summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/containerimage.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/containerimage.py')
-rw-r--r--meta/lib/oeqa/selftest/containerimage.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/containerimage.py b/meta/lib/oeqa/selftest/containerimage.py
new file mode 100644
index 0000000000..def481f144
--- /dev/null
+++ b/meta/lib/oeqa/selftest/containerimage.py
@@ -0,0 +1,83 @@
1import os
2
3from oeqa.selftest.base import oeSelfTest
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(oeSelfTest):
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)