diff options
Diffstat (limited to 'meta/lib/oeqa/sdk/cases/autotools.py')
-rw-r--r-- | meta/lib/oeqa/sdk/cases/autotools.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/meta/lib/oeqa/sdk/cases/autotools.py b/meta/lib/oeqa/sdk/cases/autotools.py new file mode 100644 index 0000000000..ee6c522551 --- /dev/null +++ b/meta/lib/oeqa/sdk/cases/autotools.py | |||
@@ -0,0 +1,48 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | import os | ||
8 | import tempfile | ||
9 | import subprocess | ||
10 | import unittest | ||
11 | |||
12 | from oeqa.sdk.case import OESDKTestCase | ||
13 | from oeqa.utils.subprocesstweak import errors_have_output | ||
14 | errors_have_output() | ||
15 | |||
16 | class AutotoolsTest(OESDKTestCase): | ||
17 | """ | ||
18 | Check that autotools will cross-compile correctly. | ||
19 | """ | ||
20 | def setUp(self): | ||
21 | libc = self.td.get("TCLIBC") | ||
22 | if libc in [ 'newlib' ]: | ||
23 | raise unittest.SkipTest("AutotoolsTest class: SDK doesn't contain a supported C library") | ||
24 | |||
25 | def test_cpio(self): | ||
26 | with tempfile.TemporaryDirectory(prefix="cpio-", dir=self.tc.sdk_dir) as testdir: | ||
27 | tarball = self.fetch(testdir, self.td["DL_DIR"], "https://ftp.gnu.org/gnu/cpio/cpio-2.15.tar.gz") | ||
28 | |||
29 | dirs = {} | ||
30 | dirs["source"] = os.path.join(testdir, "cpio-2.15") | ||
31 | dirs["build"] = os.path.join(testdir, "build") | ||
32 | dirs["install"] = os.path.join(testdir, "install") | ||
33 | |||
34 | subprocess.check_output(["tar", "xf", tarball, "-C", testdir], stderr=subprocess.STDOUT) | ||
35 | self.assertTrue(os.path.isdir(dirs["source"])) | ||
36 | os.makedirs(dirs["build"]) | ||
37 | |||
38 | self._run("cd {build} && {source}/configure CFLAGS='-std=gnu17 -Dbool=int -Dtrue=1 -Dfalse=0 -Wno-error=implicit-function-declaration' $CONFIGURE_FLAGS".format(**dirs)) | ||
39 | |||
40 | # Check that configure detected the target correctly | ||
41 | with open(os.path.join(dirs["build"], "config.log")) as f: | ||
42 | host_sys = self.td["HOST_SYS"] | ||
43 | self.assertIn(f"host_alias='{host_sys}'\n", f.readlines()) | ||
44 | |||
45 | self._run("cd {build} && make CFLAGS='-std=gnu17 -Dbool=int -Dtrue=1 -Dfalse=0 -Wno-error=implicit-function-declaration' -j".format(**dirs)) | ||
46 | self._run("cd {build} && make install DESTDIR={install}".format(**dirs)) | ||
47 | |||
48 | self.check_elf(os.path.join(dirs["install"], "usr", "local", "bin", "cpio")) | ||