diff mbox series

[v2,2/3] oe-selftest: case: support fragments in write_config

Message ID 20251228180935.2077478-3-adrian.freihofer@siemens.com
State Under Review
Headers show
Series fragments: add a 'devtool-ide-sdk' fragment | expand

Commit Message

AdrianF Dec. 28, 2025, 6:08 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

When writing configuration files during selftests, also handle the
inclusion of fragment files via the toolcfg.conf mechanism.

By default the toolcfg.conf file from build/conf/toolcfg.conf is copied
to build-st/conf/toolcfg.conf. This comes with a risk for using fragments
by accident from the main build in the selftest build. To avoid this,
support writing a reproducible set of fragments per selftest case via
the write_config() method.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 meta/lib/oeqa/selftest/case.py    | 9 ++++++++-
 meta/lib/oeqa/selftest/context.py | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/case.py b/meta/lib/oeqa/selftest/case.py
index da35b25f68..148b120371 100644
--- a/meta/lib/oeqa/selftest/case.py
+++ b/meta/lib/oeqa/selftest/case.py
@@ -30,6 +30,7 @@  class OESelftestTestCase(OETestCase):
 
         cls.localconf_path = cls.tc.config_paths['localconf']
         cls.local_bblayers_path = cls.tc.config_paths['bblayers']
+        cls.toolcfgconf_path = cls.tc.config_paths['toolcfgconf']
 
         cls.testinc_path = os.path.join(cls.tc.config_paths['builddir'],
                 "conf/selftest.inc")
@@ -161,7 +162,7 @@  class OESelftestTestCase(OETestCase):
         self.logger.debug("Adding path '%s' to be cleaned up when test is over" % path)
         self._track_for_cleanup.append(path)
 
-    def write_config(self, data, multiconfig=None):
+    def write_config(self, data, multiconfig=None, fragments=None):
         """Write to config file"""
         if multiconfig:
             multiconfigdir = "%s/conf/multiconfig" % self.builddir
@@ -174,6 +175,12 @@  class OESelftestTestCase(OETestCase):
         self.logger.debug("Writing to: %s\n%s\n" % (dest_path, data))
         ftools.write_file(dest_path, data)
 
+        if fragments:
+            toolscfg_str = '# Added by oe-selftest' + os.linesep + \
+                'OE_FRAGMENTS += "' + ' '.join(fragments) + '"' + os.linesep
+            self.logger.debug("Over writing fragments: %s\n%s" % (self.toolcfgconf_path, toolscfg_str))
+            ftools.write_file(self.toolcfgconf_path, toolscfg_str)
+
     def append_config(self, data):
         """Append to <builddir>/conf/selftest.inc"""
         self.logger.debug("Appending to: %s\n%s\n" % (self.testinc_path, data))
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py
index c9eb481725..02a4832553 100644
--- a/meta/lib/oeqa/selftest/context.py
+++ b/meta/lib/oeqa/selftest/context.py
@@ -278,6 +278,7 @@  class OESelftestTestContextExecutor(OETestContextExecutor):
         self.tc_kwargs['init']['config_paths']['builddir'] = builddir
         self.tc_kwargs['init']['config_paths']['localconf'] = os.path.join(builddir, "conf/local.conf")
         self.tc_kwargs['init']['config_paths']['bblayers'] = os.path.join(builddir, "conf/bblayers.conf")
+        self.tc_kwargs['init']['config_paths']['toolcfgconf'] = os.path.join(builddir, "conf/toolcfg.conf")
         self.tc_kwargs['init']['newbuilddir'] = args.newbuilddir
         self.tc_kwargs['init']['keep_builddir'] = args.keep_builddir