blob: 9f5de2cde7fcac99f1dc8b52fa40bd358c7505ce [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007import tempfile
8import shutil
9import os
10import glob
Brad Bishop977dc1a2019-02-06 16:01:43 -050011import time
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012from oeqa.selftest.case import OESelftestTestCase
Patrick Williams45852732022-04-02 08:58:32 -050013from oeqa.utils.commands import runCmd, bitbake, get_bb_vars
Brad Bishopd7bf8c12018-02-25 22:55:05 -050014
15class oeSDKExtSelfTest(OESelftestTestCase):
16 """
17 # Bugzilla Test Plan: 6033
18 # This code is planned to be part of the automation for eSDK containig
19 # Install libraries and headers, image generation binary feeds, sdk-update.
20 """
21
22 @staticmethod
23 def get_esdk_environment(env_eSDK, tmpdir_eSDKQA):
24 # XXX: at this time use the first env need to investigate
25 # what environment load oe-selftest, i586, x86_64
26 pattern = os.path.join(tmpdir_eSDKQA, 'environment-setup-*')
27 return glob.glob(pattern)[0]
28
29 @staticmethod
30 def run_esdk_cmd(env_eSDK, tmpdir_eSDKQA, cmd, postconfig=None, **options):
31 if postconfig:
32 esdk_conf_file = os.path.join(tmpdir_eSDKQA, 'conf', 'local.conf')
33 with open(esdk_conf_file, 'a+') as f:
34 f.write(postconfig)
35 if not options:
36 options = {}
37 if not 'shell' in options:
38 options['shell'] = True
39
Brad Bishop977dc1a2019-02-06 16:01:43 -050040 runCmd("cd %s; unset BBPATH; unset BUILDDIR; . %s; %s" % (tmpdir_eSDKQA, env_eSDK, cmd), **options)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041
42 @staticmethod
43 def generate_eSDK(image):
44 pn_task = '%s -c populate_sdk_ext' % image
45 bitbake(pn_task)
46
47 @staticmethod
48 def get_eSDK_toolchain(image):
49 pn_task = '%s -c populate_sdk_ext' % image
50
51 bb_vars = get_bb_vars(['SDK_DEPLOY', 'TOOLCHAINEXT_OUTPUTNAME'], pn_task)
52 sdk_deploy = bb_vars['SDK_DEPLOY']
53 toolchain_name = bb_vars['TOOLCHAINEXT_OUTPUTNAME']
54 return os.path.join(sdk_deploy, toolchain_name + '.sh')
55
56 @staticmethod
57 def update_configuration(cls, image, tmpdir_eSDKQA, env_eSDK, ext_sdk_path):
58 sstate_dir = os.path.join(os.environ['BUILDDIR'], 'sstate-cache')
59
60 oeSDKExtSelfTest.generate_eSDK(cls.image)
61
62 cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
63 runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
64
65 cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
66
67 sstate_config="""
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000068ESDK_LOCALCONF_ALLOW = "SSTATE_MIRRORS"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050069SSTATE_MIRRORS = "file://.* file://%s/PATH"
70CORE_IMAGE_EXTRA_INSTALL = "perl"
71 """ % sstate_dir
72
73 with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
74 f.write(sstate_config)
75
76 @classmethod
77 def setUpClass(cls):
78 super(oeSDKExtSelfTest, cls).setUpClass()
Brad Bishopd7bf8c12018-02-25 22:55:05 -050079 cls.image = 'core-image-minimal'
Brad Bishopf86d0552018-12-04 14:18:15 -080080
81 bb_vars = get_bb_vars(['SSTATE_DIR', 'WORKDIR'], cls.image)
82 bb.utils.mkdirhier(bb_vars["WORKDIR"])
83 cls.tmpdirobj = tempfile.TemporaryDirectory(prefix="selftest-esdk-", dir=bb_vars["WORKDIR"])
84 cls.tmpdir_eSDKQA = cls.tmpdirobj.name
85
Brad Bishopd7bf8c12018-02-25 22:55:05 -050086 oeSDKExtSelfTest.generate_eSDK(cls.image)
87
88 # Install eSDK
89 cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
90 runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
91
92 cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
93
94 # Configure eSDK to use sstate mirror from poky
95 sstate_config="""
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000096ESDK_LOCALCONF_ALLOW = "SSTATE_MIRRORS"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050097SSTATE_MIRRORS = "file://.* file://%s/PATH"
Brad Bishopf86d0552018-12-04 14:18:15 -080098 """ % bb_vars["SSTATE_DIR"]
Brad Bishopd7bf8c12018-02-25 22:55:05 -050099 with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
100 f.write(sstate_config)
101
102 @classmethod
103 def tearDownClass(cls):
Brad Bishop977dc1a2019-02-06 16:01:43 -0500104 for i in range(0, 10):
Andrew Geisslereff27472021-10-29 15:35:00 -0500105 if os.path.exists(os.path.join(cls.tmpdir_eSDKQA, 'bitbake.lock')) or os.path.exists(os.path.join(cls.tmpdir_eSDKQA, 'cache/hashserv.db-wal')):
Brad Bishop977dc1a2019-02-06 16:01:43 -0500106 time.sleep(1)
107 else:
108 break
Brad Bishopf86d0552018-12-04 14:18:15 -0800109 cls.tmpdirobj.cleanup()
110 super().tearDownClass()
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500111
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500112 def test_install_libraries_headers(self):
113 pn_sstate = 'bc'
114 bitbake(pn_sstate)
115 cmd = "devtool sdk-install %s " % pn_sstate
116 oeSDKExtSelfTest.run_esdk_cmd(self.env_eSDK, self.tmpdir_eSDKQA, cmd)
117
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500118 def test_image_generation_binary_feeds(self):
119 image = 'core-image-minimal'
120 cmd = "devtool build-image %s" % image
121 oeSDKExtSelfTest.run_esdk_cmd(self.env_eSDK, self.tmpdir_eSDKQA, cmd)
122