1# 2# Copyright OpenEmbedded Contributors 3# 4# SPDX-License-Identifier: MIT 5# 6 7from oeqa.selftest.case import OESelftestTestCase 8from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject 9from oeqa.utils.commands import bitbake, get_bb_vars, runCmd 10from oeqa.core.decorator import OETestTag 11import tempfile 12import shutil 13 14@OETestTag("machine") 15class MetaIDE(OESelftestTestCase): 16 17 @classmethod 18 def setUpClass(cls): 19 super(MetaIDE, cls).setUpClass() 20 bitbake('meta-ide-support') 21 bitbake('build-sysroots -c build_native_sysroot') 22 bitbake('build-sysroots -c build_target_sysroot') 23 bb_vars = get_bb_vars(['MULTIMACH_TARGET_SYS', 'DEPLOY_DIR_IMAGE', 'COREBASE']) 24 cls.environment_script = 'environment-setup-%s' % bb_vars['MULTIMACH_TARGET_SYS'] 25 cls.deploydir = bb_vars['DEPLOY_DIR_IMAGE'] 26 cls.environment_script_path = '%s/%s' % (cls.deploydir, cls.environment_script) 27 cls.corebasedir = bb_vars['COREBASE'] 28 cls.tmpdir_metaideQA = tempfile.mkdtemp(prefix='metaide') 29 30 @classmethod 31 def tearDownClass(cls): 32 shutil.rmtree(cls.tmpdir_metaideQA, ignore_errors=True) 33 super(MetaIDE, cls).tearDownClass() 34 35 def test_meta_ide_had_installed_meta_ide_support(self): 36 self.assertExists(self.environment_script_path) 37 38 def test_meta_ide_can_compile_c_program(self): 39 runCmd('cp %s/test.c %s' % (self.tc.files_dir, self.tmpdir_metaideQA)) 40 runCmd("cd %s; . %s; $CC test.c -lm" % (self.tmpdir_metaideQA, self.environment_script_path)) 41 compiled_file = '%s/a.out' % self.tmpdir_metaideQA 42 self.assertExists(compiled_file) 43 44 def test_meta_ide_can_build_cpio_project(self): 45 dl_dir = self.td.get('DL_DIR', None) 46 self.project = SDKBuildProject(self.tmpdir_metaideQA + "/cpio/", self.environment_script_path, 47 "https://ftp.gnu.org/gnu/cpio/cpio-2.15.tar.gz", 48 self.tmpdir_metaideQA, self.td['DATETIME'], dl_dir=dl_dir) 49 self.project.download_archive() 50 self.assertEqual(self.project.run_configure('$CONFIGURE_FLAGS'), 0, 51 msg="Running configure failed") 52 self.assertEqual(self.project.run_make(), 0, 53 msg="Running make failed") 54 self.assertEqual(self.project.run_install(), 0, 55 msg="Running make install failed") 56 57 def test_meta_ide_can_run_sdk_tests(self): 58 bitbake('-c populate_sysroot gtk+3') 59 bitbake('build-sysroots -c build_target_sysroot') 60 bitbake('-c testsdk meta-ide-support') 61