-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
tests: twister: using statemachine for status #80623
base: main
Are you sure you want to change the base?
Conversation
673ece9
to
7c6608d
Compare
is there already differentiation on status transitions for Harness, TestCase, TestSuite, and TestInstance ? |
No, but I need clean the ci failures. BTW do you happen to know why this change does not get execute? |
because we are running in pull_request_target mode. |
then how can I change this? @nashif |
c02927f
to
43ea148
Compare
eddffa7
to
01598ad
Compare
@hakehuang to elaborate: pull_request_target means that the source is taken from the target pranch, not the PR. So your change has to be already in the tree to take place, which afaik doesn't allow to test the change itself within the PR. But you can split the workflow change from the rest and marge it to your github fork and then see if it works. Providing a link to a PR on a fork with the workflow change included and working could help with the review. |
To reviewers: this PR requires manual testing before being approved |
@hakehuang Please provide more details. |
01598ad
to
6bed985
Compare
@golowanow , from my observation, the Harness, TestCase, TestSuite and TestInstance transtions can follow one rule set. do you see any exceptions? |
The purposes of this PR:
|
d79db2e
to
cc42b35
Compare
well, potentially they can be in the same space, but according to these comments, there is significant differences in transitions, e.g. only some states/transitions valid for Harness, blocked is TestCase only, etc. zephyr/scripts/pylib/twister/twisterlib/statuses.py Lines 54 to 68 in cc42b35
|
I see, let me add harness transition |
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.
IMO: Exception handling is a good candidate for a separate PR.
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.
IMO: Exception handling is a good candidate for a separate PR.
yeah, #80866
|
||
class TwisterException(Exception): | ||
pass | ||
def __init__(self, message="TwisterException"): |
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.
You pass only a class name in every subclasses, maybe better to add class name to exception message in one place, e.g.:
def __init__(self, message=None):
if message is None:
message = self.__class__.__name__
else:
message = f"{self.__class__.__name__}: {message}"
super().__init__(message)
pass | ||
def __init__(self, message="TwisterException"): | ||
super().__init__(message) | ||
for line in traceback.format_stack(): |
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.
you can just call logger.exception(msg)
to print the callback, however the traceback is usually more relevant when the exception is caught rather than when it is created,
except exceptions.TransitionNotAllowed: | ||
# here we violate the pre-defined transition rules | ||
self.force_state(event) | ||
g() |
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.
just use
logger.exception(f"Transition from {self.current_state} to {event} is not allowed.")
instead of adding extra g()
method
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.
BTW, I received
Transition from passed to passed is not allowed
after running:
./scripts/twister -vv --no-clean -T samples/hello_world -p native_sim
cc42b35
to
2166e9f
Compare
using StateMachine in status change. in stastus.py we can generated the StateMachine by get_graph Signed-off-by: Hake Huang <[email protected]>
add pip install step for twister Signed-off-by: Hake Huang <[email protected]>
add trace print when exception happens Signed-off-by: Hake Huang <[email protected]>
update test cases for twister 1. test_errors.py add protection. 2. test_handlers.py change call to status 3. test_testsuite.py change call to status Signed-off-by: Hake Huang <[email protected]>
2166e9f
to
14b588e
Compare
using statuemachine in status change.
in stastus.py we can generated the statuemachine
by get_graph
The purposes of this PR:
TransitionNotAllowed
exception will be triggered, and call context will be print.TwisterStatusMachine_inner.cycles
, you can generate the status.png by runpython3 ./statues.py