blob: 3ea0f6635755c13d62ce13bf89e4baee07687da9 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005import tempfile
6import shutil
7import os
8import glob
Brad Bishop977dc1a2019-02-06 16:01:43 -05009import time
Brad Bishopd7bf8c12018-02-25 22:55:05 -050010from oeqa.selftest.case import OESelftestTestCase
Patrick Williams45852732022-04-02 08:58:32 -050011from oeqa.utils.commands import runCmd, bitbake, get_bb_vars
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012
13class oeSDKExtSelfTest(OESelftestTestCase):
14 """
15 # Bugzilla Test Plan: 6033
16 # This code is planned to be part of the automation for eSDK containig
17 # Install libraries and headers, image generation binary feeds, sdk-update.
18 """
19
20 @staticmethod
21 def get_esdk_environment(env_eSDK, tmpdir_eSDKQA):
22 # XXX: at this time use the first env need to investigate
23 # what environment load oe-selftest, i586, x86_64
24 pattern = os.path.join(tmpdir_eSDKQA, 'environment-setup-*')
25 return glob.glob(pattern)[0]
26
27 @staticmethod
28 def run_esdk_cmd(env_eSDK, tmpdir_eSDKQA, cmd, postconfig=None, **options):
29 if postconfig:
30 esdk_conf_file = os.path.join(tmpdir_eSDKQA, 'conf', 'local.conf')
31 with open(esdk_conf_file, 'a+') as f:
32 f.write(postconfig)
33 if not options:
34 options = {}
35 if not 'shell' in options:
36 options['shell'] = True
37
Brad Bishop977dc1a2019-02-06 16:01:43 -050038 runCmd("cd %s; unset BBPATH; unset BUILDDIR; . %s; %s" % (tmpdir_eSDKQA, env_eSDK, cmd), **options)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050039
40 @staticmethod
41 def generate_eSDK(image):
42 pn_task = '%s -c populate_sdk_ext' % image
43 bitbake(pn_task)
44
45 @staticmethod
46 def get_eSDK_toolchain(image):
47 pn_task = '%s -c populate_sdk_ext' % image
48
49 bb_vars = get_bb_vars(['SDK_DEPLOY', 'TOOLCHAINEXT_OUTPUTNAME'], pn_task)
50 sdk_deploy = bb_vars['SDK_DEPLOY']
51 toolchain_name = bb_vars['TOOLCHAINEXT_OUTPUTNAME']
52 return os.path.join(sdk_deploy, toolchain_name + '.sh')
53
54 @staticmethod
55 def update_configuration(cls, image, tmpdir_eSDKQA, env_eSDK, ext_sdk_path):
56 sstate_dir = os.path.join(os.environ['BUILDDIR'], 'sstate-cache')
57
58 oeSDKExtSelfTest.generate_eSDK(cls.image)
59
60 cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
61 runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
62
63 cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
64
65 sstate_config="""
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000066ESDK_LOCALCONF_ALLOW = "SSTATE_MIRRORS"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050067SSTATE_MIRRORS = "file://.* file://%s/PATH"
68CORE_IMAGE_EXTRA_INSTALL = "perl"
69 """ % sstate_dir
70
71 with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
72 f.write(sstate_config)
73
74 @classmethod
75 def setUpClass(cls):
76 super(oeSDKExtSelfTest, cls).setUpClass()
Brad Bishopd7bf8c12018-02-25 22:55:05 -050077 cls.image = 'core-image-minimal'
Brad Bishopf86d0552018-12-04 14:18:15 -080078
79 bb_vars = get_bb_vars(['SSTATE_DIR', 'WORKDIR'], cls.image)
80 bb.utils.mkdirhier(bb_vars["WORKDIR"])
81 cls.tmpdirobj = tempfile.TemporaryDirectory(prefix="selftest-esdk-", dir=bb_vars["WORKDIR"])
82 cls.tmpdir_eSDKQA = cls.tmpdirobj.name
83
Brad Bishopd7bf8c12018-02-25 22:55:05 -050084 oeSDKExtSelfTest.generate_eSDK(cls.image)
85
86 # Install eSDK
87 cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
88 runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
89
90 cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
91
92 # Configure eSDK to use sstate mirror from poky
93 sstate_config="""
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000094ESDK_LOCALCONF_ALLOW = "SSTATE_MIRRORS"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050095SSTATE_MIRRORS = "file://.* file://%s/PATH"
Brad Bishopf86d0552018-12-04 14:18:15 -080096 """ % bb_vars["SSTATE_DIR"]
Brad Bishopd7bf8c12018-02-25 22:55:05 -050097 with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
98 f.write(sstate_config)
99
100 @classmethod
101 def tearDownClass(cls):
Brad Bishop977dc1a2019-02-06 16:01:43 -0500102 for i in range(0, 10):
Andrew Geisslereff27472021-10-29 15:35:00 -0500103 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 -0500104 time.sleep(1)
105 else:
106 break
Brad Bishopf86d0552018-12-04 14:18:15 -0800107 cls.tmpdirobj.cleanup()
108 super().tearDownClass()
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500109
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500110 def test_install_libraries_headers(self):
111 pn_sstate = 'bc'
112 bitbake(pn_sstate)
113 cmd = "devtool sdk-install %s " % pn_sstate
114 oeSDKExtSelfTest.run_esdk_cmd(self.env_eSDK, self.tmpdir_eSDKQA, cmd)
115
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500116 def test_image_generation_binary_feeds(self):
117 image = 'core-image-minimal'
118 cmd = "devtool build-image %s" % image
119 oeSDKExtSelfTest.run_esdk_cmd(self.env_eSDK, self.tmpdir_eSDKQA, cmd)
120