blob: 58ade920c9d3b14d6e00643f0b0dac462b863dab [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishop19323692019-04-05 15:28:33 -04005import os
6import subprocess
7import tempfile
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008import unittest
9
10from oeqa.sdk.case import OESDKTestCase
Brad Bishop19323692019-04-05 15:28:33 -040011from oeqa.utils.subprocesstweak import errors_have_output
12errors_have_output()
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013
14class GalculatorTest(OESDKTestCase):
Brad Bishop19323692019-04-05 15:28:33 -040015 """
16 Test that autotools and GTK+ 3 compiles correctly.
17 """
18 def setUp(self):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019 if not (self.tc.hasTargetPackage("gtk+3", multilib=True) or \
20 self.tc.hasTargetPackage("libgtk-3.0", multilib=True)):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021 raise unittest.SkipTest("GalculatorTest class: SDK don't support gtk+3")
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050022 if not (self.tc.hasHostPackage("nativesdk-gettext-dev") or
23 self.tc.hasHostPackage("gettext-native")):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 raise unittest.SkipTest("GalculatorTest class: SDK doesn't contain gettext")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025
26 def test_galculator(self):
Brad Bishop19323692019-04-05 15:28:33 -040027 with tempfile.TemporaryDirectory(prefix="galculator", dir=self.tc.sdk_dir) as testdir:
28 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 -050029
Brad Bishop19323692019-04-05 15:28:33 -040030 dirs = {}
31 dirs["source"] = os.path.join(testdir, "galculator-2.1.4")
32 dirs["build"] = os.path.join(testdir, "build")
33 dirs["install"] = os.path.join(testdir, "install")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050034
Andrew Geisslerc9f78652020-09-18 14:11:35 -050035 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
Brad Bishop19323692019-04-05 15:28:33 -040036 self.assertTrue(os.path.isdir(dirs["source"]))
37 os.makedirs(dirs["build"])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050038
Andrew Geissler635e0e42020-08-21 15:58:33 -050039 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 -040040 self._run("cd {build} && {source}/configure $CONFIGURE_FLAGS".format(**dirs))
41 self._run("cd {build} && make -j".format(**dirs))
42 self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043
Brad Bishop19323692019-04-05 15:28:33 -040044 self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "galculator"))