blob: 178f07472d52c9c9f54058f5f00d964b9d374c3a [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishop19323692019-04-05 15:28:33 -04007import os
8import subprocess
9import tempfile
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010import unittest
11
12from oeqa.sdk.case import OESDKTestCase
Brad Bishop19323692019-04-05 15:28:33 -040013from oeqa.utils.subprocesstweak import errors_have_output
14errors_have_output()
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015
16class GalculatorTest(OESDKTestCase):
Brad Bishop19323692019-04-05 15:28:33 -040017 """
18 Test that autotools and GTK+ 3 compiles correctly.
19 """
20 def setUp(self):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080021 if not (self.tc.hasTargetPackage("gtk+3", multilib=True) or \
22 self.tc.hasTargetPackage("libgtk-3.0", multilib=True)):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023 raise unittest.SkipTest("GalculatorTest class: SDK don't support gtk+3")
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050024 if not (self.tc.hasHostPackage("nativesdk-gettext-dev") or
25 self.tc.hasHostPackage("gettext-native")):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026 raise unittest.SkipTest("GalculatorTest class: SDK doesn't contain gettext")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050027
28 def test_galculator(self):
Brad Bishop19323692019-04-05 15:28:33 -040029 with tempfile.TemporaryDirectory(prefix="galculator", dir=self.tc.sdk_dir) as testdir:
30 tarball = self.fetch(testdir, self.td["DL_DIR"], "http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050031
Brad Bishop19323692019-04-05 15:28:33 -040032 dirs = {}
33 dirs["source"] = os.path.join(testdir, "galculator-2.1.4")
34 dirs["build"] = os.path.join(testdir, "build")
35 dirs["install"] = os.path.join(testdir, "install")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050036
Andrew Geisslerc9f78652020-09-18 14:11:35 -050037 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
Brad Bishop19323692019-04-05 15:28:33 -040038 self.assertTrue(os.path.isdir(dirs["source"]))
39 os.makedirs(dirs["build"])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050040
Andrew Geissler635e0e42020-08-21 15:58:33 -050041 self._run("cd {source} && sed -i -e '/s_preferences.*prefs;/d' src/main.c && autoreconf -i -f -I $OECORE_TARGET_SYSROOT/usr/share/aclocal -I m4".format(**dirs))
Brad Bishop19323692019-04-05 15:28:33 -040042 self._run("cd {build} && {source}/configure $CONFIGURE_FLAGS".format(**dirs))
43 self._run("cd {build} && make -j".format(**dirs))
44 self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045
Brad Bishop19323692019-04-05 15:28:33 -040046 self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "galculator"))