Skip to contentSkip to conversation

oeqa/selftest: add a newline in local.conf (newbuilddir)

PATCH New Christos Gavros 1 participant 1 message Feb 25, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v3 1/1 oeqa/selftest: add a newline in local.conf (newbuilddir)

If the build-st/conf/local.conf does not end with a newline when is generated then add one
Fixes [YOCTO #15734]

CC Yoann Congal <[email protected]>
CC Randy MacLeod <[email protected]>
CC Alexander Kanavin <[email protected]>

---
v2->v3
* reading the file line by line replaced with f.readlines (it uses more memory but gives faster access)

---
 meta/lib/oeqa/selftest/context.py | 7 +++++++
 1 file changed, 7 insertions(+)
meta/lib/oeqa/selftest/context.py +7 -0
index 5eb4cc44fd..16f82c6737 100644
@@ -102,6 +102,13 @@ class OESelftestTestContext(OETestContext):
         oe.path.copytree(builddir + "/cache", newbuilddir + "/cache")
         oe.path.copytree(selftestdir, newselftestdir)
 
+        # if the last line of local.conf in newbuilddir is not empty and does not end with newline then add one
+        localconf_path = newbuilddir + "/conf/local.conf"
+        with open(localconf_path, "r+", encoding="utf-8") as f:
+            last_line = f.readlines()[-1]
+            if last_line and not last_line.endswith("\n"):
+                f.write("\n")
+
         subprocess.check_output("git init && git add * && git commit -a -m 'initial'", cwd=newselftestdir, shell=True)
 
         # Tried to used bitbake-layers add/remove but it requires recipe parsing and hence is too slow
Signature · 1 line
2.34.1