[PATCHv2 2/2] image-without-static-linkage: add selftest


Schilling, Johannes
 

From 87c3c8cc4f3e67b2bc06af53705f18c0a9de5dd7 Mon Sep 17 00:00:00 2001
From: Johannes Schilling <johannes.schilling@...>
Date: Mon, 27 Jun 2022 16:12:25 +0200
Subject: [PATCH 2/2] image-without-static-linkage: add selftest

The selftest runs the static linkage check QA test on a small rootfs,
expecting no static linkage against the two checkers "zlib" and
"librsvg". This tests that the class and the config are correctly pulled
in, the checkers are found an run, and will fail if yocto's core image
ever does ship statically linked copies of one of these.

Signed-Off-By: Johannes Schilling <johannes.schilling@...>
---
.../selftest/cases/static_linkage_checker.py | 39 +++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 lib/oeqa/selftest/cases/static_linkage_checker.py

diff --git a/lib/oeqa/selftest/cases/static_linkage_checker.py b/lib/oeqa/selftest/cases/static_linkage_checker.py
new file mode 100644
index 0000000..a5fdf6b
--- /dev/null
+++ b/lib/oeqa/selftest/cases/static_linkage_checker.py
@@ -0,0 +1,39 @@
+import os
+import re
+
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake
+
+class StaticLinkageCheck(OESelftestTestCase):
+ def test_static_linkage_check(self):
+ self.write_recipeinc('emptytest', """
+SUMMARY = "A small image just capable of allowing a device to boot."
+
+IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
+
+CORE_IMAGE_EXTRA_INSTALL ?= ""
+
+LICENSE = "MIT"
+
+inherit image
+
+IMAGE_ROOTFS_SIZE ?= "8192"
+
+inherit image-without-static-linkage
+
+STATIC_LINKAGE_CHECK_CONFIG = "${WORKDIR}/static-linkage-check-config.toml"
+
+do_write_config() {
+ echo "[checkers]\nmodules = [ "zlib", "librsvg" ]\n" > "${STATIC_LINKAGE_CHECK_CONFIG}"
+ echo "[exceptions]" >> "${STATIC_LINKAGE_CHECK_CONFIG}"
+ echo "ignore_dirs = []" >> "${STATIC_LINKAGE_CHECK_CONFIG}"
+ echo "ignore_checks = {}" >> "${STATIC_LINKAGE_CHECK_CONFIG}"
+}
+
+addtask do_write_config before do_image_qa
+ """)
+
+ result = bitbake("-c image_qa emptytest", ignore_status=True)
+ if result.status != 0:
+ self.logger.warn(result.output)
+ raise self.failureException("build failed, something went wrong...")


This e-mail may contain privileged or confidential information. If you are not the intended recipient: (1) you may not disclose, use, distribute, copy or rely upon this message or attachment(s); and (2) please notify the sender by reply e-mail, and then delete this message and its attachment(s). Underwriters Laboratories Inc. and its affiliates disclaim all liability for any errors, omissions, corruption or virus in this message or any attachments.