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