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