-
Notifications
You must be signed in to change notification settings - Fork 3k
Cordio: Add tests that validates a cordio port. #7221
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
The first test focuse on the transport by testing that the reset sequence is correctly sent to the controller and properly received. The second test validates that the reset sequence fullfill the right state of the stack and ensure that bluetooth initialization succeed.
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 a lot Vincent, a few issues as described
if (params->error == BLE_ERROR_NONE) { | ||
initialization_state = INITIALIZATION_SUCCESS; | ||
} else { | ||
initialization_state = INITIALIZATION_SUCCESS; |
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.
The other one ;)
using namespace utest::v1; | ||
using mbed::callback; | ||
|
||
#define INITIALIZATION_TIMEOUT (10 * 1000) |
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.
Is it actually acceptable for the initialisation process to take this long?
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.
Yes, at first I was thinking of setting it to 30 seconds; if the bitrate is low and the controller require a large service pack then initialization can takes a loooooot of time.
TEST_ASSERT_NOT_EQUAL(0, hciCoreCb.availBufs); | ||
|
||
uint8_t invalid_le_states[HCI_LE_STATES_LEN] = { 0 }; | ||
TEST_ASSERT_NOT_EQUAL(0, memcmp(invalid_le_states, hciCoreCb.leStates, HCI_LE_STATES_LEN)); |
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.
Can you just add a quick comment (as hciCoreCb
is an internal Cordio struct, so not immediately obvious what you're testing here)
} | ||
break; | ||
} | ||
|
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.
You should break from the for loop here if test_result
is TEST_RESULT_FAILURE
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.
doesn't the if do that? it'll break (return) on any result change
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.
Yes, the if does that whenever a result is present (success or failure).
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.
OK - there are a few things that confused me, now I understand what you're doing. Few questions/remarks:
- Could you rename
TEST_RESULT_TIMEOUT_FAILURE
to something more explicit (like 'in progress'); it hasn't timed out till proven otherwise - At the moment, if you don't know the HCI OpCode's value, you skip to the next byte - which would be parameters' length; what's the rationale behind this? Skipping padding bytes? You could interpret the length field (and subsequent parameters) as OpCodes in the current implementation
break; | ||
} | ||
|
||
if (test_result != TEST_RESULT_TIMEOUT_FAILURE) { |
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.
Presumably that should be outside of the for loop?
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.
Why ? there's no guarantee that data in input is at the event boundary and it may fail early.
} | ||
|
||
Case cases[] = { | ||
Case("Test reset command", test_reset_command), |
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 add a second test that issues multiple reset commands + initialize()
/terminate()
?
} | ||
break; | ||
} | ||
|
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.
OK - there are a few things that confused me, now I understand what you're doing. Few questions/remarks:
- Could you rename
TEST_RESULT_TIMEOUT_FAILURE
to something more explicit (like 'in progress'); it hasn't timed out till proven otherwise - At the moment, if you don't know the HCI OpCode's value, you skip to the next byte - which would be parameters' length; what's the rationale behind this? Skipping padding bytes? You could interpret the length field (and subsequent parameters) as OpCodes in the current implementation
The existing test was expecting that the acknowledgement of the reset command would be the first and only event receive. This assumption is false. As a consequence, the new code parse all incoming packets and raise a flag in the following circumstances: * a reset packet has been successfully received. * RX stream is not synchronized * The status of the reset command is an error. Another test has been added that send a serie of reset commands.
@donatieng @paul-szczepanek-arm I've rewritten the logic in the transport test: all incoming packet are parsed and a flag is raised whenever:
In the process I've added a second test that sends a serie of reset commands and waits for response events. |
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 a lot @pan-, this addresses all of my issues 👍
/morph build |
Build : SUCCESSBuild number : 2423 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2053 |
Test : SUCCESSBuild number : 2204 |
Description
The first test focuse on the transport by testing that the reset sequence is
correctly sent to the controller and properly received.
The second test validates that the reset sequence fullfill the right state
of the stack and ensure that bluetooth initialization succeed.
Pull request type