summaryrefslogtreecommitdiffstats
path: root/meta-selftest/recipes-test
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2025-01-21 18:23:08 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-01-22 13:20:29 +0000
commit1c5a2c8bcc96b8bdfc5186d75953dfabd4b3842a (patch)
tree7ea373499155551e5a715c95ef3a0609b1bd11aa /meta-selftest/recipes-test
parent364880dcb36c443ad6bbd5840f3882ca0740134c (diff)
downloadpoky-1c5a2c8bcc96b8bdfc5186d75953dfabd4b3842a.tar.gz
oeqa/poisoning: fix gcc include poisoning test
The test code in poison was flawed: as long as one CPP/CC/CXX has fatal poisoning enabled then the test passes. However, at the moment due to a bad rebase only CPP has fatal poisoning and CC/CXX do not. Rewrite the do_compile() task to more carefully check the output so the test harness itself just has to bitbake the recipe. Note that this results in the test failing: ERROR: poison-1.0-r0 do_compile: C Compiler is not poisoned. Exit status 0, output: cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories] ERROR: poison-1.0-r0 do_compile: C++ Compiler is not poisoned. Exit status 0, output: cc1plus: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories] (From OE-Core rev: 5b413d1fdb4bdbaec86d630bb52c3ccf68aae789) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta-selftest/recipes-test')
-rw-r--r--meta-selftest/recipes-test/poison/poison.bb26
1 files changed, 19 insertions, 7 deletions
diff --git a/meta-selftest/recipes-test/poison/poison.bb b/meta-selftest/recipes-test/poison/poison.bb
index e9eee0cdba..771113acf3 100644
--- a/meta-selftest/recipes-test/poison/poison.bb
+++ b/meta-selftest/recipes-test/poison/poison.bb
@@ -8,13 +8,25 @@ inherit nopackages
8# This test confirms that compiling code that searches /usr/include for headers 8# This test confirms that compiling code that searches /usr/include for headers
9# will result in compiler errors. This recipe should will fail to build and 9# will result in compiler errors. This recipe should will fail to build and
10# oe-selftest has a test that verifies that. 10# oe-selftest has a test that verifies that.
11do_compile() { 11python do_compile() {
12 bbnote Testing preprocessor 12 import subprocess
13 echo "int main(int argc, char** argv) {}" | ${CPP} -I/usr/include - 13
14 bbnote Testing C compiler 14 tests = {
15 echo "int main(int argc, char** argv) {}" | ${CC} -x c -I/usr/include - 15 "Preprocessor": "${CPP} -I/usr/include -",
16 bbnote Testing C++ compiler 16 "C Compiler": "${CC} -I/usr/include -x c -",
17 echo "int main(int argc, char** argv) {}" | ${CC} -x c++ -I/usr/include - 17 "C++ Compiler": "${CXX} -I/usr/include -x c++ -",
18 }
19
20 for name, cmd in tests.items():
21 cmd = d.expand(cmd)
22 bb.note("Test command: " + cmd)
23 testcode = "int main(int argc, char** argv) {}"
24 proc = subprocess.run(cmd, shell=True, input=testcode, capture_output=True, text=True)
25
26 if proc.returncode != 0 and "is unsafe for cross-compilation" in proc.stderr:
27 bb.note(f"{name} passed: {proc.stderr}")
28 else:
29 bb.error(f"{name} is not poisoned. Exit status {proc.returncode}, output: {proc.stdout} {proc.stderr}")
18} 30}
19 31
20EXCLUDE_FROM_WORLD = "1" 32EXCLUDE_FROM_WORLD = "1"