blob: b4b7d85b882d515253149ee4f70ca32b5cecba74 [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, tempfile, subprocess, unittest
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008from oeqa.sdk.case import OESDKTestCase
Brad Bishop19323692019-04-05 15:28:33 -04009from oeqa.utils.subprocesstweak import errors_have_output
10errors_have_output()
Brad Bishop6e60e8b2018-02-01 10:27:11 -050011
12class BuildLzipTest(OESDKTestCase):
Brad Bishop19323692019-04-05 15:28:33 -040013 """
14 Test that "plain" compilation works, using just $CC $CFLAGS etc.
15 """
Brad Bishop6e60e8b2018-02-01 10:27:11 -050016 def test_lzip(self):
Brad Bishop19323692019-04-05 15:28:33 -040017 with tempfile.TemporaryDirectory(prefix="lzip", dir=self.tc.sdk_dir) as testdir:
18 tarball = self.fetch(testdir, self.td["DL_DIR"], "http://downloads.yoctoproject.org/mirror/sources/lzip-1.19.tar.gz")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050019
Brad Bishop19323692019-04-05 15:28:33 -040020 dirs = {}
21 dirs["source"] = os.path.join(testdir, "lzip-1.19")
22 dirs["build"] = os.path.join(testdir, "build")
23 dirs["install"] = os.path.join(testdir, "install")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050024
Andrew Geisslerc9f78652020-09-18 14:11:35 -050025 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
Brad Bishop19323692019-04-05 15:28:33 -040026 self.assertTrue(os.path.isdir(dirs["source"]))
27 os.makedirs(dirs["build"])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050028
Brad Bishop19323692019-04-05 15:28:33 -040029 cmd = """cd {build} && \
30 {source}/configure --srcdir {source} \
31 CXX="$CXX" \
32 CPPFLAGS="$CPPFLAGS" \
33 CXXFLAGS="$CXXFLAGS" \
34 LDFLAGS="$LDFLAGS" \
35 """
36 self._run(cmd.format(**dirs))
37 self._run("cd {build} && make -j".format(**dirs))
38 self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
39 self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "lzip"))