-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
twister: harness: Fix several issues at Console harness #63902
twister: harness: Fix several issues at Console harness #63902
Conversation
73984f3
to
3dd7717
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one minor comment
3dd7717
to
9edae34
Compare
@nashif, @galak, @gopiotr, @hakehuang, @PerMac - up to your attention |
can you point to an example where this happens? |
current main branch (
with this fix:
|
ok. While your workaround might deal with the issue, the problem here is that the test is wrong. It can't be both a ztest and a console test. We either use ztest and rely on passing tests reporting based on ztest output or we rely on the console output, having both is wrong. |
@@ -162,6 +163,14 @@ class Console(Harness): | |||
|
|||
def configure(self, instance): | |||
super(Console, self).configure(instance) | |||
if self.regex is None or len(self.regex) == 0: | |||
self.state = "failed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the definition of the testcase is wrong, this should be treated as an error. So, instead of doing this here and calling this a fail, error already during the parsing of the test (in config_parser.py)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if this can be dealt with on the schema level, i.e.. disallowing empty sequences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if this can be dealt with on the schema level, i.e.. disallowing empty sequences.
pykwalify has allowempty
but for `map' type only
https://pykwalify.readthedocs.io/en/unstable/validation-rules.html#allowempty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the definition of the testcase is wrong, this should be treated as an error.
changed to 'error' status for instances
So, instead of doing this here and calling this a fail, error already during the parsing of the test (in config_parser.py)
it seems not easy to avoid these checks here with the current twister harness design: testsute-schema.yaml
defines common harness_config
for all types of harnesses simultaneously and parser checks for its presence with allowed (not required) properties. Later harness configure()
needs to check what it got from the test instance in regard of the specific harness class.
9edae34
to
c670eed
Compare
c670eed
to
37f57b6
Compare
Fix the Twister Console harness unordered pattern matching to treat the ztest as failed when not all of the expected patterns were found in the console output, but the ztest application itself reports 'PROJECT EXECUTION SUCCESSFUL'. Unify debug logging on pattern match for ordered and unordered patterns. Signed-off-by: Dmitrii Golovanov <[email protected]>
If Console Harness 'harness_config' properties have no 'regex' patterns or no correct 'type' set, then ConfigurationError exception is raised, handled, and the test instance error is accounted in the summary results. Signed-off-by: Dmitrii Golovanov <[email protected]>
37f57b6
to
52c39d6
Compare
@nashif , that particular testcase wrong implementation (coredump_backends.logging) is now addressed by #64937 |
Console Harness id has only TestSuite id without TestCase name suffix. | ||
TODO: Only the first TestCase name is taken if available. | ||
''' | ||
if self.instance is not None and len(self.instance.testcases) == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in python shall we just use below?
if self.instance is not None and len(self.instance.testcases) == 1: | |
if self.instance and self.instance.testcases: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this workaround is applicable with a single Ztest testcase only.
I've simplified this if
statement; also better description is added for this method as well as for the commit message.
else: | ||
self.state = "failed" | ||
tc = self.instance.set_case_status_by_name( | ||
self.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use self.get_testcase_name() for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, I've forgot it here.
Implement a workaround for Console harness to compose TestCase identifier correctly when a Ztest suite with a single testcase uses this harness type. Normally, a Ztest suite should use the Ztest Twister harness. Without this workaround each Ztest TestCase result on Console is duplicated (and written into twister.json) with its 'identifier' attribute set to TestSuite id only, no TestCase suffix added; the resulting entry with the full TestCase id is also stored, but its values are empty with defaults. Signed-off-by: Dmitrii Golovanov <[email protected]>
52c39d6
to
2ea008e
Compare
Twister Console Harness several fixes and small improvements:
Fix unordered pattern matching to treat the ztest as failed when not all of the expected patterns were found in the console output, but the ztest application itself reports 'PROJECT EXECUTION SUCCESSFUL'.
Extends twister: harness: Fix Console pattern matching for ztest #63621
Unify debug logging on pattern match for ordered and unordered patterns.
Check for non-empty pattern list configured for Console: If Console Harness has no regexp pattens configured, then ConfigurationError is raised, handled, and the failure of the test case correctly accounted in the summary results.
Implement a workaround for Console harness to compose TestCase identifier correctly when Ztest suite with a single TestCase is executed (generally, Ztest suite should use Ztest harness).
Without the fix each TestCase result at Console is duplicated (and written into twister.json) with short 'identifier' set to TestSuite id only, without TestCase suffix added. The resulting entry with the full TestCase id is also stored, but its values are set empty to defaults.