summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRandy Witt <randy.e.witt@linux.intel.com>2017-01-30 13:16:28 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-19 06:49:00 -0800
commit23bd7e100adb6dc06c4992ff5863f01d0b39e75b (patch)
tree67b6f295aa249b9ff6801d519bc09b2e1e2598f8 /meta/lib
parent5da9c1c38b31c5edb957ad22fd093c9bc3a2ecd7 (diff)
downloadpoky-23bd7e100adb6dc06c4992ff5863f01d0b39e75b.tar.gz
selftest/containerimage.py: Add container IMAGE_FSTYPES test
This test checks to make sure only the files expected exist in a container image. Currently only ROOTFS_BOOTSTRAP_INSTALL, gets added to all images without the user specifying it. But this test should help if a developer in the future ever silently adds more than just ROOTFS_BOOTSTRAP_INSTALL, and that the developer can make sure it also gets removed from a container image. [YOCTO #9502] (From OE-Core rev: 4f5e5321fafe491f91d78a35d11afc0dc0527d4b) Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-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)