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

twister: add trace print in exception #81703

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hakehuang
Copy link
Collaborator

add trace print when exception happens

@hakehuang
Copy link
Collaborator Author

pre discussion in #80623

@hakehuang hakehuang force-pushed the twister_add_callstack_print branch 2 times, most recently from 9a01921 to e778ea7 Compare November 21, 2024 13:59
@hakehuang
Copy link
Collaborator Author

@nashif , @gchwier , @golowanow , @PerMac , @LukaszMrugala , @KamilxPaszkiet please review this.

Copy link
Member

@golowanow golowanow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR should clarify its commit description as it logs traces for TwisterException objects only.

.. and the stack trace output will be duplicated for all other Twister exceptions, but StatusAttributeError with their handlers.

Comment on lines 14 to 16
for line in traceback.format_stack():
logger.info(line.strip())
logger.warning("======call stack dump end============")
Copy link
Member

@golowanow golowanow Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way it will log the trace stack at once to reduce chances of other output in between, and to omit its last lines from TwisterException code itself.

Suggested change
for line in traceback.format_stack():
logger.info(line.strip())
logger.warning("======call stack dump end============")
logger.error(''.join(["Twister call stack dump:\n"] + traceback.format_stack()[:-1]))

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

The log traces for TwisterException objects only.
And the stack trace output follow the same rules for all exceptions,
but StatusAttributeError with its dedicated handlers.

Signed-off-by: Hake Huang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants