-
Notifications
You must be signed in to change notification settings - Fork 3k
Basic test refactoring #5243
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
Basic test refactoring #5243
Conversation
#include "mbed.h" | ||
#include "greentea-client/test_env.h" | ||
#include "unity.h" |
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.
Please add the module to the inclusion path (see here).
In other words:
#include "unity/unity.h"
#include "utest/utest.h"
#include "rtos/rtos.h"
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.
link is not found
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.
I'm not sure why you cannot access the guidelines ( @0xc0170 any idea ? ). The guideline state:
* Header files should always be included using the module directory in the path.
* examples: #include “lwip/lwip-interface.h”, #include “drivers/Ticker.h”
* Limit the include path to only the module directory, this allows the module to be moved in the future.
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.
Good refactoring. Additional changes might even make it better:
- Is it necessary to have a second thread executing
gt_comm_wait_thread
? That function is the test and can be executed in thetest
function running in the main thread. - A mutex shall protect access to the variable
callback_trigger_count
.volatile
variables cannot be shared safely across different threads of execution. - There is two comments explaining what the test do: one at line 19 and the other as the documentation of the test function. It may be good to have a single comment block explaining how things work in detail.
- Some entities names are not descriptive or misleading: for example
callback_trigger_count
doesn't mean anything, it is a counter in seconds and it is not invoked from a callback. May you improve entities naming ?
|
||
#if defined(MBED_RTOS_SINGLE_THREAD) | ||
#error [NOT_SUPPORTED] test not supported | ||
#endif | ||
|
||
using namespace utest::v1; |
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.
Would it be possible to import the symbols needed rather than the whole namespace ?
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.
Generally I don't like importing anything, but rest of TEST code already use it. So I assumed that is prefered
If we don't want importing whole namespace we have to import following symbols:
using utest::v1::status_t;
using utest::v1::Case;
using utest::v1::Specification;
using utest::v1::greentea_test_setup_handler;
using utest::v1::greentea_test_teardown_handler;
using utest::v1::Harness;
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.
We do not have explicit rule on this item however, importing the minimal set of names used rather than the whole namespace may limit conflicts. We had some in the past with target code.
Thread tick_thread(osPriorityHigh, TEST_STACK_SIZE); | ||
/** Test DUT<->host interaction | ||
|
||
Given two threads (A & B) are started and thread A act as counter for time measure |
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.
Could you precise what thread B do ?
/** Test DUT<->host interaction | ||
|
||
Given two threads (A & B) are started and thread A act as counter for time measure | ||
When thread B initiates host communication and perform time measure test |
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.
It would be interesting to have a description of the "time measure test".
Generally I planned to do minimal changes to align this test to rest of the code from TEST folder. |
b92ee4e
to
cc4b406
Compare
@pan- Test was a bit redesigned |
It is not only redesigned, from what I see the purpose of the test has also been changed. Initially the purpose of the test was: |
You are right |
cc4b406
to
8f5d93f
Compare
@pan- updated after review |
8f5d93f
to
73a91e0
Compare
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.
Thanks for the refactoring
/morph build |
Build : SUCCESSBuild number : 124 Triggering tests/test mbed-os |
Test : SUCCESSBuild number : 62 |
Build : SUCCESSBuild number : 180 Triggering tests/test mbed-os |
Test : FAILUREBuild number : 77 |
/morph build |
Build : SUCCESSBuild number : 197 Triggering tests/morph test |
Test : SUCCESSBuild number : 96 |
/morph uvisor-test |
Build : SUCCESSBuild number : 223 Triggering tests/morph test |
Test : SUCCESSBuild number : 112 |
/morph uvisor-test |
Description
No functional changes only refactoring
Status
READY