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