-
Notifications
You must be signed in to change notification settings - Fork 3k
Replace calls to printf() with mbed-trace in netsocket tests #11861
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
Conversation
@maclobdell @ARMmbed/team-embeddedplanet @ithinuel |
@trowbridgec, thank you for your changes. |
Reading emac tests , we have there trace levels:
or using mbed_trace, rather than this custom wrapper? |
@ARMmbed/mbed-os-ipcore Please review, this PR should be part of 5.14.2 |
@ARMmbed/mbed-os-maintainers What is the best practice regarding console outputs and Are we supposed to print out anything at all? |
Printing should be okay as long as you only do it when the PC is waiting for a result. Otherwise it's a risk of breaking the protocol. I think I'd advocate using mbed_trace, and having it off by default - people can turn it on to investigate failures. But others spend more time working with tests than me. |
This is one of the grey areas. Most of the time test does not print anything by default, should not.
+1. @trowbridgec can we update this to use trace as proposed? |
@0xc0170 That sounds good to me. I've already tested that using trace also resolves this issue. I'll commit the changes shortly for the tests we've been having issues with, however it occurs to me now that there may be other tests using |
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.
LGTM
CI started. It might fail as there is master known issue |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
As this is critical, I hope this can be merged and released in 5.14.2 as is. @trowbridgec - in the future, in cases where you update your changes based on feedback, it is much preferred that you squash your commits down to one and force push back to your branch. This makes the git history cleaner. Since this is at a critical stage, I don't think that this is necessary right now, but it is good practice for later. |
600ea40
to
0592e95
Compare
@maclobdell I added similar fixes to the integration tests and squashed my commits. |
I think this will make tracing those even worse and potentially break test results completely. Enabling mbed-traces will most probably trace much more info than just these test case prints and as by default traces are not synced between threads. This causes greentea's own prints to getting corrupted resulting in failures to be reported even though test itself passed ok. |
@kivaisan Are saying that this change is not worth the effects that will be caused when trying to debug a test and trace is enabled? |
This isn't enabling the trace by default (I believe), so the output is prevented, so should be okay for CI. For human testing, turning on the trace will also turn on any internal trace, but that should be addressable by setting the level appropriately. However, all the trace here is at "debug" level which would be problematic. Turning on that will by default give you all other internal traces. Most of it should be at least "info" level. But you could still filter by the "GRNT" trace group. |
Would it be feasible to change greentea itself to use mbed-trace when mbed-trace is enabled? Then it would enable use of |
In terms of this as a general idea I will leave others more knowledgeable in this area to comment. However, irrespective of that it is certainly not feasible within the current timescales. Technically code freeze for 5.14.2 was yesterday so if this PR is to come in , it needs to do so at the very latest by Monday.... |
It should be quite feasible for it to claim a mutex that is registered with A small number of tests do output from interrupt though, which is why it's still using RawSerial generally (#6674), but most tests could use a mutex. If this PR is leaving trace off, so the reduction in output fixes a CI, then it could go to 5.14.2 as-is, and a follow-up could add that mutex to make turning trace on work better. |
@kivaisan This PR is not turning on mbed-trace by default for greentea tests; it is merely converting calls to {
"name": "mbed-trace",
"config": {
"enable": {
"help": "Used to globally enable traces.",
"value": null
},
"max-level": {
"help": "This flag is used to optimize the code size. For example, setting trace optimization level to TRACE_LEVEL_INFO will define all tr_debug() macros empty, which reduces the binary size. The possible optimization levels are TRACE_LEVEL_DEBUG, TRACE_LEVEL_INFO, TRACE_LEVEL_WARN, TRACE_LEVEL_ERROR and TRACE_LEVEL_CMD. To set the output tracing level, please use mbed_trace_config_set(TRACE_ACTIVE_LEVEL_INFO). The possible tracing levels for mbed_trace_config_set() are TRACE_ACTIVE_LEVEL_ALL, TRACE_ACTIVE_LEVEL_DEBUG (same as ALL), TRACE_ACTIVE_LEVEL_INFO, TRACE_ACTIVE_LEVEL_WARN, TRACE_ACTIVE_LEVEL_ERROR, TRACE_ACTIVE_LEVEL_CMD and TRACE_LEVEL_NONE.",
"value": null,
"macro_name": "MBED_TRACE_MAX_LEVEL"
},
"fea-ipv6": {
"help": "Used to globally disable ipv6 tracing features.",
"value": null
},
"allocator": {
"value": "malloc",
"macro_name": "MEM_ALLOC"
},
"deallocator": {
"value": "free",
"macro_name": "MEM_FREE"
}
}
}
@kjbracey-arm That's a good point...I can switch to using |
As a general rule, debug level should not normally (need to) be shown except when you really are debugging - I believe IceTea defaults to showing info and above. Anything vaguely interesting for a test run should be at least "info". Ideally we would have had the extra "notice" level between "info" and "warning" to be even more selective, but we don't. (In the Linux kernel you can't even turn on "debug" globally IIRC - you'd turn it on per module). |
0592e95
to
eac84ad
Compare
@kjbracey-arm could you please re-review update? I will put into CI in the meantime |
eac84ad
to
e59fbe5
Compare
Sorry, I had to fix an astyle issue...please re-review. |
CI started |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
e59fbe5
to
a1edbb9
Compare
CI restarted |
Test run: SUCCESSSummary: 5 of 5 test jobs passed |
Description (required)
Summary of change (What the change is for and why)
While troubleshooting why our cellular-enabled target (
EP_AGORA
) was failing some netsocket tests (DNS, TCP, UDP), we determined that the caused seemed to be related to serial output synchronization issues similar to what @ithinuel described in #9954 and #11202. Whenever the Greentea test would hit aprintf()
the test would hang and subsequent test cases would timeout. By replacing the calls toprintf()
with a new wrapper function calledprint_to_console()
(which internally callsprintf()
ifMBED_CONF_APP_DISABLE_LOGGING
is not defined) in this PR, all of the tests passed without issue on our target.For reference here is an example of an
mbed_app.config
file used with our target to pass the tests:Documentation (Details of any document updates required)
Pull request type (required)
Test results (required)
Reviewers (optional)
@maclobdell
@ithinuel
Release Notes (required for feature/major PRs)
Summary of changes
Impact of changes
Migration actions required