blob: 902e93f623b471bea444e0b621c5f4f36087327c [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
Brad Bishop19323692019-04-05 15:28:33 -040027 subprocess.check_output(["tar", "xf", tarball, "-C", testdir])
28 self.assertTrue(os.path.isdir(dirs["source"]))
29 os.makedirs(dirs["build"])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030
Andrew Geissler82c905d2020-04-13 13:39:40 -050031 self._run("cd {build} && {source}/configure --disable-maintainer-mode $CONFIGURE_FLAGS".format(**dirs))
Brad Bishop19323692019-04-05 15:28:33 -040032 self._run("cd {build} && make -j".format(**dirs))
33 self._run("cd {build} && make install DESTDIR={install}".format(**dirs))
34
35 self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "cpio"))