d15bcfe83a | ||
---|---|---|
.. | ||
README.md | ||
main.cpp | ||
networkinterface_conn_disc_repeat.cpp | ||
networkinterface_status.cpp | ||
networkinterface_tests.h |
README.md
Network interface test plan
Target API
The goal of this plan is to test NetworkInterface.h
Tools needed
- Mbed OS.
- Standard Mbed OS development tools as described in the Arm Mbed tools overview.
Test environment
Test case priorities
Please refer to the following table for priorities of test cases. Priorities are labeled as MUST and SHOULD. MUST means this is a requirement and therefore mandatory to pass the test. SHOULD means it is recommended to pass the test if the driver implements the feature in question.
Test case | Priority | |
---|---|---|
1 | NETWORKINTERFACE_CONN_DISC_REPEAT | MUST |
2 | NETWORKINTERFACE_STATUS | MUST |
3 | NETWORKINTERFACE_STATUS_NONBLOCK | MUST |
4 | NETWORKINTERFACE_STATUS_GET | MUST |
Building test binaries
For testing the board and driver, test against the Mbed OS master branch to get the most recent, up-to-date test cases and drivers.
To create a build environment:
mbed new network_interface_test
cd network_interface_test
cd mbed-os
git checkout master
cd ..
Now build test binaries:
mbed test --compile -t <toolchain> -m <target> -n mbed-os-tests-network-interface
Running tests
When device is connected to network, or if a wireless device is near the access point:
mbed test -n mbed-os-tests-network-interface
Test cases for NetworkInterface class
NETWORKINTERFACE_CONN_DISC_REPEAT
Description:
Test NetworkInterface::connect()
and NetworkInterface::disconnect()
Precondition:
Network interface is initialized.
Test steps:
- Connect interface.
- Disconnect interface.
- Repeat connect and disconnect steps 1 to 2 four times.
Expected result:
Connect()
and disconnect()
calls return NSAPI_ERROR_OK
.
NETWORKINTERFACE_STATUS
Description:
Test NetworkInterface::attach()
and status indications.
Preconditions:
- Network interface is initialized.
- Status callback is attached to the network interface.
- Network interface is on blocking mode.
Test steps:
- Connect interface.
- Check that interface indicates status
NSAPI_STATUS_CONNECTING
. - Optional: Check that interface indicates status
NSAPI_STATUS_LOCAL_UP
(whether this is indicated depends on network interface type). - Check that interface indicates status
NSAPI_STATUS_GLOBAL_UP
. - Disconnect interface.
- Check that interface indicates status
NSAPI_STATUS_DISCONNECTED
. - Repeat connect and disconnect steps 1 to 6 four times.
Expected result:
Callback statuses are correct. Connect()
and disconnect()
calls return NSAPI_ERROR_OK
. Note: The network interface may indicate the same status several times in a row, depending on the network interface type. This will not fail the test.
NETWORKINTERFACE_STATUS_NONBLOCK
Description:
Test NetworkInterface::attach()
and status indications on nonblocking mode.
Preconditions:
- Network interface is initialized.
- Status callback is attached to the network interface.
- Network interface is on nonblocking mode.
Test steps:
- Connect interface.
- Check that interface indicates status
NSAPI_STATUS_CONNECTING
. - Optional: Check that interface indicates status
NSAPI_STATUS_LOCAL_UP
(whether this is indicated depends on network interface type). - Check that interface indicates status
NSAPI_STATUS_GLOBAL_UP
. - Disconnect interface.
- Check that interface indicates status
NSAPI_STATUS_DISCONNECTED
. - Repeat connect and disconnect steps 1 to 6 four times.
Expected result:
Callback statuses are correct. Connect()
and disconnect()
calls return NSAPI_ERROR_OK
. Note: The network interface may indicate the same status several times in a row, depending on the network interface type. This will not fail the test.
NETWORKINTERFACE_STATUS_GET
Description:
Test NetworkInterface::get_connection_status()
.
Preconditions:
- Network interface is initialized.
- Network interface is on blocking mode.
Test steps:
- Check that
get_connection_status()
returns statusNSAPI_STATUS_DISCONNECTED
. - Connect interface.
- Poll the
get_connection_status()
until it returns statusNSAPI_STATUS_GLOBAL_UP
. - Disconnect interface.
- Check that
get_connection_status()
returns statusNSAPI_STATUS_DISCONNECTED
. - Repeat connect and disconnect steps 2 to 5 four times.
Expected result:
Connect()
and disconnect()
calls return NSAPI_ERROR_OK
. The right status is returned by get_connection_status()
.