Skip to content

Commit

Permalink
Revert "sanitycheck: Add functions to query device tree for filters"
Browse files Browse the repository at this point in the history
PR zephyrproject-rtos#20204 broke master for boards without DTS
PR zephyrproject-rtos#20365 tried to partially fix it, but the filtering in
sanitycheck remained broken
Let's quickly revert it to allow other PRs to come in,
and then resubmit them in a separate PR.

This reverts commit 7733b94.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
  • Loading branch information
aescolar committed Nov 6, 2019
1 parent a3c33d6 commit 85d8864
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 51 deletions.
47 changes: 7 additions & 40 deletions scripts/sanity_chk/expr_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,6 @@ def p_expr_single(p):
"""expr : SYMBOL"""
p[0] = ("exists", p[1])

def p_func(p):
"""expr : SYMBOL OPAREN arg_intr CPAREN"""
p[0] = [p[1]]
p[0].append(p[3])

def p_arg_intr_single(p):
"""arg_intr : const"""
p[0] = [p[1]]

def p_arg_intr_mult(p):
"""arg_intr : arg_intr COMMA const"""
p[0] = copy.copy(p[1])
p[0].append(p[3])

def p_list(p):
"""list : OBRACKET list_intr CBRACKET"""
p[0] = p[2]
Expand Down Expand Up @@ -196,13 +182,13 @@ def ast_sym_int(ast, env):
return int(v, 10)
return 0

def ast_expr(ast, env, edt):
def ast_expr(ast, env):
if ast[0] == "not":
return not ast_expr(ast[1], env, edt)
return not ast_expr(ast[1], env)
elif ast[0] == "or":
return ast_expr(ast[1], env, edt) or ast_expr(ast[2], env, edt)
return ast_expr(ast[1], env) or ast_expr(ast[2], env)
elif ast[0] == "and":
return ast_expr(ast[1], env, edt) and ast_expr(ast[2], env, edt)
return ast_expr(ast[1], env) and ast_expr(ast[2], env)
elif ast[0] == "==":
return ast_sym(ast[1], env) == ast[2]
elif ast[0] == "!=":
Expand All @@ -221,29 +207,10 @@ def ast_expr(ast, env, edt):
return bool(ast_sym(ast[1], env))
elif ast[0] == ":":
return bool(re.match(ast[2], ast_sym(ast[1], env)))
elif ast[0] == "dt_compat_enabled":
compat = ast[1][0]
for node in edt.nodes:
if compat in node.compats and node.enabled:
return True
return False
elif ast[0] == "dt_alias_exists":
alias = ast[1][0]
for node in edt.nodes:
if alias in node.aliases and node.enabled:
return True
return False
elif ast[0] == "dt_compat_enabled_with_alias":
compat = ast[1][0]
alias = ast[1][1]
for node in edt.nodes:
if node.enabled and alias in node.aliases and node.matching_compat == compat:
return True
return False

mutex = threading.Lock()

def parse(expr_text, env, edt):
def parse(expr_text, env):
"""Given a text representation of an expression in our language,
use the provided environment to determine whether the expression
is true or false"""
Expand All @@ -255,7 +222,7 @@ def parse(expr_text, env, edt):
finally:
mutex.release()

return ast_expr(ast, env, edt)
return ast_expr(ast, env)

# Just some test code
if __name__ == "__main__":
Expand All @@ -277,4 +244,4 @@ def parse(expr_text, env, edt):
parser = yacc.yacc()
print(parser.parse(line))

print(parse(line, local_env, None))
print(parse(line, local_env))
17 changes: 6 additions & 11 deletions scripts/sanitycheck
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,6 @@ from itertools import islice
from pathlib import Path
from distutils.spawn import find_executable

ZEPHYR_BASE = os.getenv("ZEPHYR_BASE")
if not ZEPHYR_BASE:
sys.exit("$ZEPHYR_BASE environment variable undefined")

sys.path.insert(0, os.path.join(ZEPHYR_BASE, "scripts", "dts"))
import edtlib

import logging


Expand All @@ -216,6 +209,11 @@ report_lock = threading.Lock()
log_format = "%(levelname)s %(name)s::%(module)s.%(funcName)s():%(lineno)d: %(message)s"
logging.basicConfig(format=log_format, level=30)

ZEPHYR_BASE = os.environ.get("ZEPHYR_BASE")
if not ZEPHYR_BASE:
sys.stderr.write("$ZEPHYR_BASE environment variable undefined.\n")
exit(1)

# Use this for internal comparisons; that's what canonicalization is
# for. Don't use it when invoking other components of the build system
# to avoid confusing and hard to trace inconsistencies in error messages
Expand Down Expand Up @@ -1915,10 +1913,7 @@ class FilterBuilder(CMake):

if self.testcase and self.testcase.tc_filter:
try:
dts_path = os.path.join(self.build_dir, "zephyr", self.platform.name + ".dts.pre.tmp")
edt = edtlib.EDT(dts_path, [os.path.join(ZEPHYR_BASE, "dts", "bindings")])
res = expr_parser.parse(self.testcase.tc_filter, filter_data, edt)

res = expr_parser.parse(self.testcase.tc_filter, filter_data)
except (ValueError, SyntaxError) as se:
sys.stderr.write(
"Failed processing %s\n" % self.testcase.yamlfile)
Expand Down

0 comments on commit 85d8864

Please sign in to comment.