summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-selftest/recipes-test/poison/poison.bb26
-rw-r--r--meta/lib/oeqa/selftest/cases/buildoptions.py5
2 files changed, 21 insertions, 10 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"
diff --git a/meta/lib/oeqa/selftest/cases/buildoptions.py b/meta/lib/oeqa/selftest/cases/buildoptions.py
index 09272314bb..b509bcf951 100644
--- a/meta/lib/oeqa/selftest/cases/buildoptions.py
+++ b/meta/lib/oeqa/selftest/cases/buildoptions.py
@@ -234,6 +234,5 @@ PREMIRRORS = "\\
234 234
235class Poisoning(OESelftestTestCase): 235class Poisoning(OESelftestTestCase):
236 def test_poisoning(self): 236 def test_poisoning(self):
237 res = bitbake("poison", ignore_status=True) 237 # The poison recipe fails if the poisoning didn't work
238 self.assertNotEqual(res.status, 0) 238 bitbake("poison")
239 self.assertTrue("is unsafe for cross-compilation" in res.output)