1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 00:39:46 +00:00

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>
This commit is contained in:
Ross Burton
2025-01-21 18:23:08 +00:00
committed by Richard Purdie
parent 364880dcb3
commit 1c5a2c8bcc
2 changed files with 21 additions and 10 deletions
+19 -7
View File
@@ -8,13 +8,25 @@ inherit nopackages
# This test confirms that compiling code that searches /usr/include for headers
# will result in compiler errors. This recipe should will fail to build and
# oe-selftest has a test that verifies that.
do_compile() {
bbnote Testing preprocessor
echo "int main(int argc, char** argv) {}" | ${CPP} -I/usr/include -
bbnote Testing C compiler
echo "int main(int argc, char** argv) {}" | ${CC} -x c -I/usr/include -
bbnote Testing C++ compiler
echo "int main(int argc, char** argv) {}" | ${CC} -x c++ -I/usr/include -
python do_compile() {
import subprocess
tests = {
"Preprocessor": "${CPP} -I/usr/include -",
"C Compiler": "${CC} -I/usr/include -x c -",
"C++ Compiler": "${CXX} -I/usr/include -x c++ -",
}
for name, cmd in tests.items():
cmd = d.expand(cmd)
bb.note("Test command: " + cmd)
testcode = "int main(int argc, char** argv) {}"
proc = subprocess.run(cmd, shell=True, input=testcode, capture_output=True, text=True)
if proc.returncode != 0 and "is unsafe for cross-compilation" in proc.stderr:
bb.note(f"{name} passed: {proc.stderr}")
else:
bb.error(f"{name} is not poisoned. Exit status {proc.returncode}, output: {proc.stdout} {proc.stderr}")
}
EXCLUDE_FROM_WORLD = "1"