blob: 8eb6ec660ce6806fd85c807a1bddf0233df76935 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001import tempfile
2import shutil
3import os
4import glob
Brad Bishop977dc1a2019-02-06 16:01:43 -05005import time
Brad Bishopd7bf8c12018-02-25 22:55:05 -05006from oeqa.core.decorator.oeid import OETestID
7from oeqa.selftest.case import OESelftestTestCase
8from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
9
10class oeSDKExtSelfTest(OESelftestTestCase):
11 """
12 # Bugzilla Test Plan: 6033
13 # This code is planned to be part of the automation for eSDK containig
14 # Install libraries and headers, image generation binary feeds, sdk-update.
15 """
16
17 @staticmethod
18 def get_esdk_environment(env_eSDK, tmpdir_eSDKQA):
19 # XXX: at this time use the first env need to investigate
20 # what environment load oe-selftest, i586, x86_64
21 pattern = os.path.join(tmpdir_eSDKQA, 'environment-setup-*')
22 return glob.glob(pattern)[0]
23
24 @staticmethod
25 def run_esdk_cmd(env_eSDK, tmpdir_eSDKQA, cmd, postconfig=None, **options):
26 if postconfig:
27 esdk_conf_file = os.path.join(tmpdir_eSDKQA, 'conf', 'local.conf')
28 with open(esdk_conf_file, 'a+') as f:
29 f.write(postconfig)
30 if not options:
31 options = {}
32 if not 'shell' in options:
33 options['shell'] = True
34
Brad Bishop977dc1a2019-02-06 16:01:43 -050035 runCmd("cd %s; unset BBPATH; unset BUILDDIR; . %s; %s" % (tmpdir_eSDKQA, env_eSDK, cmd), **options)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036
37 @staticmethod
38 def generate_eSDK(image):
39 pn_task = '%s -c populate_sdk_ext' % image
40 bitbake(pn_task)
41
42 @staticmethod
43 def get_eSDK_toolchain(image):
44 pn_task = '%s -c populate_sdk_ext' % image
45
46 bb_vars = get_bb_vars(['SDK_DEPLOY', 'TOOLCHAINEXT_OUTPUTNAME'], pn_task)
47 sdk_deploy = bb_vars['SDK_DEPLOY']
48 toolchain_name = bb_vars['TOOLCHAINEXT_OUTPUTNAME']
49 return os.path.join(sdk_deploy, toolchain_name + '.sh')
50
51 @staticmethod
52 def update_configuration(cls, image, tmpdir_eSDKQA, env_eSDK, ext_sdk_path):
53 sstate_dir = os.path.join(os.environ['BUILDDIR'], 'sstate-cache')
54
55 oeSDKExtSelfTest.generate_eSDK(cls.image)
56
57 cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
58 runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
59
60 cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
61
62 sstate_config="""
63SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
64SSTATE_MIRRORS = "file://.* file://%s/PATH"
65CORE_IMAGE_EXTRA_INSTALL = "perl"
66 """ % sstate_dir
67
68 with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
69 f.write(sstate_config)
70
71 @classmethod
72 def setUpClass(cls):
73 super(oeSDKExtSelfTest, cls).setUpClass()
Brad Bishopd7bf8c12018-02-25 22:55:05 -050074 cls.image = 'core-image-minimal'
Brad Bishopf86d0552018-12-04 14:18:15 -080075
76 bb_vars = get_bb_vars(['SSTATE_DIR', 'WORKDIR'], cls.image)
77 bb.utils.mkdirhier(bb_vars["WORKDIR"])
78 cls.tmpdirobj = tempfile.TemporaryDirectory(prefix="selftest-esdk-", dir=bb_vars["WORKDIR"])
79 cls.tmpdir_eSDKQA = cls.tmpdirobj.name
80
Brad Bishopd7bf8c12018-02-25 22:55:05 -050081 oeSDKExtSelfTest.generate_eSDK(cls.image)
82
83 # Install eSDK
84 cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
85 runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
86
87 cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
88
89 # Configure eSDK to use sstate mirror from poky
90 sstate_config="""
91SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
92SSTATE_MIRRORS = "file://.* file://%s/PATH"
Brad Bishopf86d0552018-12-04 14:18:15 -080093 """ % bb_vars["SSTATE_DIR"]
Brad Bishopd7bf8c12018-02-25 22:55:05 -050094 with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
95 f.write(sstate_config)
96
97 @classmethod
98 def tearDownClass(cls):
Brad Bishop977dc1a2019-02-06 16:01:43 -050099 for i in range(0, 10):
100 if os.path.exists(os.path.join(cls.tmpdir_eSDKQA, 'bitbake.lock')):
101 time.sleep(1)
102 else:
103 break
Brad Bishopf86d0552018-12-04 14:18:15 -0800104 cls.tmpdirobj.cleanup()
105 super().tearDownClass()
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500106
107 @OETestID(1602)
108 def test_install_libraries_headers(self):
109 pn_sstate = 'bc'
110 bitbake(pn_sstate)
111 cmd = "devtool sdk-install %s " % pn_sstate
112 oeSDKExtSelfTest.run_esdk_cmd(self.env_eSDK, self.tmpdir_eSDKQA, cmd)
113
114 @OETestID(1603)
115 def test_image_generation_binary_feeds(self):
116 image = 'core-image-minimal'
117 cmd = "devtool build-image %s" % image
118 oeSDKExtSelfTest.run_esdk_cmd(self.env_eSDK, self.tmpdir_eSDKQA, cmd)
119