blob: c42c670add0efee9f3ae469d401a8507427e45e8 [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
8import tempfile
9import subprocess
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010import unittest
Brad Bishop19323692019-04-05 15:28:33 -040011
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012from oeqa.sdk.case import OESDKTestCase
Brad Bishop19323692019-04-05 15:28:33 -040013from oeqa.utils.subprocesstweak import errors_have_output
14errors_have_output()
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015
16class BuildCpioTest(OESDKTestCase):
Brad Bishop19323692019-04-05 15:28:33 -040017 """
18 Check that autotools will cross-compile correctly.
19 """
Brad Bishop6e60e8b2018-02-01 10:27:11 -050020 def test_cpio(self):
Brad Bishop19323692019-04-05 15:28:33 -040021 with tempfile.TemporaryDirectory(prefix="cpio-", dir=self.tc.sdk_dir) as testdir:
Andrew Geissler82c905d2020-04-13 13:39:40 -050022 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 -050023
Brad Bishop19323692019-04-05 15:28:33 -040024 dirs = {}
Andrew Geissler82c905d2020-04-13 13:39:40 -050025 dirs["source"] = os.path.join(testdir, "cpio-2.13")
Brad Bishop19323692019-04-05 15:28:33 -040026 dirs["build"] = os.path.join(testdir, "build")
27 dirs["install"] = os.path.join(testdir, "install")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050028
Andrew Geisslerc9f78652020-09-18 14:11:35 -050029 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT)
Brad Bishop19323692019-04-05 15:28:33 -040030 self.assertTrue(os.path.isdir(dirs["source"]))
31 os.makedirs(dirs["build"])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032
Andrew Geissler635e0e42020-08-21 15:58:33 -050033 self._run("sed -i -e '/char.*program_name/d' {source}/src/global.c".format(**dirs))
Andrew Geissler82c905d2020-04-13 13:39:40 -050034 self._run("cd {build} && {source}/configure --disable-maintainer-mode $CONFIGURE_FLAGS".format(**dirs))
Brad Bishop19323692019-04-05 15:28:33 -040035 self._run("cd {build} && make -j".format(**dirs))
36 self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
37
38 self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "cpio"))