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 EpoxyTest(OESDKTestCase): 15 """ 16 Test that Meson builds correctly. 17 """ 18 def setUp(self): 19 if not (self.tc.hasHostPackage("nativesdk-meson")): 20 raise unittest.SkipTest("EpoxyTest class: SDK doesn't contain Meson") 21 22 def test_epoxy(self): 23 with tempfile.TemporaryDirectory(prefix="epoxy", dir=self.tc.sdk_dir) as testdir: 24 tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/anholt/libepoxy/releases/download/1.5.3/libepoxy-1.5.3.tar.xz") 25 26 dirs = {} 27 dirs["source"] = os.path.join(testdir, "libepoxy-1.5.3") 28 dirs["build"] = os.path.join(testdir, "build") 29 dirs["install"] = os.path.join(testdir, "install") 30 31 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT) 32 self.assertTrue(os.path.isdir(dirs["source"])) 33 os.makedirs(dirs["build"]) 34 35 log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs)) 36 # Check that Meson thinks we're doing a cross build and not a native 37 self.assertIn("Build type: cross build", log) 38 self._run("ninja -C {build} -v".format(**dirs)) 39 self._run("DESTDIR={install} ninja -C {build} -v install".format(**dirs)) 40 41 self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libepoxy.so")) 42