generate_test_code: ease checks on the test data depends_on

In case of depends_on elements that include a conditional check
on some symbol's value, we allow the comparison element to
be anything and not just a fixed value as it was before.
This allows for more complex depends_on conditions where
build symbols and macros are used on both sides of the comparison.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
This commit is contained in:
Valerio Setti
2024-09-26 17:23:17 +02:00
parent 6b04996bda
commit b6dc14c3c8
+11 -2
View File
@@ -193,10 +193,19 @@ BEGIN_CASE_REGEX = r'/\*\s*BEGIN_CASE\s*(?P<depends_on>.*?)\s*\*/'
END_CASE_REGEX = r'/\*\s*END_CASE\s*\*/'
DEPENDENCY_REGEX = r'depends_on:(?P<dependencies>.*)'
# This can be something like [!]MBEDTLS_xxx
C_IDENTIFIER_REGEX = r'!?[a-z_][a-z0-9_]*'
# This is a generic relation operator: ==, !=, >[=], <[=]
CONDITION_OPERATOR_REGEX = r'[!=]=|[<>]=?'
# forbid 0ddd which might be accidentally octal or accidentally decimal
CONDITION_VALUE_REGEX = r'[-+]?(0x[0-9a-f]+|0|[1-9][0-9]*)'
# This can be (almost) anything as long as:
# - it starts with a number or a letter or a "("
# - it contains only
# - numbers
# - letters
# - spaces
# - math operators, i.e "+"", "-", "*", "/"
# - parentheses, i.e. "()"
CONDITION_VALUE_REGEX = r'[\d|\w|\(][\s_\(\)0-9a-zA-Z\+\-\*\/]*'
CONDITION_REGEX = r'({})(?:\s*({})\s*({}))?$'.format(C_IDENTIFIER_REGEX,
CONDITION_OPERATOR_REGEX,
CONDITION_VALUE_REGEX)