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