1# 2# SPDX-License-Identifier: MIT 3# 4 5import os 6import tempfile 7import subprocess 8import unittest 9 10from oeqa.sdk.case import OESDKTestCase 11from oeqa.utils.subprocesstweak import errors_have_output 12errors_have_output() 13 14class BuildCpioTest(OESDKTestCase): 15 """ 16 Check that autotools will cross-compile correctly. 17 """ 18 def test_cpio(self): 19 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.13.tar.gz") 21 22 dirs = {} 23 dirs["source"] = os.path.join(testdir, "cpio-2.13") 24 dirs["build"] = os.path.join(testdir, "build") 25 dirs["install"] = os.path.join(testdir, "install") 26 27 subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT) 28 self.assertTrue(os.path.isdir(dirs["source"])) 29 os.makedirs(dirs["build"]) 30 31 self._run("sed -i -e '/char.*program_name/d' {source}/src/global.c".format(**dirs)) 32 self._run("cd {build} && {source}/configure --disable-maintainer-mode $CONFIGURE_FLAGS".format(**dirs)) 33 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")) 37