Skip to content

Add newline after mbed error so greentea shows it #10964

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

Merged
merged 1 commit into from
Jul 5, 2019

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Jul 4, 2019

Description

When the function error is called without ending in a newline greentea will not display the error. This is because greentea is performing line buffering.

This patch ensures that all calls to error end with a newline. This is done by adding an additional newline to end end of the string.

Example code exhibiting this problem:

error("This function is not supported.");

Greentea output before this change:

++ MbedOS Error Info ++​
Error Status: 0x80FF0100 Code: 256 Module: 255​
Error Message: Fatal Run-time error​
Location: 0x1001766D​
Error Value: 0x0​
Current Thread: main  Id: 0x8003FD8 Entry: 0x1000E64F StackSize: 0x1000 StackMem: 0x8004AE8 SP: 0x8005898​
For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=target​
-- MbedOS Error Info --​
test suite run finished after 240.50 sec...

Greentea output after this change:

++ MbedOS Error Info ++​
Error Status: 0x80FF0100 Code: 256 Module: 255​
Error Message: Fatal Run-time error​
Location: 0x1001766D​
Error Value: 0x0​
Current Thread: main  Id: 0x8003FD8 Entry: 0x1000E64F StackSize: 0x1000 StackMem: 0x8004AE8 SP: 0x8005898​
For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=target​
-- MbedOS Error Info --​
This function is not supported.
test suite run finished after 240.50 sec...

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

When the function `error` is called without ending in a newline
greentea will not display the error. This is because greentea is
performing line buffering.

This patch ensures that all calls to `error` end with a newline. This
is done by adding an additional newline to end end of the string.

Example code exhibiting this problem:
error("This function is not supported.");

Greentea output before this change:
++ MbedOS Error Info ++​
Error Status: 0x80FF0100 Code: 256 Module: 255​
Error Message: Fatal Run-time error​
Location: 0x1001766D​
Error Value: 0x0​
Current Thread: main  Id: 0x8003FD8 Entry: 0x1000E64F StackSize: 0x1000 StackMem: 0x8004AE8 SP: 0x8005898​
For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=target​
-- MbedOS Error Info --​
test suite run finished after 240.50 sec...

Greentea output after this change:
++ MbedOS Error Info ++​
Error Status: 0x80FF0100 Code: 256 Module: 255​
Error Message: Fatal Run-time error​
Location: 0x1001766D​
Error Value: 0x0​
Current Thread: main  Id: 0x8003FD8 Entry: 0x1000E64F StackSize: 0x1000 StackMem: 0x8004AE8 SP: 0x8005898​
For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=target​
-- MbedOS Error Info --​
This function is not supported.
test suite run finished after 240.50 sec...
@ciarmcom ciarmcom requested a review from a team July 4, 2019 21:00
@ciarmcom
Copy link
Member

ciarmcom commented Jul 4, 2019

@c1728p9, thank you for your changes.
@ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

@ciarmcom ciarmcom requested a review from a team July 4, 2019 21:00
@0xc0170
Copy link
Contributor

0xc0170 commented Jul 5, 2019

@kjbracey-arm We had discussions around newlines. I recall some patches adding newline in strings by themselves. This patch is important to have for the next week.

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

Thought we'd ensured a newline somewhere else recently for the same reason, but I guess it wasn't on this path.

@jeromecoutant
Copy link
Collaborator

Is this fixing #10626 ?

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 5, 2019

CI started (expected cloud client test to fail, we are investigating this)

@kjbracey
Copy link
Contributor

kjbracey commented Jul 5, 2019

I recall some patches adding newline in strings by themselves.

Ew, no. ROM space! Some APIs are inherently "single-line per call" (for potential packetisation purposes) like tr_info, and MBED_ERROR, so the newline/message boundary is implied.

error is potentially free-form like printf, so could be multiple-line or single line, but as it's fatal, sticking a final newline on just in case is fine, and can't cause any formatting grief.

Callers should only have to put their own newlines in when it's a free-form API that can actually print part of a line at a time, like printf. (You're not printing part of a line at a time with error!)

Is this fixing #10626 ?

So it is. That's what I was recalling. So we just talked about it, didn't do it...

@mbed-ci
Copy link

mbed-ci commented Jul 5, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jul 5, 2019

Hi @jeromecoutant this fixes #10626. Thanks for pointing this out. I didn't realize there was an open issue when I created the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants