Skip to content

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

Merged
merged 4 commits into from
Jun 22, 2018

Conversation

pan-
Copy link
Member

@pan- pan- commented Jun 14, 2018

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

[ ] Fix
[ ] Refactor
[ ] New target
[X] Feature
[ ] Breaking change

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.
Copy link
Contributor

@donatieng donatieng left a 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;
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Member Author

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));
Copy link
Contributor

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;
}

Copy link
Contributor

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

Copy link
Member

@paul-szczepanek-arm paul-szczepanek-arm Jun 19, 2018

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

Copy link
Member Author

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).

Copy link
Contributor

@donatieng donatieng Jun 20, 2018

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) {
Copy link
Contributor

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?

Copy link
Member Author

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),
Copy link
Contributor

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;
}

Copy link
Contributor

@donatieng donatieng Jun 20, 2018

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

pan- added 3 commits June 20, 2018 12:00
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.
@pan-
Copy link
Member Author

pan- commented Jun 20, 2018

@donatieng @paul-szczepanek-arm I've rewritten the logic in the transport test: all incoming packet are parsed and a flag is raised whenever:

  • A reset packet has been received
  • RX is synced with the controller
  • The status of the reset packet is incorrect.

In the process I've added a second test that sends a serie of reset commands and waits for response events.

Copy link
Contributor

@donatieng donatieng left a 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 👍

@cmonr
Copy link
Contributor

cmonr commented Jun 21, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jun 21, 2018

Build : SUCCESS

Build number : 2423
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7221/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jun 21, 2018

@mbed-ci
Copy link

mbed-ci commented Jun 22, 2018

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