expr_parser: support ':' operator
Similar to '==' but compiles the RHS into a regular expression and attempts to match whatever is in the environment against it. Change-Id: I7a03452ef88d067b62661d14dc6f42273de436fa Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
99c0f64b34
commit
7a87f9f500
2 changed files with 17 additions and 1 deletions
|
@ -18,6 +18,7 @@ import sys
|
||||||
import os
|
import os
|
||||||
import copy
|
import copy
|
||||||
import threading
|
import threading
|
||||||
|
import re
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ply.lex as lex
|
import ply.lex as lex
|
||||||
|
@ -51,6 +52,7 @@ tokens = [
|
||||||
"CBRACKET",
|
"CBRACKET",
|
||||||
"COMMA",
|
"COMMA",
|
||||||
"SYMBOL",
|
"SYMBOL",
|
||||||
|
"COLON",
|
||||||
] + list(reserved.values())
|
] + list(reserved.values())
|
||||||
|
|
||||||
def t_HEX(t):
|
def t_HEX(t):
|
||||||
|
@ -91,6 +93,8 @@ t_CBRACKET = r"\]"
|
||||||
|
|
||||||
t_COMMA = r","
|
t_COMMA = r","
|
||||||
|
|
||||||
|
t_COLON = ":"
|
||||||
|
|
||||||
def t_SYMBOL(t):
|
def t_SYMBOL(t):
|
||||||
r"[A-Za-z_][0-9A-Za-z_]*"
|
r"[A-Za-z_][0-9A-Za-z_]*"
|
||||||
t.type = reserved.get(t.value, "SYMBOL")
|
t.type = reserved.get(t.value, "SYMBOL")
|
||||||
|
@ -133,7 +137,8 @@ def p_expr_eval(p):
|
||||||
| SYMBOL LT number
|
| SYMBOL LT number
|
||||||
| SYMBOL GTEQ number
|
| SYMBOL GTEQ number
|
||||||
| SYMBOL LTEQ number
|
| SYMBOL LTEQ number
|
||||||
| SYMBOL IN list"""
|
| SYMBOL IN list
|
||||||
|
| SYMBOL COLON STR"""
|
||||||
p[0] = (p[2], p[1], p[3])
|
p[0] = (p[2], p[1], p[3])
|
||||||
|
|
||||||
def p_expr_single(p):
|
def p_expr_single(p):
|
||||||
|
@ -204,6 +209,8 @@ def ast_expr(ast, env):
|
||||||
return ast_sym(ast[1], env) in ast[2]
|
return ast_sym(ast[1], env) in ast[2]
|
||||||
elif ast[0] == "exists":
|
elif ast[0] == "exists":
|
||||||
return True if ast_sym(ast[1], env) else False
|
return True if ast_sym(ast[1], env) else False
|
||||||
|
elif ast[0] == ":":
|
||||||
|
return True if re.compile(ast[2]).match(ast_sym(ast[1], env)) else False
|
||||||
|
|
||||||
mutex = threading.Lock()
|
mutex = threading.Lock()
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ Each testcase.ini block can define the following key/value pairs:
|
||||||
| symbol ">=" number
|
| symbol ">=" number
|
||||||
| symbol "<=" number
|
| symbol "<=" number
|
||||||
| symbol "in" list
|
| symbol "in" list
|
||||||
|
| symbol ":" string
|
||||||
| symbol
|
| symbol
|
||||||
|
|
||||||
list ::= "[" list_contents "]"
|
list ::= "[" list_contents "]"
|
||||||
|
@ -110,6 +111,14 @@ Each testcase.ini block can define the following key/value pairs:
|
||||||
|
|
||||||
filter = not ARCH in ["x86", "arc"]
|
filter = not ARCH in ["x86", "arc"]
|
||||||
|
|
||||||
|
The ':' operator compiles the string argument as a regular expression,
|
||||||
|
and then returns a true value only if the symbol's value in the environment
|
||||||
|
matches. For example, if CONFIG_SOC="quark_se" then
|
||||||
|
|
||||||
|
filter = CONFIG_SOC : "quark.*"
|
||||||
|
|
||||||
|
Would match it.
|
||||||
|
|
||||||
Architectures and platforms are defined in an archtecture configuration
|
Architectures and platforms are defined in an archtecture configuration
|
||||||
file which are stored by default in scripts/sanity_chk/arches/. These
|
file which are stored by default in scripts/sanity_chk/arches/. These
|
||||||
each define an [arch] block with the following key/value pairs:
|
each define an [arch] block with the following key/value pairs:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue