blob: 0a5e68d5fd787939c3c1ee3a3e59b5d4fdc45371 [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:
20 tarball = self.fetch(testdir, self.td["DL_DIR"], "https://ftp.gnu.org/gnu/cpio/cpio-2.12.tar.gz")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021
Brad Bishop19323692019-04-05 15:28:33 -040022 dirs = {}
23 dirs["source"] = os.path.join(testdir, "cpio-2.12")
24 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
Brad Bishop19323692019-04-05 15:28:33 -040031 self._run("cd {build} && {source}/configure $CONFIGURE_FLAGS".format(**dirs))
32 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"))