1# 2# SPDX-License-Identifier: MIT 3# 4 5import os 6import subprocess 7import tempfile 8import unittest 9 10from oeqa.sdk.case import OESDKTestCase 11from oeqa.utils.subprocesstweak import errors_have_output 12errors_have_output() 13 14class GalculatorTest(OESDKTestCase): 15 """ 16 Test that autotools and GTK+ 3 compiles correctly. 17 """ 18 def setUp(self): 19 if not (self.tc.hasTargetPackage("gtk+3", multilib=True) or \ 20 self.tc.hasTargetPackage("libgtk-3.0", multilib=True)): 21 raise unittest.SkipTest("GalculatorTest class: SDK don't support gtk+3") 22 if not (self.tc.hasHostPackage("nativesdk-gettext-dev")): 23 raise unittest.SkipTest("GalculatorTest class: SDK doesn't contain gettext") 24 25 def test_galculator(self): 26 with tempfile.TemporaryDirectory(prefix="galculator", dir=self.tc.sdk_dir) as testdir: 27 tarball = self.fetch(testdir, self.td["DL_DIR"], "http://galculator.mnim.org/downloads/galculator-2.1.4.tar.bz2") 28 29 dirs = {} 30 dirs["source"] = os.path.join(testdir, "galculator-2.1.4") 31 dirs["build"] = os.path.join(testdir, "build") 32 dirs["install"] = os.path.join(testdir, "install") 33 34 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT) 35 self.assertTrue(os.path.isdir(dirs["source"])) 36 os.makedirs(dirs["build"]) 37 38 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)) 39 self._run("cd {build} && {source}/configure $CONFIGURE_FLAGS".format(**dirs)) 40 self._run("cd {build} && make -j".format(**dirs)) 41 self._run("cd {build} && make install DESTDIR={install}".format(**dirs)) 42 43 self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "galculator")) 44