summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/parse.py
diff options
context:
space:
mode:
authorNikolai Merinov <n.merinov@inango-systems.com>2025-02-04 09:13:46 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-02-05 12:11:01 +0000
commitb65452bda3cadf53b2a262df3eb43adea88d2401 (patch)
treecfcb0fb00cb70dca246492e60ee6e1603428b67f /bitbake/lib/bb/tests/parse.py
parentc2da016918d1fda5bf63d94b59863f5013e482f9 (diff)
downloadpoky-b65452bda3cadf53b2a262df3eb43adea88d2401.tar.gz
bitbake: parse: Forbid ambiguous assignments to ${.}, ${+}, and ${:} variables
Old code that parse variable names in assignment commands behave differently for variables that ends with special symbol for single-character variable names and multi-character variable names. For example: A+="1" # Change variable ${A}, '+' glued to '=' A+ = "1" # Change variable ${A+} +="1" # Change variable ${+}, the '+' symbol not part of assignment operator + = "1" # Change variable ${+} New code would always assume that '.=', '+=', and ':=' is assignment operator. As result code like the following would raise parsing error +="value" While code with extra spaces would work as before + = "value" # Change variable ${+} This change allow to catch issues in code that generate bitbake configuration files in a manner like "echo ${VARNAME}+=${VALUE} >> conf/local.conf" (Bitbake rev: 93059aad13a12cd69d86368795c88e5349197d5d) Signed-off-by: Nikolai Merinov <n.merinov@inango-systems.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/parse.py')
-rw-r--r--bitbake/lib/bb/tests/parse.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py
index cb60af3641..e3cba67ad4 100644
--- a/bitbake/lib/bb/tests/parse.py
+++ b/bitbake/lib/bb/tests/parse.py
@@ -443,3 +443,23 @@ include \\
443 in_file.write("\n".join(lines)) 443 in_file.write("\n".join(lines))
444 in_file.flush() 444 in_file.flush()
445 bb.parse.handle(recipename_closed, bb.data.createCopy(self.d)) 445 bb.parse.handle(recipename_closed, bb.data.createCopy(self.d))
446
447 special_character_assignment = """
448A+="a"
449A+ = "b"
450+ = "c"
451"""
452 ambigous_assignment = """
453+= "d"
454"""
455 def test_parse_special_character_assignment(self):
456 f = self.parsehelper(self.special_character_assignment)
457 d = bb.parse.handle(f.name, self.d)['']
458 self.assertEqual(d.getVar("A"), " a")
459 self.assertEqual(d.getVar("A+"), "b")
460 self.assertEqual(d.getVar("+"), "c")
461
462 f = self.parsehelper(self.ambigous_assignment)
463 with self.assertRaises(bb.parse.ParseError) as error:
464 bb.parse.handle(f.name, self.d)
465 self.assertIn("Empty variable name in assignment", str(error.exception))