-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add a Unity macro to assert on platform error code difference #8646
Conversation
@SenRamakri - Please review |
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 to me 👍
@ARMmbed/mbed-os-test Please review |
@ARMmbed/mbed-os-test reminder: Please review |
@ARMmbed/mbed-os-test another reminder: Please review |
/morph build |
*-------------------------------------------------------*/ | ||
// Use these to check whether error code equals what we expect. | ||
// Only display error code (without other information) | ||
#define TEST_ASSERT_EQUAL_ERROR_CODE(expected, actual) TEST_ASSERT_EQUAL(expected & MBED_ERROR_STATUS_CODE_MASK, actual & MBED_ERROR_STATUS_CODE_MASK) |
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.
Hi David, Instead of using the error mask directly can you please use the macro MBED_GET_ERROR_CODE() macro. The reason is depending on error type the error code is encoded differently(this is due to support for Posix errors). Using the macro makes the code more portable?
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.
Fixed.
8791a2b
to
42e0ef3
Compare
/morph build |
Build : FAILUREBuild number : 3631 |
@davidsaada Please take a look at the build failure. Looks like there's something wrong with the PR's implementation when it's compiled with IAR. |
42e0ef3
to
3995779
Compare
IAR build problem was bypassed by removing the include to "mbed_error.h". This should be OK, as the only change here was in a macro, which should be used by users of mbed errors anyway.
|
/morph build |
Build : SUCCESSBuild number : 3634 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 3241 |
Test : FAILUREBuild number : 3416 |
Sporadic NRF52 RTC test issue. Will retest when able. |
Info: This PR has now been bundled into a rollup PR (#8760). The CI failures that this PR saw do not appear to be the fault of the PR. To save time in retesting this PR, along with other PRs that experienced similar issues, it has been bundled into a rollup PR. If any more commits are made in this PR, this PR will remain open and have to go through CI on its own. |
Info: This PR has been re-bundled into a new rollup PR (#8763). The previous rollup found an issue with a bundled PR after new devices were added into master. The PR needing work has been removed. No further work is needed here, as once that PR is merged, this PR will also be closed and marked as merged. |
Description
Current platform error codes, defined in mbed_error.h header file, consist of the error code along with other information such as the module ID. This means that if we have a test that checks for the error code, an unexpected result would show a very large (negative) number, requiring user parsing in order to understand the real error.
This PR adds
TEST_ASSERT_EQUAL_ERROR_CODE
andTEST_ASSERT_EQUAL_ERROR_CODE_MESSAGE
macros, checking only the status code (lower part) of the full error code, showing the interesting part of the error in case of a mismatch.Pull request type