Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: twister: Unrecognized section test solution 4 #1

Draft
wants to merge 2 commits into
base: lmrugalx_unrecognized_sections
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
scripts: twister: Unrecognized section test solution 4
This solution to the unrecognized section test crisis makes
the check raise warnings instead of errors by default.

Users as well as test creators are able to elevate warns
to error via CLI flags and testcase.yaml.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
  • Loading branch information
LukaszMrugala committed Apr 4, 2024
commit 554fe7656478b492ab99032b20c1ffd53e892554
1 change: 1 addition & 0 deletions scripts/pylib/twister/twisterlib/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TwisterConfigParser:
"extra_conf_files": {"type": "list", "default": []},
"extra_overlay_confs" : {"type": "list", "default": []},
"extra_dtc_overlay_files": {"type": "list", "default": []},
"fail_on_unrecognized_section_test": {"type": "bool", "default": False},
"required_snippets": {"type": "list"},
"build_only": {"type": "bool", "default": False},
"build_on_all": {"type": "bool", "default": False},
Expand Down
10 changes: 9 additions & 1 deletion scripts/pylib/twister/twisterlib/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def add_parse_arguments(parser = None):

test_xor_generator = case_select.add_mutually_exclusive_group()

unrecognized_section_test_group = parser.add_mutually_exclusive_group()

valgrind_asan_group = parser.add_mutually_exclusive_group()

case_select.add_argument(
Expand Down Expand Up @@ -345,11 +347,17 @@ def add_parse_arguments(parser = None):
dest="enable_asserts",
help="deprecated, left for compatibility")

parser.add_argument(
unrecognized_section_test_group.add_argument(
"--disable-unrecognized-section-test", action="store_true",
default=False,
help="Skip the 'unrecognized section' test.")

unrecognized_section_test_group.add_argument(
"--fail-on-unrecognized-section-test", action="store_true",
default=False,
help="The 'unrecognized section' test will now fail the testcase, "
"rather than just sending out a warning.")

parser.add_argument(
"--disable-suite-name-check", action="store_true", default=False,
help="Disable extended test suite name verification at the beginning "
Expand Down
43 changes: 28 additions & 15 deletions scripts/pylib/twister/twisterlib/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,24 +663,37 @@ def process(self, pipeline, done, message, lock, results):

elif op == "gather_metrics":
self.gather_metrics(self.instance)
next_op = {}

# Unrecognized binary section test
if self.instance.metrics.get("unrecognized") and \
not self.options.disable_unrecognized_section_test:
logger.error(f"{Fore.RED}FAILED{Fore.RESET}:"
f" {self.instance.name} has unrecognized binary sections:"
f" {self.instance.metrics.get('unrecognized')}")
self.instance.status = "failed"
self.instance.reason = f"Unrecognized binary sections:" \
f" {self.instance.metrics.get('unrecognized')}"
pipeline.put({
"op": "report",
"test": self.instance,
"status": self.instance.status,
"reason": self.instance.reason
})
elif self.instance.run and self.instance.handler.ready:
pipeline.put({"op": "run", "test": self.instance})
should_fail = self.options.fail_on_unrecognized_section_test \
if self.instance.testsuite.fail_on_unrecognized_section_test is None \
else self.instance.testsuite.fail_on_unrecognized_section_test
if should_fail:
logger.error(f"{Fore.RED}FAILED{Fore.RESET}:"
f" {self.instance.name} has unrecognized binary sections:"
f" {self.instance.metrics.get('unrecognized')}")
self.instance.status = "failed"
self.instance.reason = f"Unrecognized binary sections:" \
f" {self.instance.metrics.get('unrecognized')}"
next_op = {
"op": "report",
"test": self.instance,
"status": self.instance.status,
"reason": self.instance.reason
}
else:
logger.warning(f" {self.instance.name} has unrecognized binary sections:"
f" {self.instance.metrics.get('unrecognized')}")

if self.instance.run and self.instance.handler.ready:
next_op = {"op": "run", "test": self.instance} if not next_op else next_op
else:
pipeline.put({"op": "report", "test": self.instance})
next_op = {"op": "report", "test": self.instance} if not next_op else next_op

pipeline.put(next_op)

# Run the generated binary using one of the supported handlers
elif op == "run":
Expand Down
3 changes: 3 additions & 0 deletions scripts/schemas/twister/testsuite-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ schema;scenario-schema:
required: false
sequence:
- type: str
"fail_on_unrecognized_section_test":
type: bool
required: false
"filter":
type: str
required: false
Expand Down
Loading