summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorJames R T <jamestiotio@gmail.com>2023-03-17 14:37:25 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-03-23 22:41:32 +0000
commitf14328c22f25d01449055b6ed9120d6deac9e0ac (patch)
tree84640590064b127314f3dd4604d20d28bfd7ff04 /bitbake/lib/bb/tests
parentf98f1fe24d1e041f698b00ad898cd2ff76670c3a (diff)
downloadpoky-f14328c22f25d01449055b6ed9120d6deac9e0ac.tar.gz
bitbake: ConfHandler: Allow the '@' character in variable flag names
This patch enables the usage of the '@' character in variable flag names. One use case of variable flags is to assign the network namespaces of some systemd services/targets to configure other parts of the build process of some system. The filenames of systemd services/targets might contain the '@' character if they are template unit files that can take in a single parameter/argument and be instanced multiple times, as indicated by systemd's official manual page. The '@' character is disallowed as the first character in a variable flag name. Imposing more restrictions on the first character is a compromise to make parsing easier and to allow for more options in the future to extend the syntax. This patch is successfully verified by creating a custom BitBake recipe that sets and unsets the value of a variable flag with the '@' character in its name and ensuring that no ParseError is being thrown. Regression tests have also been added to `bb.parse`. `bin/bitbake-selftest` has also been successfully executed and all tests passed. (Bitbake rev: 00f9ab2cacfbd2a63b6b4959cf5401babae7e32a) Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/parse.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py
index ee7f2534f1..d27c7c6f15 100644
--- a/bitbake/lib/bb/tests/parse.py
+++ b/bitbake/lib/bb/tests/parse.py
@@ -218,3 +218,24 @@ VAR = " \\
218 with self.assertRaises(bb.BBHandledException): 218 with self.assertRaises(bb.BBHandledException):
219 d = bb.parse.handle(f.name, self.d)[''] 219 d = bb.parse.handle(f.name, self.d)['']
220 220
221
222 at_sign_in_var_flag = """
223A[flag@.service] = "nonet"
224B[flag@.target] = "ntb"
225
226unset A[flag@.service]
227"""
228 def test_parse_at_sign_in_var_flag(self):
229 f = self.parsehelper(self.at_sign_in_var_flag)
230 d = bb.parse.handle(f.name, self.d)['']
231 self.assertEqual(d.getVar("A"), None)
232 self.assertEqual(d.getVar("B"), None)
233 self.assertEqual(d.getVarFlag("A","flag@.service"), None)
234 self.assertEqual(d.getVarFlag("B","flag@.target"), "ntb")
235
236 def test_parse_invalid_at_sign_in_var_flag(self):
237 invalid_at_sign = self.at_sign_in_var_flag.replace("B[f", "B[@f")
238 f = self.parsehelper(invalid_at_sign)
239 with self.assertRaises(bb.parse.ParseError):
240 d = bb.parse.handle(f.name, self.d)['']
241