blob: 51003b19cd013060d7e8f41071094e7e2369bb15 [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:
Patrick Williams73bd93f2024-02-20 08:07:48 -060022 tarball = self.fetch(testdir, self.td["DL_DIR"], "https://ftp.gnu.org/gnu/cpio/cpio-2.15.tar.gz")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023
Brad Bishop19323692019-04-05 15:28:33 -040024 dirs = {}
Patrick Williams73bd93f2024-02-20 08:07:48 -060025 dirs["source"] = os.path.join(testdir, "cpio-2.15")
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
Patrick Williams73bd93f2024-02-20 08:07:48 -060033 self._run("cd {build} && {source}/configure $CONFIGURE_FLAGS".format(**dirs))
Brad Bishop19323692019-04-05 15:28:33 -040034 self._run("cd {build} && make -j".format(**dirs))
35 self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
36
37 self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "cpio"))