blob: e7fc211a47948f3234ef11e924f3b20e394d0a50 [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 tempfile
7import subprocess
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008import unittest
Brad Bishop19323692019-04-05 15:28:33 -04009
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010from 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 BuildCpioTest(OESDKTestCase):
Brad Bishop19323692019-04-05 15:28:33 -040015 """
16 Check that autotools will cross-compile correctly.
17 """
Brad Bishop6e60e8b2018-02-01 10:27:11 -050018 def test_cpio(self):
Brad Bishop19323692019-04-05 15:28:33 -040019 with tempfile.TemporaryDirectory(prefix="cpio-", dir=self.tc.sdk_dir) as testdir:
Andrew Geissler82c905d2020-04-13 13:39:40 -050020 tarball = self.fetch(testdir, self.td["DL_DIR"], "https://ftp.gnu.org/gnu/cpio/cpio-2.13.tar.gz")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021
Brad Bishop19323692019-04-05 15:28:33 -040022 dirs = {}
Andrew Geissler82c905d2020-04-13 13:39:40 -050023 dirs["source"] = os.path.join(testdir, "cpio-2.13")
Brad Bishop19323692019-04-05 15:28:33 -040024 dirs["build"] = os.path.join(testdir, "build")
25 dirs["install"] = os.path.join(testdir, "install")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026
Andrew Geisslerc9f78652020-09-18 14:11:35 -050027 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
Brad Bishop19323692019-04-05 15:28:33 -040028 self.assertTrue(os.path.isdir(dirs["source"]))
29 os.makedirs(dirs["build"])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030
Andrew Geissler635e0e42020-08-21 15:58:33 -050031 self._run("sed -i -e '/char.*program_name/d' {source}/src/global.c".format(**dirs))
Andrew Geissler82c905d2020-04-13 13:39:40 -050032 self._run("cd {build} && {source}/configure --disable-maintainer-mode $CONFIGURE_FLAGS".format(**dirs))
Brad Bishop19323692019-04-05 15:28:33 -040033 self._run("cd {build} && make -j".format(**dirs))
34 self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
35
36 self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "cpio"))