1#
2# SPDX-License-Identifier: MIT
3#
4
5import os
6
7from oeqa.selftest.case import OESelftestTestCase
8from oeqa.utils.commands import bitbake
9
10class ImageTypeDepTests(OESelftestTestCase):
11
12    # Verify that when specifying a IMAGE_TYPEDEP: of the form "foo.bar" that
13    # the conversion type bar gets added as a dep as well
14    def test_conversion_typedep_added(self):
15
16        self.write_recipeinc('emptytest', """
17# Try to empty out the default dependency list
18PACKAGE_INSTALL = ""
19DISTRO_EXTRA_RDEPENDS=""
20
21LICENSE = "MIT"
22IMAGE_FSTYPES = "testfstype"
23
24IMAGE_TYPES_MASKED += "testfstype"
25IMAGE_TYPEDEP:testfstype = "tar.bz2"
26
27inherit image
28
29""")
30        # First get the dependency that should exist for bz2, it will look
31        # like CONVERSION_DEPENDS_bz2="somedep"
32        result = bitbake('-e emptytest')
33
34        dep = None
35        for line in result.output.split('\n'):
36            if line.startswith('CONVERSION_DEPENDS_bz2'):
37                dep = line.split('=')[1].strip('"')
38                break
39
40        self.assertIsNotNone(dep, "CONVERSION_DEPENDS_bz2 dependency not found in bitbake -e output")
41
42        # Now get the dependency task list and check for the expected task
43        # dependency
44        bitbake('-g emptytest')
45
46        taskdependsfile = os.path.join(self.builddir, 'task-depends.dot')
47        dep =  dep + ".do_populate_sysroot"
48        depfound = False
49        expectedline = '"emptytest.do_rootfs" -> "{}"'.format(dep)
50
51        with open(taskdependsfile, "r") as f:
52            for line in f:
53                if line.strip() == expectedline:
54                    depfound = True
55                    break
56
57        if not depfound:
58            raise AssertionError("\"{}\" not found".format(expectedline))
59