blob: 6f10d30dc9c20d4850b40c49c4d9d7c89161a1a6 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishop316dfdd2018-06-25 12:45:53 -04005from oeqa.selftest.case import OESelftestTestCase
6from oeqa.sdk.utils.sdkbuildproject import SDKBuildProject
7from oeqa.utils.commands import bitbake, get_bb_vars, runCmd
Brad Bishop79641f22019-09-10 07:20:22 -04008from oeqa.core.decorator import OETestTag
Brad Bishop316dfdd2018-06-25 12:45:53 -04009import tempfile
10import shutil
11
Brad Bishop79641f22019-09-10 07:20:22 -040012@OETestTag("machine")
Brad Bishop316dfdd2018-06-25 12:45:53 -040013class 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
Brad Bishop316dfdd2018-06-25 12:45:53 -040031 def test_meta_ide_had_installed_meta_ide_support(self):
32 self.assertExists(self.environment_script_path)
33
Brad Bishop316dfdd2018-06-25 12:45:53 -040034 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
Brad Bishop316dfdd2018-06-25 12:45:53 -040040 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,
Andrew Geissler82c905d2020-04-13 13:39:40 -050043 "https://ftp.gnu.org/gnu/cpio/cpio-2.13.tar.gz",
Brad Bishop316dfdd2018-06-25 12:45:53 -040044 self.tmpdir_metaideQA, self.td['DATETIME'], dl_dir=dl_dir)
45 self.project.download_archive()
Andrew Geisslerc9f78652020-09-18 14:11:35 -050046 self.assertEqual(self.project.run_configure('$CONFIGURE_FLAGS --disable-maintainer-mode','sed -i -e "/char \*program_name/d" src/global.c;'), 0,
Brad Bishop316dfdd2018-06-25 12:45:53 -040047 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")