takashi kadono
/
Nucleo446_SSD1331
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/TESTS/netsocket/README.md@0:8fdf9a60065b, 2018-10-10 (annotated)
- Committer:
- kadonotakashi
- Date:
- Wed Oct 10 00:33:53 2018 +0000
- Revision:
- 0:8fdf9a60065b
how to make mbed librry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | Network Socket test plan |
kadonotakashi | 0:8fdf9a60065b | 2 | ======================== |
kadonotakashi | 0:8fdf9a60065b | 3 | |
kadonotakashi | 0:8fdf9a60065b | 4 | This is a test plan for the Mbed OS Socket API. This describes all test |
kadonotakashi | 0:8fdf9a60065b | 5 | cases and their intended behaviors. When an API document is not clear, use |
kadonotakashi | 0:8fdf9a60065b | 6 | this as a reference for implementing correct behavior. |
kadonotakashi | 0:8fdf9a60065b | 7 | |
kadonotakashi | 0:8fdf9a60065b | 8 | **NOTE:** Because testing is a moving target, this test plan might define more test cases than Mbed OS |
kadonotakashi | 0:8fdf9a60065b | 9 | implements. Refer to [test case priorities](#test-case-priorities) for a list of test cases that the target must pass to be compliant with the Mbed OS socket API. |
kadonotakashi | 0:8fdf9a60065b | 10 | |
kadonotakashi | 0:8fdf9a60065b | 11 | |
kadonotakashi | 0:8fdf9a60065b | 12 | Target API |
kadonotakashi | 0:8fdf9a60065b | 13 | ---------- |
kadonotakashi | 0:8fdf9a60065b | 14 | |
kadonotakashi | 0:8fdf9a60065b | 15 | The target for this plan is to test: |
kadonotakashi | 0:8fdf9a60065b | 16 | |
kadonotakashi | 0:8fdf9a60065b | 17 | - [Socket](https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/Socket.h). |
kadonotakashi | 0:8fdf9a60065b | 18 | - [UDPSocket](https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/UDPSocket.h). |
kadonotakashi | 0:8fdf9a60065b | 19 | - [TCPSocket](https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/TCPSocket.h). |
kadonotakashi | 0:8fdf9a60065b | 20 | - [TCPServer](https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/TCPServer.h). |
kadonotakashi | 0:8fdf9a60065b | 21 | |
kadonotakashi | 0:8fdf9a60065b | 22 | Reference documentation: https://os.mbed.com/docs/latest/reference/network-socket.html |
kadonotakashi | 0:8fdf9a60065b | 23 | |
kadonotakashi | 0:8fdf9a60065b | 24 | Tools to use |
kadonotakashi | 0:8fdf9a60065b | 25 | ---------------- |
kadonotakashi | 0:8fdf9a60065b | 26 | |
kadonotakashi | 0:8fdf9a60065b | 27 | - Mbed OS. |
kadonotakashi | 0:8fdf9a60065b | 28 | - Standard Mbed OS development tools as described in https://os.mbed.com/docs/latest/tools/index.html. |
kadonotakashi | 0:8fdf9a60065b | 29 | - Test server. |
kadonotakashi | 0:8fdf9a60065b | 30 | |
kadonotakashi | 0:8fdf9a60065b | 31 | These test cases themselves do not require any special tooling, other than |
kadonotakashi | 0:8fdf9a60065b | 32 | the test server described in "Test environment" chapter. |
kadonotakashi | 0:8fdf9a60065b | 33 | |
kadonotakashi | 0:8fdf9a60065b | 34 | Test environment |
kadonotakashi | 0:8fdf9a60065b | 35 | ---------------- |
kadonotakashi | 0:8fdf9a60065b | 36 | |
kadonotakashi | 0:8fdf9a60065b | 37 | As a general guideline, network connectivity with public Internet access |
kadonotakashi | 0:8fdf9a60065b | 38 | is required. This satisfies Socket tests, but specific connectivity |
kadonotakashi | 0:8fdf9a60065b | 39 | methods might require some extra configuration or devices within the |
kadonotakashi | 0:8fdf9a60065b | 40 | network. |
kadonotakashi | 0:8fdf9a60065b | 41 | |
kadonotakashi | 0:8fdf9a60065b | 42 | The test environment consist of DUTs, network connection and the test |
kadonotakashi | 0:8fdf9a60065b | 43 | server. Arm provides a public test server, but it can be installed locally |
kadonotakashi | 0:8fdf9a60065b | 44 | as well, if an isolated test environment is required. |
kadonotakashi | 0:8fdf9a60065b | 45 | |
kadonotakashi | 0:8fdf9a60065b | 46 | ### Public test server |
kadonotakashi | 0:8fdf9a60065b | 47 | |
kadonotakashi | 0:8fdf9a60065b | 48 | Address: `echo.mbedcloudtesting.com` |
kadonotakashi | 0:8fdf9a60065b | 49 | |
kadonotakashi | 0:8fdf9a60065b | 50 | Both IPv4 and IPv6 addresses are available from a public DNS service: |
kadonotakashi | 0:8fdf9a60065b | 51 | |
kadonotakashi | 0:8fdf9a60065b | 52 | ```.sh |
kadonotakashi | 0:8fdf9a60065b | 53 | $ host echo.mbedcloudtesting.com |
kadonotakashi | 0:8fdf9a60065b | 54 | echo.mbedcloudtesting.com has address 52.215.34.155 |
kadonotakashi | 0:8fdf9a60065b | 55 | echo.mbedcloudtesting.com has IPv6 address 2a05:d018:21f:3800:8584:60f8:bc9f:e614 |
kadonotakashi | 0:8fdf9a60065b | 56 | ``` |
kadonotakashi | 0:8fdf9a60065b | 57 | |
kadonotakashi | 0:8fdf9a60065b | 58 | **Open services in the test server** |
kadonotakashi | 0:8fdf9a60065b | 59 | |
kadonotakashi | 0:8fdf9a60065b | 60 | - Echo protocol, [RFC 862](https://tools.ietf.org/html/rfc862) is |
kadonotakashi | 0:8fdf9a60065b | 61 | enabled in both TCP and UDP. Port 7. |
kadonotakashi | 0:8fdf9a60065b | 62 | - Discard protocol, [RFC 863](https://tools.ietf.org/html/rfc863) is |
kadonotakashi | 0:8fdf9a60065b | 63 | enabled in both TCP and UDP. Port 9. |
kadonotakashi | 0:8fdf9a60065b | 64 | - Character generator protocol, [RFC 864](https://tools.ietf.org/html/rfc864) is |
kadonotakashi | 0:8fdf9a60065b | 65 | enabled in both TCP and UDP. Port 19. Output pattern should follow |
kadonotakashi | 0:8fdf9a60065b | 66 | the proposed example pattern in RFC. |
kadonotakashi | 0:8fdf9a60065b | 67 | - Daytime protocol, [RFC 867](https://tools.ietf.org/html/rfc867) in |
kadonotakashi | 0:8fdf9a60065b | 68 | both TCP and UDP. Port 13. |
kadonotakashi | 0:8fdf9a60065b | 69 | - Time protocol, [RFC 868](https://tools.ietf.org/html/rfc868) in |
kadonotakashi | 0:8fdf9a60065b | 70 | both TCP and UDP. Port 37. |
kadonotakashi | 0:8fdf9a60065b | 71 | |
kadonotakashi | 0:8fdf9a60065b | 72 | Configure the firewall to allow this traffic to access the test server. |
kadonotakashi | 0:8fdf9a60065b | 73 | |
kadonotakashi | 0:8fdf9a60065b | 74 | **Example configuration for Debian/Ubuntu Linux** |
kadonotakashi | 0:8fdf9a60065b | 75 | |
kadonotakashi | 0:8fdf9a60065b | 76 | These services are available on many operating systems, and installing them is out of |
kadonotakashi | 0:8fdf9a60065b | 77 | scope of this document. Below is an |
kadonotakashi | 0:8fdf9a60065b | 78 | example of how to install these services into a Debian/Ubuntu based Linux distribution |
kadonotakashi | 0:8fdf9a60065b | 79 | using standard Inet Daemon: |
kadonotakashi | 0:8fdf9a60065b | 80 | |
kadonotakashi | 0:8fdf9a60065b | 81 | ```.sh |
kadonotakashi | 0:8fdf9a60065b | 82 | $ sudo apt install inetutils-inetd |
kadonotakashi | 0:8fdf9a60065b | 83 | $ nano /etc/inetd.conf |
kadonotakashi | 0:8fdf9a60065b | 84 | ``` |
kadonotakashi | 0:8fdf9a60065b | 85 | |
kadonotakashi | 0:8fdf9a60065b | 86 | Enable following services from /etc/inetd.conf: |
kadonotakashi | 0:8fdf9a60065b | 87 | |
kadonotakashi | 0:8fdf9a60065b | 88 | ``` |
kadonotakashi | 0:8fdf9a60065b | 89 | #:INTERNAL: Internal services |
kadonotakashi | 0:8fdf9a60065b | 90 | discard stream tcp6 nowait root internal |
kadonotakashi | 0:8fdf9a60065b | 91 | discard dgram udp6 wait root internal |
kadonotakashi | 0:8fdf9a60065b | 92 | echo stream tcp6 nowait root internal |
kadonotakashi | 0:8fdf9a60065b | 93 | echo dgram udp6 wait root internal |
kadonotakashi | 0:8fdf9a60065b | 94 | chargen stream tcp6 nowait root internal |
kadonotakashi | 0:8fdf9a60065b | 95 | chargen dgram udp6 wait root internal |
kadonotakashi | 0:8fdf9a60065b | 96 | daytime stream tcp6 nowait root internal |
kadonotakashi | 0:8fdf9a60065b | 97 | time stream tcp6 nowait root internal |
kadonotakashi | 0:8fdf9a60065b | 98 | ``` |
kadonotakashi | 0:8fdf9a60065b | 99 | |
kadonotakashi | 0:8fdf9a60065b | 100 | **Testing the connectivity** |
kadonotakashi | 0:8fdf9a60065b | 101 | |
kadonotakashi | 0:8fdf9a60065b | 102 | You can connect to the test server with an NMAP tool like this: |
kadonotakashi | 0:8fdf9a60065b | 103 | |
kadonotakashi | 0:8fdf9a60065b | 104 | ```.sh |
kadonotakashi | 0:8fdf9a60065b | 105 | $ nmap -sT -p7,9,13,37 echo.mbedcloudtesting.com |
kadonotakashi | 0:8fdf9a60065b | 106 | |
kadonotakashi | 0:8fdf9a60065b | 107 | Starting Nmap 7.12 ( https://nmap.org ) at 2018-04-05 16:17 EEST |
kadonotakashi | 0:8fdf9a60065b | 108 | Nmap scan report for echo.mbedcloudtesting.com (52.215.34.155) |
kadonotakashi | 0:8fdf9a60065b | 109 | Host is up (0.065s latency). |
kadonotakashi | 0:8fdf9a60065b | 110 | Other addresses for echo.mbedcloudtesting.com (not scanned): 2a05:d018:21f:3800:8584:60f8:bc9f:e614 |
kadonotakashi | 0:8fdf9a60065b | 111 | rDNS record for 52.215.34.155: ec2-52-215-34-155.eu-west-1.compute.amazonaws.com |
kadonotakashi | 0:8fdf9a60065b | 112 | PORT STATE SERVICE |
kadonotakashi | 0:8fdf9a60065b | 113 | 7/tcp open echo |
kadonotakashi | 0:8fdf9a60065b | 114 | 9/tcp open discard |
kadonotakashi | 0:8fdf9a60065b | 115 | 13/tcp open daytime |
kadonotakashi | 0:8fdf9a60065b | 116 | 37/tcp open time |
kadonotakashi | 0:8fdf9a60065b | 117 | |
kadonotakashi | 0:8fdf9a60065b | 118 | Nmap done: 1 IP address (1 host up) scanned in 0.17 seconds |
kadonotakashi | 0:8fdf9a60065b | 119 | |
kadonotakashi | 0:8fdf9a60065b | 120 | $ sudo nmap -sT -p7,9,13,37 echo.mbedcloudtesting.com |
kadonotakashi | 0:8fdf9a60065b | 121 | |
kadonotakashi | 0:8fdf9a60065b | 122 | Starting Nmap 7.12 ( https://nmap.org ) at 2018-04-05 16:16 EEST |
kadonotakashi | 0:8fdf9a60065b | 123 | Nmap scan report for echo.mbedcloudtesting.com (52.215.34.155) |
kadonotakashi | 0:8fdf9a60065b | 124 | Host is up (0.068s latency). |
kadonotakashi | 0:8fdf9a60065b | 125 | Other addresses for echo.mbedcloudtesting.com (not scanned): 2a05:d018:21f:3800:8584:60f8:bc9f:e614 |
kadonotakashi | 0:8fdf9a60065b | 126 | rDNS record for 52.215.34.155: ec2-52-215-34-155.eu-west-1.compute.amazonaws.com |
kadonotakashi | 0:8fdf9a60065b | 127 | PORT STATE SERVICE |
kadonotakashi | 0:8fdf9a60065b | 128 | 7/tcp open echo |
kadonotakashi | 0:8fdf9a60065b | 129 | 9/tcp open discard |
kadonotakashi | 0:8fdf9a60065b | 130 | 13/tcp open daytime |
kadonotakashi | 0:8fdf9a60065b | 131 | 37/tcp open time |
kadonotakashi | 0:8fdf9a60065b | 132 | |
kadonotakashi | 0:8fdf9a60065b | 133 | Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds |
kadonotakashi | 0:8fdf9a60065b | 134 | ``` |
kadonotakashi | 0:8fdf9a60065b | 135 | |
kadonotakashi | 0:8fdf9a60065b | 136 | ### Ethernet test environment |
kadonotakashi | 0:8fdf9a60065b | 137 | |
kadonotakashi | 0:8fdf9a60065b | 138 | ![Ethernet](eth_environment.png) |
kadonotakashi | 0:8fdf9a60065b | 139 | |
kadonotakashi | 0:8fdf9a60065b | 140 | The Ethernet test environment consists of devices, an ethernet switch and an optional |
kadonotakashi | 0:8fdf9a60065b | 141 | firewall that allows connecting to the Echo server. |
kadonotakashi | 0:8fdf9a60065b | 142 | |
kadonotakashi | 0:8fdf9a60065b | 143 | ### Wi-Fi test environment |
kadonotakashi | 0:8fdf9a60065b | 144 | |
kadonotakashi | 0:8fdf9a60065b | 145 | ![Wi-Fi](wifi_environment.png) |
kadonotakashi | 0:8fdf9a60065b | 146 | |
kadonotakashi | 0:8fdf9a60065b | 147 | The Wi-Fi test environment is equivalent to the Ethernet test environment, except that the |
kadonotakashi | 0:8fdf9a60065b | 148 | Wi-Fi test environment has two separate access points or one with dual SSID. Connectivity to |
kadonotakashi | 0:8fdf9a60065b | 149 | echo server is required, but it can be hosted locally, as specified in |
kadonotakashi | 0:8fdf9a60065b | 150 | the Ethernet environment. |
kadonotakashi | 0:8fdf9a60065b | 151 | |
kadonotakashi | 0:8fdf9a60065b | 152 | Test case priorities |
kadonotakashi | 0:8fdf9a60065b | 153 | -------------------- |
kadonotakashi | 0:8fdf9a60065b | 154 | |
kadonotakashi | 0:8fdf9a60065b | 155 | Please refer to the following table for priorities of test cases. Priorities |
kadonotakashi | 0:8fdf9a60065b | 156 | are labeled as MUST and SHOULD. MUST means this is a requirement and |
kadonotakashi | 0:8fdf9a60065b | 157 | therefore mandatory to pass the test. SHOULD means it is recommended to |
kadonotakashi | 0:8fdf9a60065b | 158 | pass the test if the driver implements the feature in question. |
kadonotakashi | 0:8fdf9a60065b | 159 | |
kadonotakashi | 0:8fdf9a60065b | 160 | | | Test case | Priority | |
kadonotakashi | 0:8fdf9a60065b | 161 | |-----|-----------------------------------------|----------| |
kadonotakashi | 0:8fdf9a60065b | 162 | | 1 | UDPSOCKET_OPEN_DESTRUCT | MUST | |
kadonotakashi | 0:8fdf9a60065b | 163 | | 2 | UDPSOCKET_OPEN_LIMIT | MUST | |
kadonotakashi | 0:8fdf9a60065b | 164 | | 3 | UDPSOCKET_OPEN_TWICE | MUST | |
kadonotakashi | 0:8fdf9a60065b | 165 | | 4 | UDPSOCKET_OPEN_CLOSE_REPEAT | MUST | |
kadonotakashi | 0:8fdf9a60065b | 166 | | 5 | UDPSOCKET_BIND_PORT | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 167 | | 6 | UDPSOCKET_BIND_PORT_FAIL | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 168 | | 7 | UDPSOCKET_BIND_ADDRESS_PORT | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 169 | | 8 | UDPSOCKET_BIND_ADDRESS_NULL | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 170 | | 9 | UDPSOCKET_BIND_ADDRESS_INVALID | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 171 | | 10 | UDPSOCKET_BIND_WRONG_TYPE | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 172 | | 11 | UDPSOCKET_BIND_ADDRESS | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 173 | | 12 | UDPSOCKET_BIND_UNOPENED | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 174 | | 13 | UDPSOCKET_SENDTO_INVALID | MUST | |
kadonotakashi | 0:8fdf9a60065b | 175 | | 14 | UDPSOCKET_SENDTO_REPEAT | MUST | |
kadonotakashi | 0:8fdf9a60065b | 176 | | 15 | UDPSOCKET_BIND_SENDTO | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 177 | | 16 | UDPSOCKET_ECHOTEST | MUST | |
kadonotakashi | 0:8fdf9a60065b | 178 | | 17 | UDPSOCKET_ECHOTEST_NONBLOCK | MUST | |
kadonotakashi | 0:8fdf9a60065b | 179 | | 18 | UDPSOCKET_RECV_TIMEOUT | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 180 | | 19 | UDPSOCKET_SENDTO_TIMEOUT | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 181 | | 20 | TCPSOCKET_OPEN_DESTRUCT | MUST | |
kadonotakashi | 0:8fdf9a60065b | 182 | | 21 | TCPSOCKET_OPEN_LIMIT | MUST | |
kadonotakashi | 0:8fdf9a60065b | 183 | | 22 | TCPSOCKET_OPEN_TWICE | MUST | |
kadonotakashi | 0:8fdf9a60065b | 184 | | 23 | TCPSOCKET_OPEN_CLOSE_REPEAT | MUST | |
kadonotakashi | 0:8fdf9a60065b | 185 | | 24 | TCPSOCKET_BIND_PORT | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 186 | | 25 | TCPSOCKET_BIND_PORT_FAIL | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 187 | | 26 | TCPSOCKET_BIND_ADDRESS_PORT | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 188 | | 27 | TCPSOCKET_BIND_ADDRESS_NULL | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 189 | | 28 | TCPSOCKET_BIND_ADDRESS_INVALID | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 190 | | 29 | TCPSOCKET_BIND_WRONG_TYPE | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 191 | | 30 | TCPSOCKET_BIND_ADDRESS | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 192 | | 31 | TCPSOCKET_BIND_UNOPENED | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 193 | | 32 | TCPSOCKET_CONNECT_INVALID | MUST | |
kadonotakashi | 0:8fdf9a60065b | 194 | | 33 | TCPSOCKET_SEND_REPEAT | MUST | |
kadonotakashi | 0:8fdf9a60065b | 195 | | 34 | TCPSOCKET_ECHOTEST | MUST | |
kadonotakashi | 0:8fdf9a60065b | 196 | | 35 | TCPSOCKET_ECHOTEST_NONBLOCK | MUST | |
kadonotakashi | 0:8fdf9a60065b | 197 | | 36 | TCPSOCKET_RECV_TIMEOUT | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 198 | | 37 | TCPSOCKET_SEND_TIMEOUT | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 199 | | 38 | TCPSOCKET_ENDPOINT_CLOSE | MUST | |
kadonotakashi | 0:8fdf9a60065b | 200 | | 39 | TCPSERVER_ACCEPT | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 201 | | 40 | TCPSERVER_LISTEN | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 202 | | 41 | TCPSERVER_LISTEN_WITHOUT_BIND | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 203 | | 42 | TCPSERVER_ACCEPT_WITHOUT_LISTEN | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 204 | | 43 | UDPSOCKET_ECHOTEST_BURST | MUST | |
kadonotakashi | 0:8fdf9a60065b | 205 | | 44 | UDPSOCKET_ECHOTEST_BURST_NONBLOCK | MUST | |
kadonotakashi | 0:8fdf9a60065b | 206 | | 45 | TCPSOCKET_ECHOTEST_BURST | MUST | |
kadonotakashi | 0:8fdf9a60065b | 207 | | 46 | TCPSOCKET_ECHOTEST_BURST_NONBLOCK | MUST | |
kadonotakashi | 0:8fdf9a60065b | 208 | | 47 | TCPSOCKET_RECV_100K | MUST | |
kadonotakashi | 0:8fdf9a60065b | 209 | | 48 | TCPSOCKET_RECV_100K_NONBLOCK | MUST | |
kadonotakashi | 0:8fdf9a60065b | 210 | | 49 | TCPSOCKET_THREAD_PER_SOCKET_SAFETY | MUST | |
kadonotakashi | 0:8fdf9a60065b | 211 | | 50 | TCPSOCKET_SETSOCKOPT_KEEPALIVE_VALID | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 212 | | 51 | TCPSOCKET_SETSOCKOPT_KEEPALIVE_INVALID | SHOULD | |
kadonotakashi | 0:8fdf9a60065b | 213 | |
kadonotakashi | 0:8fdf9a60065b | 214 | |
kadonotakashi | 0:8fdf9a60065b | 215 | Building test binaries |
kadonotakashi | 0:8fdf9a60065b | 216 | -------------------------- |
kadonotakashi | 0:8fdf9a60065b | 217 | |
kadonotakashi | 0:8fdf9a60065b | 218 | For testing the board and driver, test against the Mbed OS |
kadonotakashi | 0:8fdf9a60065b | 219 | master branch to get the most recent, up-to-date test cases and drivers. |
kadonotakashi | 0:8fdf9a60065b | 220 | |
kadonotakashi | 0:8fdf9a60065b | 221 | To create a build environment: |
kadonotakashi | 0:8fdf9a60065b | 222 | |
kadonotakashi | 0:8fdf9a60065b | 223 | ```.sh |
kadonotakashi | 0:8fdf9a60065b | 224 | mbed new network_test |
kadonotakashi | 0:8fdf9a60065b | 225 | cd network_test |
kadonotakashi | 0:8fdf9a60065b | 226 | cd mbed-os |
kadonotakashi | 0:8fdf9a60065b | 227 | git checkout master |
kadonotakashi | 0:8fdf9a60065b | 228 | cd .. |
kadonotakashi | 0:8fdf9a60065b | 229 | ``` |
kadonotakashi | 0:8fdf9a60065b | 230 | |
kadonotakashi | 0:8fdf9a60065b | 231 | Also, building socket test cases requires a special macro to |
kadonotakashi | 0:8fdf9a60065b | 232 | enable all tests, so create an `mbed_app.json` file with the following |
kadonotakashi | 0:8fdf9a60065b | 233 | content at minimum: |
kadonotakashi | 0:8fdf9a60065b | 234 | |
kadonotakashi | 0:8fdf9a60065b | 235 | ``` |
kadonotakashi | 0:8fdf9a60065b | 236 | { |
kadonotakashi | 0:8fdf9a60065b | 237 | "config": { |
kadonotakashi | 0:8fdf9a60065b | 238 | "echo-server-addr" : { |
kadonotakashi | 0:8fdf9a60065b | 239 | "help" : "IP address of echo server", |
kadonotakashi | 0:8fdf9a60065b | 240 | "value" : "\"echo.mbedcloudtesting.com\"" |
kadonotakashi | 0:8fdf9a60065b | 241 | }, |
kadonotakashi | 0:8fdf9a60065b | 242 | "echo-server-port" : { |
kadonotakashi | 0:8fdf9a60065b | 243 | "help" : "Port of echo server", |
kadonotakashi | 0:8fdf9a60065b | 244 | "value" : "7" |
kadonotakashi | 0:8fdf9a60065b | 245 | } |
kadonotakashi | 0:8fdf9a60065b | 246 | }, |
kadonotakashi | 0:8fdf9a60065b | 247 | "macros": ["MBED_EXTENDED_TESTS"] |
kadonotakashi | 0:8fdf9a60065b | 248 | } |
kadonotakashi | 0:8fdf9a60065b | 249 | ``` |
kadonotakashi | 0:8fdf9a60065b | 250 | |
kadonotakashi | 0:8fdf9a60065b | 251 | Wi-Fi tests require some more configuration, so for Wi-Fi purposes, |
kadonotakashi | 0:8fdf9a60065b | 252 | the `mbed_app.json` might look like this: |
kadonotakashi | 0:8fdf9a60065b | 253 | |
kadonotakashi | 0:8fdf9a60065b | 254 | ``` |
kadonotakashi | 0:8fdf9a60065b | 255 | { |
kadonotakashi | 0:8fdf9a60065b | 256 | "config": { |
kadonotakashi | 0:8fdf9a60065b | 257 | "wifi-secure-ssid": { |
kadonotakashi | 0:8fdf9a60065b | 258 | "help": "WiFi SSID for WPA2 secured network", |
kadonotakashi | 0:8fdf9a60065b | 259 | "value": "\"test-network\"" |
kadonotakashi | 0:8fdf9a60065b | 260 | }, |
kadonotakashi | 0:8fdf9a60065b | 261 | "wifi-unsecure-ssid": { |
kadonotakashi | 0:8fdf9a60065b | 262 | "help": "WiFi SSID for unsecure netwrok", |
kadonotakashi | 0:8fdf9a60065b | 263 | "value": "\"unsecure-test-net\"" |
kadonotakashi | 0:8fdf9a60065b | 264 | }, |
kadonotakashi | 0:8fdf9a60065b | 265 | "wifi-password": { |
kadonotakashi | 0:8fdf9a60065b | 266 | "help": "WiFi Password", |
kadonotakashi | 0:8fdf9a60065b | 267 | "value": "\"password\"" |
kadonotakashi | 0:8fdf9a60065b | 268 | }, |
kadonotakashi | 0:8fdf9a60065b | 269 | "wifi-secure-protocol": { |
kadonotakashi | 0:8fdf9a60065b | 270 | "help": "WiFi security protocol, valid values are WEP, WPA, WPA2, WPA_WPA2", |
kadonotakashi | 0:8fdf9a60065b | 271 | "value": "\"WPA2\"" |
kadonotakashi | 0:8fdf9a60065b | 272 | }, |
kadonotakashi | 0:8fdf9a60065b | 273 | "wifi-ch-secure": { |
kadonotakashi | 0:8fdf9a60065b | 274 | "help": "Channel number of secure SSID", |
kadonotakashi | 0:8fdf9a60065b | 275 | "value": 6 |
kadonotakashi | 0:8fdf9a60065b | 276 | }, |
kadonotakashi | 0:8fdf9a60065b | 277 | "wifi-ch-unsecure": { |
kadonotakashi | 0:8fdf9a60065b | 278 | "help": "Channel number of unsecure SSID", |
kadonotakashi | 0:8fdf9a60065b | 279 | "value": 6 |
kadonotakashi | 0:8fdf9a60065b | 280 | }, |
kadonotakashi | 0:8fdf9a60065b | 281 | "ap-mac-secure": { |
kadonotakashi | 0:8fdf9a60065b | 282 | "help": "BSSID of secure AP in form of AA:BB:CC:DD:EE:FF", |
kadonotakashi | 0:8fdf9a60065b | 283 | "value": "\"58:8b:f3:99:f2:9c\"" |
kadonotakashi | 0:8fdf9a60065b | 284 | }, |
kadonotakashi | 0:8fdf9a60065b | 285 | "ap-mac-unsecure": { |
kadonotakashi | 0:8fdf9a60065b | 286 | "help": "BSSID of unsecure AP in form of \"AA:BB:CC:DD:EE:FF\"", |
kadonotakashi | 0:8fdf9a60065b | 287 | "value": "\"58:8b:f3:99:c2:08\"" |
kadonotakashi | 0:8fdf9a60065b | 288 | }, |
kadonotakashi | 0:8fdf9a60065b | 289 | "max-scan-size": { |
kadonotakashi | 0:8fdf9a60065b | 290 | "help": "How many networks may appear in Wifi scan result", |
kadonotakashi | 0:8fdf9a60065b | 291 | "value": 30 |
kadonotakashi | 0:8fdf9a60065b | 292 | }, |
kadonotakashi | 0:8fdf9a60065b | 293 | "echo-server-addr" : { |
kadonotakashi | 0:8fdf9a60065b | 294 | "help" : "IP address of echo server", |
kadonotakashi | 0:8fdf9a60065b | 295 | "value" : "\"echo.mbedcloudtesting.com\"" |
kadonotakashi | 0:8fdf9a60065b | 296 | }, |
kadonotakashi | 0:8fdf9a60065b | 297 | "echo-server-port" : { |
kadonotakashi | 0:8fdf9a60065b | 298 | "help" : "Port of echo server", |
kadonotakashi | 0:8fdf9a60065b | 299 | "value" : "7" |
kadonotakashi | 0:8fdf9a60065b | 300 | } |
kadonotakashi | 0:8fdf9a60065b | 301 | }, |
kadonotakashi | 0:8fdf9a60065b | 302 | "macros": ["MBED_EXTENDED_TESTS"], |
kadonotakashi | 0:8fdf9a60065b | 303 | "target_overrides": { |
kadonotakashi | 0:8fdf9a60065b | 304 | "*": { |
kadonotakashi | 0:8fdf9a60065b | 305 | "target.network-default-interface-type": "WIFI", |
kadonotakashi | 0:8fdf9a60065b | 306 | "nsapi.default-wifi-ssid": "\"WIFI_SSID\"", |
kadonotakashi | 0:8fdf9a60065b | 307 | "nsapi.default-wifi-password": "\"WIFI_PASSWORD\"", |
kadonotakashi | 0:8fdf9a60065b | 308 | "nsapi.default-wifi-security": "WPA_WPA2" |
kadonotakashi | 0:8fdf9a60065b | 309 | } |
kadonotakashi | 0:8fdf9a60065b | 310 | } |
kadonotakashi | 0:8fdf9a60065b | 311 | } |
kadonotakashi | 0:8fdf9a60065b | 312 | ``` |
kadonotakashi | 0:8fdf9a60065b | 313 | See `mbed-os/tools/test_configs` folder for examples. |
kadonotakashi | 0:8fdf9a60065b | 314 | |
kadonotakashi | 0:8fdf9a60065b | 315 | Now build test binaries: |
kadonotakashi | 0:8fdf9a60065b | 316 | |
kadonotakashi | 0:8fdf9a60065b | 317 | ```.sh |
kadonotakashi | 0:8fdf9a60065b | 318 | mbed test --compile -t <toolchain> -m <target> -n mbed-os-tests-network-*,mbed-os-tests-netsocket* |
kadonotakashi | 0:8fdf9a60065b | 319 | ``` |
kadonotakashi | 0:8fdf9a60065b | 320 | |
kadonotakashi | 0:8fdf9a60065b | 321 | Running tests |
kadonotakashi | 0:8fdf9a60065b | 322 | ------------- |
kadonotakashi | 0:8fdf9a60065b | 323 | |
kadonotakashi | 0:8fdf9a60065b | 324 | When device is connected to network, or in case of wireless device near |
kadonotakashi | 0:8fdf9a60065b | 325 | the access point. |
kadonotakashi | 0:8fdf9a60065b | 326 | |
kadonotakashi | 0:8fdf9a60065b | 327 | ```.sh |
kadonotakashi | 0:8fdf9a60065b | 328 | mbed test -n mbed-os-tests-network-*,mbed-os-tests-netsocket* |
kadonotakashi | 0:8fdf9a60065b | 329 | ``` |
kadonotakashi | 0:8fdf9a60065b | 330 | |
kadonotakashi | 0:8fdf9a60065b | 331 | Test cases for Socket class |
kadonotakashi | 0:8fdf9a60065b | 332 | --------------------------- |
kadonotakashi | 0:8fdf9a60065b | 333 | |
kadonotakashi | 0:8fdf9a60065b | 334 | These test are equal for UDPSocket and TCPSocket but are described here |
kadonotakashi | 0:8fdf9a60065b | 335 | because of identical API and behaviour. Socket class is abstract so it |
kadonotakashi | 0:8fdf9a60065b | 336 | cannot be instantiated, therefore these test cases are implemented using |
kadonotakashi | 0:8fdf9a60065b | 337 | both TCPSocket and UDPSocket. |
kadonotakashi | 0:8fdf9a60065b | 338 | |
kadonotakashi | 0:8fdf9a60065b | 339 | ### SOCKET_OPEN_DESTRUCT |
kadonotakashi | 0:8fdf9a60065b | 340 | |
kadonotakashi | 0:8fdf9a60065b | 341 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 342 | |
kadonotakashi | 0:8fdf9a60065b | 343 | Call `Socket::open()` and then destruct the socket |
kadonotakashi | 0:8fdf9a60065b | 344 | |
kadonotakashi | 0:8fdf9a60065b | 345 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 346 | |
kadonotakashi | 0:8fdf9a60065b | 347 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 348 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 349 | |
kadonotakashi | 0:8fdf9a60065b | 350 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 351 | |
kadonotakashi | 0:8fdf9a60065b | 352 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 353 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 354 | 3. Call "delete" for the object |
kadonotakashi | 0:8fdf9a60065b | 355 | 4. Repeat 1000 times. |
kadonotakashi | 0:8fdf9a60065b | 356 | |
kadonotakashi | 0:8fdf9a60065b | 357 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 358 | |
kadonotakashi | 0:8fdf9a60065b | 359 | `Socket::open()` should always return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 360 | |
kadonotakashi | 0:8fdf9a60065b | 361 | |
kadonotakashi | 0:8fdf9a60065b | 362 | |
kadonotakashi | 0:8fdf9a60065b | 363 | ### SOCKET_OPEN_LIMIT |
kadonotakashi | 0:8fdf9a60065b | 364 | |
kadonotakashi | 0:8fdf9a60065b | 365 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 366 | |
kadonotakashi | 0:8fdf9a60065b | 367 | Call `Socket::open()` until it runs out of memory or other internal limit |
kadonotakashi | 0:8fdf9a60065b | 368 | in the stack is reached. |
kadonotakashi | 0:8fdf9a60065b | 369 | |
kadonotakashi | 0:8fdf9a60065b | 370 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 371 | |
kadonotakashi | 0:8fdf9a60065b | 372 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 373 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 374 | |
kadonotakashi | 0:8fdf9a60065b | 375 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 376 | |
kadonotakashi | 0:8fdf9a60065b | 377 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 378 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 379 | 3. repeat until `NSAPI_ERROR_NO_MEMORY` or `NSAPI_ERROR_NO_SOCKET` |
kadonotakashi | 0:8fdf9a60065b | 380 | error is returned. |
kadonotakashi | 0:8fdf9a60065b | 381 | 4. Call "delete" for all previously allocated sockets. |
kadonotakashi | 0:8fdf9a60065b | 382 | 5. repeat |
kadonotakashi | 0:8fdf9a60065b | 383 | |
kadonotakashi | 0:8fdf9a60065b | 384 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 385 | |
kadonotakashi | 0:8fdf9a60065b | 386 | Should be able to reserve at least 4 sockets. After freeing all sockets, |
kadonotakashi | 0:8fdf9a60065b | 387 | should be able to reserve same number of sockets. |
kadonotakashi | 0:8fdf9a60065b | 388 | |
kadonotakashi | 0:8fdf9a60065b | 389 | |
kadonotakashi | 0:8fdf9a60065b | 390 | |
kadonotakashi | 0:8fdf9a60065b | 391 | ### SOCKET_OPEN_TWICE |
kadonotakashi | 0:8fdf9a60065b | 392 | |
kadonotakashi | 0:8fdf9a60065b | 393 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 394 | |
kadonotakashi | 0:8fdf9a60065b | 395 | Call `Socket::open()` twice |
kadonotakashi | 0:8fdf9a60065b | 396 | |
kadonotakashi | 0:8fdf9a60065b | 397 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 398 | |
kadonotakashi | 0:8fdf9a60065b | 399 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 400 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 401 | |
kadonotakashi | 0:8fdf9a60065b | 402 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 403 | |
kadonotakashi | 0:8fdf9a60065b | 404 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 405 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 406 | 3. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 407 | 4. delete the socket |
kadonotakashi | 0:8fdf9a60065b | 408 | |
kadonotakashi | 0:8fdf9a60065b | 409 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 410 | |
kadonotakashi | 0:8fdf9a60065b | 411 | `Socket::open()` should first return `NSAPI_ERROR_OK` and second |
kadonotakashi | 0:8fdf9a60065b | 412 | call `NSAPI_ERROR_PARAMETER`. |
kadonotakashi | 0:8fdf9a60065b | 413 | |
kadonotakashi | 0:8fdf9a60065b | 414 | |
kadonotakashi | 0:8fdf9a60065b | 415 | |
kadonotakashi | 0:8fdf9a60065b | 416 | ### SOCKET_OPEN_CLOSE_REPEAT |
kadonotakashi | 0:8fdf9a60065b | 417 | |
kadonotakashi | 0:8fdf9a60065b | 418 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 419 | |
kadonotakashi | 0:8fdf9a60065b | 420 | Call `Socket::open()` followed by `Socket::close()` and then again |
kadonotakashi | 0:8fdf9a60065b | 421 | `Socket::open()`. Should allow you to reuse the same object. |
kadonotakashi | 0:8fdf9a60065b | 422 | |
kadonotakashi | 0:8fdf9a60065b | 423 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 424 | |
kadonotakashi | 0:8fdf9a60065b | 425 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 426 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 427 | |
kadonotakashi | 0:8fdf9a60065b | 428 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 429 | |
kadonotakashi | 0:8fdf9a60065b | 430 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 431 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 432 | 3. Call `Socket::close(stack)` |
kadonotakashi | 0:8fdf9a60065b | 433 | 4. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 434 | 5. Call `Socket::close(stack)` |
kadonotakashi | 0:8fdf9a60065b | 435 | 6. delete the socket |
kadonotakashi | 0:8fdf9a60065b | 436 | |
kadonotakashi | 0:8fdf9a60065b | 437 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 438 | |
kadonotakashi | 0:8fdf9a60065b | 439 | All `Socket::open()` and `Socket::close()` calls should return |
kadonotakashi | 0:8fdf9a60065b | 440 | NSAPI_ERROR_OK. |
kadonotakashi | 0:8fdf9a60065b | 441 | |
kadonotakashi | 0:8fdf9a60065b | 442 | |
kadonotakashi | 0:8fdf9a60065b | 443 | ### SOCKET_BIND_PORT |
kadonotakashi | 0:8fdf9a60065b | 444 | |
kadonotakashi | 0:8fdf9a60065b | 445 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 446 | |
kadonotakashi | 0:8fdf9a60065b | 447 | Call `Socket::bind(port)` |
kadonotakashi | 0:8fdf9a60065b | 448 | |
kadonotakashi | 0:8fdf9a60065b | 449 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 450 | |
kadonotakashi | 0:8fdf9a60065b | 451 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 452 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 453 | |
kadonotakashi | 0:8fdf9a60065b | 454 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 455 | |
kadonotakashi | 0:8fdf9a60065b | 456 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 457 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 458 | 3. Call `Socket::bind(<any non-used port number>);` |
kadonotakashi | 0:8fdf9a60065b | 459 | 4. destroy socket |
kadonotakashi | 0:8fdf9a60065b | 460 | |
kadonotakashi | 0:8fdf9a60065b | 461 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 462 | |
kadonotakashi | 0:8fdf9a60065b | 463 | All calls return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 464 | |
kadonotakashi | 0:8fdf9a60065b | 465 | |
kadonotakashi | 0:8fdf9a60065b | 466 | |
kadonotakashi | 0:8fdf9a60065b | 467 | ### SOCKET_BIND_PORT_FAIL |
kadonotakashi | 0:8fdf9a60065b | 468 | |
kadonotakashi | 0:8fdf9a60065b | 469 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 470 | |
kadonotakashi | 0:8fdf9a60065b | 471 | Call `Socket::bind(port)` on port number that is already used |
kadonotakashi | 0:8fdf9a60065b | 472 | |
kadonotakashi | 0:8fdf9a60065b | 473 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 474 | |
kadonotakashi | 0:8fdf9a60065b | 475 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 476 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 477 | |
kadonotakashi | 0:8fdf9a60065b | 478 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 479 | |
kadonotakashi | 0:8fdf9a60065b | 480 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 481 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 482 | 3. Call `Socket::bind(<any non-used port number>);` |
kadonotakashi | 0:8fdf9a60065b | 483 | 4. Repeat 1-3 for a new socket. |
kadonotakashi | 0:8fdf9a60065b | 484 | 5. destroy both sockets |
kadonotakashi | 0:8fdf9a60065b | 485 | |
kadonotakashi | 0:8fdf9a60065b | 486 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 487 | |
kadonotakashi | 0:8fdf9a60065b | 488 | Second `Socket::bind()` should return NSAPI_ERROR_PARAMETER |
kadonotakashi | 0:8fdf9a60065b | 489 | |
kadonotakashi | 0:8fdf9a60065b | 490 | |
kadonotakashi | 0:8fdf9a60065b | 491 | |
kadonotakashi | 0:8fdf9a60065b | 492 | ### SOCKET_BIND_ADDRESS_PORT |
kadonotakashi | 0:8fdf9a60065b | 493 | |
kadonotakashi | 0:8fdf9a60065b | 494 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 495 | |
kadonotakashi | 0:8fdf9a60065b | 496 | Call `Socket::bind(addr, port)` |
kadonotakashi | 0:8fdf9a60065b | 497 | |
kadonotakashi | 0:8fdf9a60065b | 498 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 499 | |
kadonotakashi | 0:8fdf9a60065b | 500 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 501 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 502 | |
kadonotakashi | 0:8fdf9a60065b | 503 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 504 | |
kadonotakashi | 0:8fdf9a60065b | 505 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 506 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 507 | 3. Get address by calling NetworkInterface::get_ip_address(); |
kadonotakashi | 0:8fdf9a60065b | 508 | 4. Call `Socket::bind(address, <any non-used port number>);` |
kadonotakashi | 0:8fdf9a60065b | 509 | 5. destroy socket |
kadonotakashi | 0:8fdf9a60065b | 510 | |
kadonotakashi | 0:8fdf9a60065b | 511 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 512 | |
kadonotakashi | 0:8fdf9a60065b | 513 | All calls return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 514 | |
kadonotakashi | 0:8fdf9a60065b | 515 | |
kadonotakashi | 0:8fdf9a60065b | 516 | |
kadonotakashi | 0:8fdf9a60065b | 517 | ### SOCKET_BIND_ADDRESS_NULL |
kadonotakashi | 0:8fdf9a60065b | 518 | |
kadonotakashi | 0:8fdf9a60065b | 519 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 520 | |
kadonotakashi | 0:8fdf9a60065b | 521 | Call `Socket::bind(NULL, port)` |
kadonotakashi | 0:8fdf9a60065b | 522 | |
kadonotakashi | 0:8fdf9a60065b | 523 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 524 | |
kadonotakashi | 0:8fdf9a60065b | 525 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 526 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 527 | |
kadonotakashi | 0:8fdf9a60065b | 528 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 529 | |
kadonotakashi | 0:8fdf9a60065b | 530 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 531 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 532 | 3. Call `Socket::bind(NULL, <any non-used port number>);` |
kadonotakashi | 0:8fdf9a60065b | 533 | 4. destroy socket |
kadonotakashi | 0:8fdf9a60065b | 534 | |
kadonotakashi | 0:8fdf9a60065b | 535 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 536 | |
kadonotakashi | 0:8fdf9a60065b | 537 | `Socket::bind()` should return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 538 | |
kadonotakashi | 0:8fdf9a60065b | 539 | |
kadonotakashi | 0:8fdf9a60065b | 540 | |
kadonotakashi | 0:8fdf9a60065b | 541 | ### SOCKET_BIND_ADDRESS_INVALID |
kadonotakashi | 0:8fdf9a60065b | 542 | |
kadonotakashi | 0:8fdf9a60065b | 543 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 544 | |
kadonotakashi | 0:8fdf9a60065b | 545 | Call `Socket::bind(address, port)` with and address that is not assigned |
kadonotakashi | 0:8fdf9a60065b | 546 | to us. |
kadonotakashi | 0:8fdf9a60065b | 547 | |
kadonotakashi | 0:8fdf9a60065b | 548 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 549 | |
kadonotakashi | 0:8fdf9a60065b | 550 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 551 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 552 | |
kadonotakashi | 0:8fdf9a60065b | 553 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 554 | |
kadonotakashi | 0:8fdf9a60065b | 555 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 556 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 557 | 3. Check whether device is IPv4 or IPv6 connected. |
kadonotakashi | 0:8fdf9a60065b | 558 | 1. For IPv4: Call `Socket::bind("190.2.3.4", <any non-used port number>);` |
kadonotakashi | 0:8fdf9a60065b | 559 | 2. For IPv6: Call `Socket::bind("fe80::ff01", <any non-used port number>);` |
kadonotakashi | 0:8fdf9a60065b | 560 | |
kadonotakashi | 0:8fdf9a60065b | 561 | 4. destroy socket |
kadonotakashi | 0:8fdf9a60065b | 562 | |
kadonotakashi | 0:8fdf9a60065b | 563 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 564 | |
kadonotakashi | 0:8fdf9a60065b | 565 | `Socket::bind()` should return NSAPI_ERROR_PARAMETER |
kadonotakashi | 0:8fdf9a60065b | 566 | |
kadonotakashi | 0:8fdf9a60065b | 567 | |
kadonotakashi | 0:8fdf9a60065b | 568 | |
kadonotakashi | 0:8fdf9a60065b | 569 | ### SOCKET_BIND_ADDRESS_WRONG_TYPE |
kadonotakashi | 0:8fdf9a60065b | 570 | |
kadonotakashi | 0:8fdf9a60065b | 571 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 572 | |
kadonotakashi | 0:8fdf9a60065b | 573 | Call `Socket::bind(SocketAddress)` with and address that is not wrong type |
kadonotakashi | 0:8fdf9a60065b | 574 | for the connection. |
kadonotakashi | 0:8fdf9a60065b | 575 | |
kadonotakashi | 0:8fdf9a60065b | 576 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 577 | |
kadonotakashi | 0:8fdf9a60065b | 578 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 579 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 580 | |
kadonotakashi | 0:8fdf9a60065b | 581 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 582 | |
kadonotakashi | 0:8fdf9a60065b | 583 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 584 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 585 | 3. Check whether device is IPv4 or IPv6 connected. |
kadonotakashi | 0:8fdf9a60065b | 586 | 1. For IPv4: Create `SocketAddress("fe80::ff01", <any non-used port number>);` |
kadonotakashi | 0:8fdf9a60065b | 587 | 2. For IPv6: Create `SocketAddress("190.2.3.4", <any non-used port number>);` |
kadonotakashi | 0:8fdf9a60065b | 588 | |
kadonotakashi | 0:8fdf9a60065b | 589 | 4. Call `Socket::bind(address);` |
kadonotakashi | 0:8fdf9a60065b | 590 | 5. destroy socket |
kadonotakashi | 0:8fdf9a60065b | 591 | |
kadonotakashi | 0:8fdf9a60065b | 592 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 593 | |
kadonotakashi | 0:8fdf9a60065b | 594 | `Socket::bind()` should return NSAPI_ERROR_PARAMETER |
kadonotakashi | 0:8fdf9a60065b | 595 | |
kadonotakashi | 0:8fdf9a60065b | 596 | |
kadonotakashi | 0:8fdf9a60065b | 597 | |
kadonotakashi | 0:8fdf9a60065b | 598 | ### SOCKET_BIND_ADDRESS |
kadonotakashi | 0:8fdf9a60065b | 599 | |
kadonotakashi | 0:8fdf9a60065b | 600 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 601 | |
kadonotakashi | 0:8fdf9a60065b | 602 | Call `Socket::bind(SocketAddress)` |
kadonotakashi | 0:8fdf9a60065b | 603 | |
kadonotakashi | 0:8fdf9a60065b | 604 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 605 | |
kadonotakashi | 0:8fdf9a60065b | 606 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 607 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 608 | |
kadonotakashi | 0:8fdf9a60065b | 609 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 610 | |
kadonotakashi | 0:8fdf9a60065b | 611 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 612 | 2. Call `Socket::open(stack)` |
kadonotakashi | 0:8fdf9a60065b | 613 | 3. Get address by calling NetworkInterface::get_ip_address(); |
kadonotakashi | 0:8fdf9a60065b | 614 | 4. Create a SocketAddress object using this address and any non-used |
kadonotakashi | 0:8fdf9a60065b | 615 | port number. |
kadonotakashi | 0:8fdf9a60065b | 616 | 5. Call `Socket::bind(address);` |
kadonotakashi | 0:8fdf9a60065b | 617 | 6. destroy socket |
kadonotakashi | 0:8fdf9a60065b | 618 | |
kadonotakashi | 0:8fdf9a60065b | 619 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 620 | |
kadonotakashi | 0:8fdf9a60065b | 621 | All calls return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 622 | |
kadonotakashi | 0:8fdf9a60065b | 623 | |
kadonotakashi | 0:8fdf9a60065b | 624 | |
kadonotakashi | 0:8fdf9a60065b | 625 | ### SOCKET_BIND_UNOPENED |
kadonotakashi | 0:8fdf9a60065b | 626 | |
kadonotakashi | 0:8fdf9a60065b | 627 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 628 | |
kadonotakashi | 0:8fdf9a60065b | 629 | Call `Socket::bind()` on socket that has not been opened |
kadonotakashi | 0:8fdf9a60065b | 630 | |
kadonotakashi | 0:8fdf9a60065b | 631 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 632 | |
kadonotakashi | 0:8fdf9a60065b | 633 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 634 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 635 | |
kadonotakashi | 0:8fdf9a60065b | 636 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 637 | |
kadonotakashi | 0:8fdf9a60065b | 638 | 1. Create a object by calling `new Socket()` |
kadonotakashi | 0:8fdf9a60065b | 639 | 2. Call `Socket::bind(<any non-used port number>);` |
kadonotakashi | 0:8fdf9a60065b | 640 | 3. destroy socket |
kadonotakashi | 0:8fdf9a60065b | 641 | |
kadonotakashi | 0:8fdf9a60065b | 642 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 643 | |
kadonotakashi | 0:8fdf9a60065b | 644 | NSAPI_ERROR_NO_SOCKET |
kadonotakashi | 0:8fdf9a60065b | 645 | |
kadonotakashi | 0:8fdf9a60065b | 646 | |
kadonotakashi | 0:8fdf9a60065b | 647 | |
kadonotakashi | 0:8fdf9a60065b | 648 | Test cases for UDPSocket class |
kadonotakashi | 0:8fdf9a60065b | 649 | ------------------------------ |
kadonotakashi | 0:8fdf9a60065b | 650 | |
kadonotakashi | 0:8fdf9a60065b | 651 | ### UDPSOCKET_OPEN_DESTRUCT |
kadonotakashi | 0:8fdf9a60065b | 652 | |
kadonotakashi | 0:8fdf9a60065b | 653 | **Description:** Run SOCKET_OPEN_DESTRUCT for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 654 | |
kadonotakashi | 0:8fdf9a60065b | 655 | ### UDPSOCKET_OPEN_LIMIT |
kadonotakashi | 0:8fdf9a60065b | 656 | |
kadonotakashi | 0:8fdf9a60065b | 657 | **Description:** Run SOCKET_OPEN_LIMIT for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 658 | |
kadonotakashi | 0:8fdf9a60065b | 659 | ### UDPSOCKET_OPEN_TWICE |
kadonotakashi | 0:8fdf9a60065b | 660 | |
kadonotakashi | 0:8fdf9a60065b | 661 | **Description:** Run SOCKET_OPEN_TWICE for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 662 | |
kadonotakashi | 0:8fdf9a60065b | 663 | ### UDPSOCKET_OPEN_CLOSE_REPEAT |
kadonotakashi | 0:8fdf9a60065b | 664 | |
kadonotakashi | 0:8fdf9a60065b | 665 | **Description:** Run SOCKET_OPEN_CLOSE_REPEAT for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 666 | |
kadonotakashi | 0:8fdf9a60065b | 667 | ### UDPSOCKET_BIND_PORT |
kadonotakashi | 0:8fdf9a60065b | 668 | |
kadonotakashi | 0:8fdf9a60065b | 669 | **Description:** Run SOCKET_BIND_PORT for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 670 | |
kadonotakashi | 0:8fdf9a60065b | 671 | ### UDPSOCKET_BIND_PORT_FAIL |
kadonotakashi | 0:8fdf9a60065b | 672 | |
kadonotakashi | 0:8fdf9a60065b | 673 | **Description:** Run SOCKET_BIND_PORT_FAIL for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 674 | |
kadonotakashi | 0:8fdf9a60065b | 675 | ### UDPSOCKET_BIND_ADDRESS_PORT |
kadonotakashi | 0:8fdf9a60065b | 676 | |
kadonotakashi | 0:8fdf9a60065b | 677 | **Description:** Run SOCKET_BIND_ADDRESS_PORT for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 678 | |
kadonotakashi | 0:8fdf9a60065b | 679 | ### UDPSOCKET_BIND_ADDRESS_NULL |
kadonotakashi | 0:8fdf9a60065b | 680 | |
kadonotakashi | 0:8fdf9a60065b | 681 | **Description:** Run SOCKET_BIND_ADDRESS_NULL for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 682 | |
kadonotakashi | 0:8fdf9a60065b | 683 | ### UDPSOCKET_BIND_ADDRESS_INVALID |
kadonotakashi | 0:8fdf9a60065b | 684 | |
kadonotakashi | 0:8fdf9a60065b | 685 | **Description:** Run SOCKET_BIND_ADDRESS_INVALID for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 686 | |
kadonotakashi | 0:8fdf9a60065b | 687 | ### UDPSOCKET_BIND_WRONG_TYPE |
kadonotakashi | 0:8fdf9a60065b | 688 | |
kadonotakashi | 0:8fdf9a60065b | 689 | **Description:** Run SOCKET_BIND_WRONG_TYPE for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 690 | |
kadonotakashi | 0:8fdf9a60065b | 691 | ### UDPSOCKET_BIND_ADDRESS |
kadonotakashi | 0:8fdf9a60065b | 692 | |
kadonotakashi | 0:8fdf9a60065b | 693 | **Description:** Run SOCKET_BIND_ADDRESS for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 694 | |
kadonotakashi | 0:8fdf9a60065b | 695 | ### UDPSOCKET_BIND_UNOPENED |
kadonotakashi | 0:8fdf9a60065b | 696 | |
kadonotakashi | 0:8fdf9a60065b | 697 | **Description:** Run SOCKET_BIND_UNOPENED for UDPSocket |
kadonotakashi | 0:8fdf9a60065b | 698 | |
kadonotakashi | 0:8fdf9a60065b | 699 | ### UDPSOCKET_SENDTO_INVALID |
kadonotakashi | 0:8fdf9a60065b | 700 | |
kadonotakashi | 0:8fdf9a60065b | 701 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 702 | |
kadonotakashi | 0:8fdf9a60065b | 703 | Call `UDPSocket::sendto()` with invalid parameters. |
kadonotakashi | 0:8fdf9a60065b | 704 | |
kadonotakashi | 0:8fdf9a60065b | 705 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 706 | |
kadonotakashi | 0:8fdf9a60065b | 707 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 708 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 709 | 3. UDPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 710 | |
kadonotakashi | 0:8fdf9a60065b | 711 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 712 | |
kadonotakashi | 0:8fdf9a60065b | 713 | 1. Call `UDPSocket:sendto( NULL, 9, NULL, 0);` |
kadonotakashi | 0:8fdf9a60065b | 714 | 2. Call `UDPSocket:sendto( "", 9, NULL, 0);` |
kadonotakashi | 0:8fdf9a60065b | 715 | 3. Call `UDPSocket:sendto( "", 0, NULL, 0);` |
kadonotakashi | 0:8fdf9a60065b | 716 | 4. Call `UDPSocket:sendto(NULL, 9, "hello", 5);` |
kadonotakashi | 0:8fdf9a60065b | 717 | 5. Call `UDPSocket:sendto(NULL, 0, "hello", 5);` |
kadonotakashi | 0:8fdf9a60065b | 718 | 6. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 9,NULL, 0);` |
kadonotakashi | 0:8fdf9a60065b | 719 | 7. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 9, "hello", 5);` |
kadonotakashi | 0:8fdf9a60065b | 720 | 8. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 721 | |
kadonotakashi | 0:8fdf9a60065b | 722 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 723 | |
kadonotakashi | 0:8fdf9a60065b | 724 | All sendto() calls should return some error code except: |
kadonotakashi | 0:8fdf9a60065b | 725 | |
kadonotakashi | 0:8fdf9a60065b | 726 | - step 6 should return 5 |
kadonotakashi | 0:8fdf9a60065b | 727 | - step 7 should return 0 |
kadonotakashi | 0:8fdf9a60065b | 728 | - step 8 should return 5 |
kadonotakashi | 0:8fdf9a60065b | 729 | |
kadonotakashi | 0:8fdf9a60065b | 730 | |
kadonotakashi | 0:8fdf9a60065b | 731 | |
kadonotakashi | 0:8fdf9a60065b | 732 | ### UDPSOCKET_SENDTO_REPEAT |
kadonotakashi | 0:8fdf9a60065b | 733 | |
kadonotakashi | 0:8fdf9a60065b | 734 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 735 | |
kadonotakashi | 0:8fdf9a60065b | 736 | Repeatedly send small packets. |
kadonotakashi | 0:8fdf9a60065b | 737 | |
kadonotakashi | 0:8fdf9a60065b | 738 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 739 | |
kadonotakashi | 0:8fdf9a60065b | 740 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 741 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 742 | 3. UDPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 743 | |
kadonotakashi | 0:8fdf9a60065b | 744 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 745 | |
kadonotakashi | 0:8fdf9a60065b | 746 | 1. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 9, "hello", 5);` |
kadonotakashi | 0:8fdf9a60065b | 747 | 2. repeat 100 times |
kadonotakashi | 0:8fdf9a60065b | 748 | 3. Fail if `NSAPI_ERROR_NO_MEMORY` is returned two times in a row, |
kadonotakashi | 0:8fdf9a60065b | 749 | wait 1 second before retry |
kadonotakashi | 0:8fdf9a60065b | 750 | 4. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 751 | |
kadonotakashi | 0:8fdf9a60065b | 752 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 753 | |
kadonotakashi | 0:8fdf9a60065b | 754 | All sendto() calls should return 5. |
kadonotakashi | 0:8fdf9a60065b | 755 | |
kadonotakashi | 0:8fdf9a60065b | 756 | |
kadonotakashi | 0:8fdf9a60065b | 757 | |
kadonotakashi | 0:8fdf9a60065b | 758 | ### UDPSOCKET_BIND_SENDTO |
kadonotakashi | 0:8fdf9a60065b | 759 | |
kadonotakashi | 0:8fdf9a60065b | 760 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 761 | |
kadonotakashi | 0:8fdf9a60065b | 762 | Bind the socket to specific port before sending. Verify from DUT2 that |
kadonotakashi | 0:8fdf9a60065b | 763 | packet was coming from correct port. |
kadonotakashi | 0:8fdf9a60065b | 764 | |
kadonotakashi | 0:8fdf9a60065b | 765 | Requires two devices with LAN connectivity (Eth, WiFi or mesh). For |
kadonotakashi | 0:8fdf9a60065b | 766 | Cellular or WAN connectivity, skip this test. |
kadonotakashi | 0:8fdf9a60065b | 767 | |
kadonotakashi | 0:8fdf9a60065b | 768 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 769 | |
kadonotakashi | 0:8fdf9a60065b | 770 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 771 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 772 | 3. UDPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 773 | |
kadonotakashi | 0:8fdf9a60065b | 774 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 775 | |
kadonotakashi | 0:8fdf9a60065b | 776 | 1. DUT1&2: Call `UDPSocket::bind(<unuser port number>);` |
kadonotakashi | 0:8fdf9a60065b | 777 | 2. DUT2: Get devices IP address |
kadonotakashi | 0:8fdf9a60065b | 778 | 3. DUT1: Call `UDPSocket::sendto( dut2, port, "hello", 5);` |
kadonotakashi | 0:8fdf9a60065b | 779 | 4. DUT2: Call `UDPSocket::recvfrom();` |
kadonotakashi | 0:8fdf9a60065b | 780 | 5. destroy the sockets |
kadonotakashi | 0:8fdf9a60065b | 781 | |
kadonotakashi | 0:8fdf9a60065b | 782 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 783 | |
kadonotakashi | 0:8fdf9a60065b | 784 | `UDPSocket::bind()` should return NSAPI_ERROR_OK. |
kadonotakashi | 0:8fdf9a60065b | 785 | |
kadonotakashi | 0:8fdf9a60065b | 786 | `UDPSocket::sendto()` call should return 5. |
kadonotakashi | 0:8fdf9a60065b | 787 | |
kadonotakashi | 0:8fdf9a60065b | 788 | `UDPSocket::recvfrom()` should return 5 and port number should match the |
kadonotakashi | 0:8fdf9a60065b | 789 | one used in bind() call. Data should contain "hello" |
kadonotakashi | 0:8fdf9a60065b | 790 | |
kadonotakashi | 0:8fdf9a60065b | 791 | |
kadonotakashi | 0:8fdf9a60065b | 792 | |
kadonotakashi | 0:8fdf9a60065b | 793 | ### UDPSOCKET_ECHOTEST |
kadonotakashi | 0:8fdf9a60065b | 794 | |
kadonotakashi | 0:8fdf9a60065b | 795 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 796 | |
kadonotakashi | 0:8fdf9a60065b | 797 | Repeatedly send packets to echo server and read incoming packets back. |
kadonotakashi | 0:8fdf9a60065b | 798 | Verify working of different packet sizes. |
kadonotakashi | 0:8fdf9a60065b | 799 | |
kadonotakashi | 0:8fdf9a60065b | 800 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 801 | |
kadonotakashi | 0:8fdf9a60065b | 802 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 803 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 804 | 3. UDPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 805 | |
kadonotakashi | 0:8fdf9a60065b | 806 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 807 | |
kadonotakashi | 0:8fdf9a60065b | 808 | 1. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = loop index>, <loop index>);` |
kadonotakashi | 0:8fdf9a60065b | 809 | 2. Wait for incomming packet. If timeout happens, retry |
kadonotakashi | 0:8fdf9a60065b | 810 | sending&receiving, max 3 times. |
kadonotakashi | 0:8fdf9a60065b | 811 | 3. Verify incomming content was the same that was sent |
kadonotakashi | 0:8fdf9a60065b | 812 | 4. Repeat 1200 times |
kadonotakashi | 0:8fdf9a60065b | 813 | 5. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 814 | |
kadonotakashi | 0:8fdf9a60065b | 815 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 816 | |
kadonotakashi | 0:8fdf9a60065b | 817 | All sendto() calls should return the packet size. All recvfrom() calls |
kadonotakashi | 0:8fdf9a60065b | 818 | should return the same sized packet that was send with same content. |
kadonotakashi | 0:8fdf9a60065b | 819 | Calculate packet loss rate, maximum tolerated packet loss rate is 30% |
kadonotakashi | 0:8fdf9a60065b | 820 | |
kadonotakashi | 0:8fdf9a60065b | 821 | |
kadonotakashi | 0:8fdf9a60065b | 822 | |
kadonotakashi | 0:8fdf9a60065b | 823 | ### UDPSOCKET_ECHOTEST_NONBLOCK |
kadonotakashi | 0:8fdf9a60065b | 824 | |
kadonotakashi | 0:8fdf9a60065b | 825 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 826 | |
kadonotakashi | 0:8fdf9a60065b | 827 | Repeatedly send packets to echo server and read incoming packets back. |
kadonotakashi | 0:8fdf9a60065b | 828 | Verify working of different packet sizes. Use socket in non-blocking |
kadonotakashi | 0:8fdf9a60065b | 829 | mode |
kadonotakashi | 0:8fdf9a60065b | 830 | |
kadonotakashi | 0:8fdf9a60065b | 831 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 832 | |
kadonotakashi | 0:8fdf9a60065b | 833 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 834 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 835 | 3. UDPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 836 | |
kadonotakashi | 0:8fdf9a60065b | 837 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 838 | |
kadonotakashi | 0:8fdf9a60065b | 839 | 1. Call `UDPSocket::set_blocking(false)` |
kadonotakashi | 0:8fdf9a60065b | 840 | 2. Register event handler with `UDPSocket::sigio()` |
kadonotakashi | 0:8fdf9a60065b | 841 | 3. Create another thread that constantly waits signal from sigio() |
kadonotakashi | 0:8fdf9a60065b | 842 | handler, when received try `UDPSocket::recvfrom()` |
kadonotakashi | 0:8fdf9a60065b | 843 | 4. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = loop index>, <loop index>);` |
kadonotakashi | 0:8fdf9a60065b | 844 | 5. Wait for incomming packet for one second. If nothing received retry, |
kadonotakashi | 0:8fdf9a60065b | 845 | max 3 times. |
kadonotakashi | 0:8fdf9a60065b | 846 | 6. Verify incomming content was the same that was sent |
kadonotakashi | 0:8fdf9a60065b | 847 | 7. Repeat 1200 times |
kadonotakashi | 0:8fdf9a60065b | 848 | 8. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 849 | |
kadonotakashi | 0:8fdf9a60065b | 850 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 851 | |
kadonotakashi | 0:8fdf9a60065b | 852 | All sendto() calls should return the packet size. All recvfrom() calls |
kadonotakashi | 0:8fdf9a60065b | 853 | should return the same sized packet that was send with same content or |
kadonotakashi | 0:8fdf9a60065b | 854 | NSAPI_ERROR_WOULD_BLOCK. |
kadonotakashi | 0:8fdf9a60065b | 855 | |
kadonotakashi | 0:8fdf9a60065b | 856 | Calculate packet loss rate, maximum tolerated packet loss rate is 30% |
kadonotakashi | 0:8fdf9a60065b | 857 | |
kadonotakashi | 0:8fdf9a60065b | 858 | |
kadonotakashi | 0:8fdf9a60065b | 859 | |
kadonotakashi | 0:8fdf9a60065b | 860 | ### UDPSOCKET_RECV_TIMEOUT |
kadonotakashi | 0:8fdf9a60065b | 861 | |
kadonotakashi | 0:8fdf9a60065b | 862 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 863 | |
kadonotakashi | 0:8fdf9a60065b | 864 | Test whether timeouts are obeyed in UDPSockets. |
kadonotakashi | 0:8fdf9a60065b | 865 | |
kadonotakashi | 0:8fdf9a60065b | 866 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 867 | |
kadonotakashi | 0:8fdf9a60065b | 868 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 869 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 870 | |
kadonotakashi | 0:8fdf9a60065b | 871 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 872 | |
kadonotakashi | 0:8fdf9a60065b | 873 | 1. Call `UDPSocket::set_timeout(100)` |
kadonotakashi | 0:8fdf9a60065b | 874 | 2. Call `UDPSocket::sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 100>, 100);` |
kadonotakashi | 0:8fdf9a60065b | 875 | 3. Repeat 5 times |
kadonotakashi | 0:8fdf9a60065b | 876 | 1. record a time in millisecond precission |
kadonotakashi | 0:8fdf9a60065b | 877 | 2. Call `UDPSocket::recvfrom()` |
kadonotakashi | 0:8fdf9a60065b | 878 | 3. record a time in millisecond precission |
kadonotakashi | 0:8fdf9a60065b | 879 | |
kadonotakashi | 0:8fdf9a60065b | 880 | 4. repeat testcase 10 times. |
kadonotakashi | 0:8fdf9a60065b | 881 | |
kadonotakashi | 0:8fdf9a60065b | 882 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 883 | |
kadonotakashi | 0:8fdf9a60065b | 884 | Each `sendto()` calls should return 100. |
kadonotakashi | 0:8fdf9a60065b | 885 | |
kadonotakashi | 0:8fdf9a60065b | 886 | Within each loop, one `recvfrom()` may return the received packet size |
kadonotakashi | 0:8fdf9a60065b | 887 | (100). Other calls should return NSAPI_ERROR_WOULD_BLOCK. |
kadonotakashi | 0:8fdf9a60065b | 888 | |
kadonotakashi | 0:8fdf9a60065b | 889 | When NSAPI_ERROR_WOULD_BLOCK is received, check that time consumed is |
kadonotakashi | 0:8fdf9a60065b | 890 | more that 100 milliseconds but less than 200 milliseconds. |
kadonotakashi | 0:8fdf9a60065b | 891 | |
kadonotakashi | 0:8fdf9a60065b | 892 | After repeating for 10 times, at least 5 packets must have been |
kadonotakashi | 0:8fdf9a60065b | 893 | received. |
kadonotakashi | 0:8fdf9a60065b | 894 | |
kadonotakashi | 0:8fdf9a60065b | 895 | |
kadonotakashi | 0:8fdf9a60065b | 896 | ### UDPSOCKET_SENDTO_TIMEOUT |
kadonotakashi | 0:8fdf9a60065b | 897 | |
kadonotakashi | 0:8fdf9a60065b | 898 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 899 | |
kadonotakashi | 0:8fdf9a60065b | 900 | Test whether timeouts are obeyed in UDPSockets. |
kadonotakashi | 0:8fdf9a60065b | 901 | |
kadonotakashi | 0:8fdf9a60065b | 902 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 903 | |
kadonotakashi | 0:8fdf9a60065b | 904 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 905 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 906 | |
kadonotakashi | 0:8fdf9a60065b | 907 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 908 | |
kadonotakashi | 0:8fdf9a60065b | 909 | 1. Record time |
kadonotakashi | 0:8fdf9a60065b | 910 | 2. Call `UDPSocket::sendto("echo.mbedcloudtesting.com", 9, <random packet, size = 100>, 100);` |
kadonotakashi | 0:8fdf9a60065b | 911 | 3. Record time |
kadonotakashi | 0:8fdf9a60065b | 912 | 4. Call `UDPSocket::set_timeout(1000)` |
kadonotakashi | 0:8fdf9a60065b | 913 | 5. Call `UDPSocket::sendto("echo.mbedcloudtesting.com", 9, <random packet, size = 100>, 100);` |
kadonotakashi | 0:8fdf9a60065b | 914 | 6. Record time |
kadonotakashi | 0:8fdf9a60065b | 915 | |
kadonotakashi | 0:8fdf9a60065b | 916 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 917 | |
kadonotakashi | 0:8fdf9a60065b | 918 | Each sendto() call should return 100. |
kadonotakashi | 0:8fdf9a60065b | 919 | |
kadonotakashi | 0:8fdf9a60065b | 920 | All sendto() calls should return faster than 100 milliseconds because |
kadonotakashi | 0:8fdf9a60065b | 921 | UDP sending should not block that long. |
kadonotakashi | 0:8fdf9a60065b | 922 | |
kadonotakashi | 0:8fdf9a60065b | 923 | |
kadonotakashi | 0:8fdf9a60065b | 924 | Test cases for TCPSocket class |
kadonotakashi | 0:8fdf9a60065b | 925 | ------------------------------ |
kadonotakashi | 0:8fdf9a60065b | 926 | |
kadonotakashi | 0:8fdf9a60065b | 927 | ### TCPSOCKET_OPEN_DESTRUCT |
kadonotakashi | 0:8fdf9a60065b | 928 | |
kadonotakashi | 0:8fdf9a60065b | 929 | **Description:** Run SOCKET_OPEN_DESTRUCT for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 930 | |
kadonotakashi | 0:8fdf9a60065b | 931 | ### TCPSOCKET_OPEN_LIMIT |
kadonotakashi | 0:8fdf9a60065b | 932 | |
kadonotakashi | 0:8fdf9a60065b | 933 | **Description:** Run SOCKET_OPEN_LIMIT for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 934 | |
kadonotakashi | 0:8fdf9a60065b | 935 | ### TCPSOCKET_OPEN_TWICE |
kadonotakashi | 0:8fdf9a60065b | 936 | |
kadonotakashi | 0:8fdf9a60065b | 937 | **Description:** Run SOCKET_OPEN_TWICE for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 938 | |
kadonotakashi | 0:8fdf9a60065b | 939 | ### TCPSOCKET_OPEN_CLOSE_REPEAT |
kadonotakashi | 0:8fdf9a60065b | 940 | |
kadonotakashi | 0:8fdf9a60065b | 941 | **Description:** Run SOCKET_OPEN_CLOSE_REPEAT for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 942 | |
kadonotakashi | 0:8fdf9a60065b | 943 | ### TCPSOCKET_BIND_PORT |
kadonotakashi | 0:8fdf9a60065b | 944 | |
kadonotakashi | 0:8fdf9a60065b | 945 | **Description:** Run SOCKET_BIND_PORT for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 946 | |
kadonotakashi | 0:8fdf9a60065b | 947 | ### TCPSOCKET_BIND_PORT_FAIL |
kadonotakashi | 0:8fdf9a60065b | 948 | |
kadonotakashi | 0:8fdf9a60065b | 949 | **Description:** Run SOCKET_BIND_PORT_FAIL for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 950 | |
kadonotakashi | 0:8fdf9a60065b | 951 | ### TCPSOCKET_BIND_ADDRESS_PORT |
kadonotakashi | 0:8fdf9a60065b | 952 | |
kadonotakashi | 0:8fdf9a60065b | 953 | **Description:** Run SOCKET_BIND_ADDRESS_PORT for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 954 | |
kadonotakashi | 0:8fdf9a60065b | 955 | ### TCPSOCKET_BIND_ADDRESS_NULL |
kadonotakashi | 0:8fdf9a60065b | 956 | |
kadonotakashi | 0:8fdf9a60065b | 957 | **Description:** Run SOCKET_BIND_ADDRESS_NULL for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 958 | |
kadonotakashi | 0:8fdf9a60065b | 959 | ### TCPSOCKET_BIND_ADDRESS_INVALID |
kadonotakashi | 0:8fdf9a60065b | 960 | |
kadonotakashi | 0:8fdf9a60065b | 961 | **Description:** Run SOCKET_BIND_ADDRESS_INVALID for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 962 | |
kadonotakashi | 0:8fdf9a60065b | 963 | ### TCPSOCKET_BIND_WRONG_TYPE |
kadonotakashi | 0:8fdf9a60065b | 964 | |
kadonotakashi | 0:8fdf9a60065b | 965 | **Description:** Run SOCKET_BIND_WRONG_TYPE for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 966 | |
kadonotakashi | 0:8fdf9a60065b | 967 | ### TCPSOCKET_BIND_ADDRESS |
kadonotakashi | 0:8fdf9a60065b | 968 | |
kadonotakashi | 0:8fdf9a60065b | 969 | **Description:** Run SOCKET_BIND_ADDRESS for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 970 | |
kadonotakashi | 0:8fdf9a60065b | 971 | ### TCPSOCKET_BIND_UNOPENED |
kadonotakashi | 0:8fdf9a60065b | 972 | |
kadonotakashi | 0:8fdf9a60065b | 973 | **Description:** Run SOCKET_BIND_UNOPENED for TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 974 | |
kadonotakashi | 0:8fdf9a60065b | 975 | ### TCPSOCKET_CONNECT_INVALID |
kadonotakashi | 0:8fdf9a60065b | 976 | |
kadonotakashi | 0:8fdf9a60065b | 977 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 978 | |
kadonotakashi | 0:8fdf9a60065b | 979 | Call `TCPSocket::connect()` with invalid parameters. |
kadonotakashi | 0:8fdf9a60065b | 980 | |
kadonotakashi | 0:8fdf9a60065b | 981 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 982 | |
kadonotakashi | 0:8fdf9a60065b | 983 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 984 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 985 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 986 | |
kadonotakashi | 0:8fdf9a60065b | 987 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 988 | |
kadonotakashi | 0:8fdf9a60065b | 989 | 1. Call `TCPSocket:connect( NULL, 9);` |
kadonotakashi | 0:8fdf9a60065b | 990 | 2. Call `TCPSocket:connect( "", 9);` |
kadonotakashi | 0:8fdf9a60065b | 991 | 3. Call `TCPSocket:connect( "", 0);` |
kadonotakashi | 0:8fdf9a60065b | 992 | 4. Call `TCPSocket:connect( "echo.mbedcloudtesting.com", 9);` |
kadonotakashi | 0:8fdf9a60065b | 993 | 5. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 994 | |
kadonotakashi | 0:8fdf9a60065b | 995 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 996 | |
kadonotakashi | 0:8fdf9a60065b | 997 | All connect() calls should return some error code except the number 5 |
kadonotakashi | 0:8fdf9a60065b | 998 | should return NSAPI_ERROR_OK. |
kadonotakashi | 0:8fdf9a60065b | 999 | |
kadonotakashi | 0:8fdf9a60065b | 1000 | |
kadonotakashi | 0:8fdf9a60065b | 1001 | |
kadonotakashi | 0:8fdf9a60065b | 1002 | ### TCPSOCKET_SEND_REPEAT |
kadonotakashi | 0:8fdf9a60065b | 1003 | |
kadonotakashi | 0:8fdf9a60065b | 1004 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1005 | |
kadonotakashi | 0:8fdf9a60065b | 1006 | Repeatedly send small packets. |
kadonotakashi | 0:8fdf9a60065b | 1007 | |
kadonotakashi | 0:8fdf9a60065b | 1008 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1009 | |
kadonotakashi | 0:8fdf9a60065b | 1010 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1011 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1012 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1013 | |
kadonotakashi | 0:8fdf9a60065b | 1014 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1015 | |
kadonotakashi | 0:8fdf9a60065b | 1016 | 1. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 9);` |
kadonotakashi | 0:8fdf9a60065b | 1017 | 2. Call `TCPSocket::send("hello", 5);` |
kadonotakashi | 0:8fdf9a60065b | 1018 | 3. repeat 1000 times |
kadonotakashi | 0:8fdf9a60065b | 1019 | 4. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 1020 | |
kadonotakashi | 0:8fdf9a60065b | 1021 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1022 | |
kadonotakashi | 0:8fdf9a60065b | 1023 | `TCPSocket::connect()` should return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 1024 | |
kadonotakashi | 0:8fdf9a60065b | 1025 | All send() calls should return 5. |
kadonotakashi | 0:8fdf9a60065b | 1026 | |
kadonotakashi | 0:8fdf9a60065b | 1027 | |
kadonotakashi | 0:8fdf9a60065b | 1028 | |
kadonotakashi | 0:8fdf9a60065b | 1029 | ### TCPSOCKET_ECHOTEST |
kadonotakashi | 0:8fdf9a60065b | 1030 | |
kadonotakashi | 0:8fdf9a60065b | 1031 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1032 | |
kadonotakashi | 0:8fdf9a60065b | 1033 | Repeatedly send packets to echo server and read incoming packets back. |
kadonotakashi | 0:8fdf9a60065b | 1034 | Verify working of different packet sizes. |
kadonotakashi | 0:8fdf9a60065b | 1035 | |
kadonotakashi | 0:8fdf9a60065b | 1036 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1037 | |
kadonotakashi | 0:8fdf9a60065b | 1038 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1039 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1040 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1041 | |
kadonotakashi | 0:8fdf9a60065b | 1042 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1043 | |
kadonotakashi | 0:8fdf9a60065b | 1044 | 1. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 7);` |
kadonotakashi | 0:8fdf9a60065b | 1045 | 2. Call `TCPSocket::send(<random packet, size = loop index>, <size>);` |
kadonotakashi | 0:8fdf9a60065b | 1046 | 1. If less than <loop index> was returned, size = sent bytes |
kadonotakashi | 0:8fdf9a60065b | 1047 | |
kadonotakashi | 0:8fdf9a60065b | 1048 | 3. Call `TCPSocket::recv(buffer, <size>);` |
kadonotakashi | 0:8fdf9a60065b | 1049 | 4. Verify incomming content was the same that was sent |
kadonotakashi | 0:8fdf9a60065b | 1050 | 5. Repeat 1200 times |
kadonotakashi | 0:8fdf9a60065b | 1051 | 6. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 1052 | |
kadonotakashi | 0:8fdf9a60065b | 1053 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1054 | |
kadonotakashi | 0:8fdf9a60065b | 1055 | All send() calls should return the packet size or less. All recv() calls |
kadonotakashi | 0:8fdf9a60065b | 1056 | should return the same sized packet that was send with same content. |
kadonotakashi | 0:8fdf9a60065b | 1057 | |
kadonotakashi | 0:8fdf9a60065b | 1058 | NOTE: This is stream so recv() might return less data than what was |
kadonotakashi | 0:8fdf9a60065b | 1059 | requested. In this case you need to keep calling recv() until all data |
kadonotakashi | 0:8fdf9a60065b | 1060 | that you have sent is returned. |
kadonotakashi | 0:8fdf9a60065b | 1061 | |
kadonotakashi | 0:8fdf9a60065b | 1062 | |
kadonotakashi | 0:8fdf9a60065b | 1063 | ### TCPSOCKET_ECHOTEST_NONBLOCK |
kadonotakashi | 0:8fdf9a60065b | 1064 | |
kadonotakashi | 0:8fdf9a60065b | 1065 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1066 | |
kadonotakashi | 0:8fdf9a60065b | 1067 | Repeatedly send packets to echo server and read incoming packets back. |
kadonotakashi | 0:8fdf9a60065b | 1068 | Verify working of different packet sizes. Use socket in non-blocking |
kadonotakashi | 0:8fdf9a60065b | 1069 | mode |
kadonotakashi | 0:8fdf9a60065b | 1070 | |
kadonotakashi | 0:8fdf9a60065b | 1071 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1072 | |
kadonotakashi | 0:8fdf9a60065b | 1073 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1074 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1075 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1076 | |
kadonotakashi | 0:8fdf9a60065b | 1077 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1078 | |
kadonotakashi | 0:8fdf9a60065b | 1079 | 1. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 7);` |
kadonotakashi | 0:8fdf9a60065b | 1080 | 2. Call `TCPSocket::set_blocking(false)` |
kadonotakashi | 0:8fdf9a60065b | 1081 | 3. Register event handler with `TCPSocket::sigio()` |
kadonotakashi | 0:8fdf9a60065b | 1082 | 4. Create another thread that constantly waits signal from `sigio()` |
kadonotakashi | 0:8fdf9a60065b | 1083 | handler, when received try `TCPSocket::recv(buf+index, <loop index> - index)`, where index is the amount of data |
kadonotakashi | 0:8fdf9a60065b | 1084 | already received. |
kadonotakashi | 0:8fdf9a60065b | 1085 | 5. Call `TCPSocket:send(<random packet, size = loop index>, <loop index>);` |
kadonotakashi | 0:8fdf9a60065b | 1086 | 1. If less than <loop index> was returned, try immeadiately |
kadonotakashi | 0:8fdf9a60065b | 1087 | sending remaining bytes. |
kadonotakashi | 0:8fdf9a60065b | 1088 | 2. If NSAPI_ERROR_WOULD_BLOCK is returned, wait for sigio() call |
kadonotakashi | 0:8fdf9a60065b | 1089 | to happen. |
kadonotakashi | 0:8fdf9a60065b | 1090 | |
kadonotakashi | 0:8fdf9a60065b | 1091 | 6. Wait for incomming packet for one second. |
kadonotakashi | 0:8fdf9a60065b | 1092 | 7. Verify incomming content was the same that was sent, set index for |
kadonotakashi | 0:8fdf9a60065b | 1093 | receiving thread to zero. |
kadonotakashi | 0:8fdf9a60065b | 1094 | 8. Repeat 1200 times |
kadonotakashi | 0:8fdf9a60065b | 1095 | 9. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 1096 | |
kadonotakashi | 0:8fdf9a60065b | 1097 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1098 | |
kadonotakashi | 0:8fdf9a60065b | 1099 | All send() calls should return the packet size or less. All recv() calls |
kadonotakashi | 0:8fdf9a60065b | 1100 | should return NSAPI_ERROR_WOULD_BLOCK or packet size that is equal or |
kadonotakashi | 0:8fdf9a60065b | 1101 | less than what has been sent. |
kadonotakashi | 0:8fdf9a60065b | 1102 | |
kadonotakashi | 0:8fdf9a60065b | 1103 | ### TCPSOCKET_RECV_TIMEOUT |
kadonotakashi | 0:8fdf9a60065b | 1104 | |
kadonotakashi | 0:8fdf9a60065b | 1105 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1106 | |
kadonotakashi | 0:8fdf9a60065b | 1107 | Test whether timeouts are obeyed in TCPSockets. |
kadonotakashi | 0:8fdf9a60065b | 1108 | |
kadonotakashi | 0:8fdf9a60065b | 1109 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1110 | |
kadonotakashi | 0:8fdf9a60065b | 1111 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1112 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1113 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1114 | |
kadonotakashi | 0:8fdf9a60065b | 1115 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1116 | |
kadonotakashi | 0:8fdf9a60065b | 1117 | 1. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 7);` |
kadonotakashi | 0:8fdf9a60065b | 1118 | 2. Call `TCPSocket::set_timeout(100);` |
kadonotakashi | 0:8fdf9a60065b | 1119 | 3. Call `TCPSocket::send(<random packet, size = 100>;, 100);` |
kadonotakashi | 0:8fdf9a60065b | 1120 | 4. Repeat 5 times |
kadonotakashi | 0:8fdf9a60065b | 1121 | 1. record a time in millisecond precission |
kadonotakashi | 0:8fdf9a60065b | 1122 | 2. Call `TCPSocket::recv()` |
kadonotakashi | 0:8fdf9a60065b | 1123 | 3. record a time in millisecond precission |
kadonotakashi | 0:8fdf9a60065b | 1124 | |
kadonotakashi | 0:8fdf9a60065b | 1125 | 5. repeat testcase 10 times. |
kadonotakashi | 0:8fdf9a60065b | 1126 | |
kadonotakashi | 0:8fdf9a60065b | 1127 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1128 | |
kadonotakashi | 0:8fdf9a60065b | 1129 | Each send() call should return 100. |
kadonotakashi | 0:8fdf9a60065b | 1130 | |
kadonotakashi | 0:8fdf9a60065b | 1131 | Within each loop, one recv() may return the received packet size (100). |
kadonotakashi | 0:8fdf9a60065b | 1132 | Other calls should return NSAPI_ERROR_WOULD_BLOCK. |
kadonotakashi | 0:8fdf9a60065b | 1133 | |
kadonotakashi | 0:8fdf9a60065b | 1134 | When NSAPI_ERROR_WOULD_BLOCK is received, check that time consumed is |
kadonotakashi | 0:8fdf9a60065b | 1135 | more that 100 milliseconds but less than 200 milliseconds. |
kadonotakashi | 0:8fdf9a60065b | 1136 | |
kadonotakashi | 0:8fdf9a60065b | 1137 | |
kadonotakashi | 0:8fdf9a60065b | 1138 | ### TCPSOCKET_SEND_TIMEOUT |
kadonotakashi | 0:8fdf9a60065b | 1139 | |
kadonotakashi | 0:8fdf9a60065b | 1140 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1141 | |
kadonotakashi | 0:8fdf9a60065b | 1142 | Repeatedly send small packets in a given time limit |
kadonotakashi | 0:8fdf9a60065b | 1143 | |
kadonotakashi | 0:8fdf9a60065b | 1144 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1145 | |
kadonotakashi | 0:8fdf9a60065b | 1146 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1147 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1148 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1149 | |
kadonotakashi | 0:8fdf9a60065b | 1150 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1151 | |
kadonotakashi | 0:8fdf9a60065b | 1152 | 1. Call `TCPSocket:connect("echo.mbedcloudtesting.com", 9);` |
kadonotakashi | 0:8fdf9a60065b | 1153 | 3. Call `TCPSocket:set_blocking(false);` |
kadonotakashi | 0:8fdf9a60065b | 1154 | 3. Call `TCPSocket:send("hello", 5);` |
kadonotakashi | 0:8fdf9a60065b | 1155 | 4. repeat 10 times |
kadonotakashi | 0:8fdf9a60065b | 1156 | 5. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 1157 | |
kadonotakashi | 0:8fdf9a60065b | 1158 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1159 | |
kadonotakashi | 0:8fdf9a60065b | 1160 | `TCPSocket::connect()` should return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 1161 | |
kadonotakashi | 0:8fdf9a60065b | 1162 | All send() calls should return in less than 800 milliseconds |
kadonotakashi | 0:8fdf9a60065b | 1163 | |
kadonotakashi | 0:8fdf9a60065b | 1164 | |
kadonotakashi | 0:8fdf9a60065b | 1165 | ### TCPSOCKET_ENDPOINT_CLOSE |
kadonotakashi | 0:8fdf9a60065b | 1166 | |
kadonotakashi | 0:8fdf9a60065b | 1167 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1168 | |
kadonotakashi | 0:8fdf9a60065b | 1169 | Test whether we tolerate endpoint closing the connection. |
kadonotakashi | 0:8fdf9a60065b | 1170 | |
kadonotakashi | 0:8fdf9a60065b | 1171 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1172 | |
kadonotakashi | 0:8fdf9a60065b | 1173 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1174 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1175 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1176 | |
kadonotakashi | 0:8fdf9a60065b | 1177 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1178 | |
kadonotakashi | 0:8fdf9a60065b | 1179 | 1. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 13);` |
kadonotakashi | 0:8fdf9a60065b | 1180 | 2. Call `TCPSocket::recv(<buffer>, 30);` |
kadonotakashi | 0:8fdf9a60065b | 1181 | 3. Repeat until recv() returns 0 |
kadonotakashi | 0:8fdf9a60065b | 1182 | 4. Call `TCPSocket::close();` |
kadonotakashi | 0:8fdf9a60065b | 1183 | 5. delete socket |
kadonotakashi | 0:8fdf9a60065b | 1184 | |
kadonotakashi | 0:8fdf9a60065b | 1185 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1186 | Connect should return NSAPI_ERROR_OK. |
kadonotakashi | 0:8fdf9a60065b | 1187 | |
kadonotakashi | 0:8fdf9a60065b | 1188 | First recv() should return more that zero. Something between 10 and 30 |
kadonotakashi | 0:8fdf9a60065b | 1189 | bytes (datetime string) |
kadonotakashi | 0:8fdf9a60065b | 1190 | |
kadonotakashi | 0:8fdf9a60065b | 1191 | Second recv() should return zero because endpoint closed the connection. |
kadonotakashi | 0:8fdf9a60065b | 1192 | (EOF). close() should return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 1193 | |
kadonotakashi | 0:8fdf9a60065b | 1194 | ### TCPSOCKET_SETSOCKOPT_KEEPALIVE_VALID |
kadonotakashi | 0:8fdf9a60065b | 1195 | |
kadonotakashi | 0:8fdf9a60065b | 1196 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1197 | |
kadonotakashi | 0:8fdf9a60065b | 1198 | Test we are able to request setting valid TCP keepalive values |
kadonotakashi | 0:8fdf9a60065b | 1199 | |
kadonotakashi | 0:8fdf9a60065b | 1200 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1201 | |
kadonotakashi | 0:8fdf9a60065b | 1202 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1203 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1204 | |
kadonotakashi | 0:8fdf9a60065b | 1205 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1206 | |
kadonotakashi | 0:8fdf9a60065b | 1207 | 1. Call `TCPSocket::setsockopt(keepalive, [0,1 or 7200]);` |
kadonotakashi | 0:8fdf9a60065b | 1208 | 2. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 9);` |
kadonotakashi | 0:8fdf9a60065b | 1209 | 3. Call `TCPSocket::getsockopt(keepalive);` |
kadonotakashi | 0:8fdf9a60065b | 1210 | |
kadonotakashi | 0:8fdf9a60065b | 1211 | **Postconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1212 | |
kadonotakashi | 0:8fdf9a60065b | 1213 | 1. Call `TCPSocket::close();` |
kadonotakashi | 0:8fdf9a60065b | 1214 | 2. delete socket |
kadonotakashi | 0:8fdf9a60065b | 1215 | |
kadonotakashi | 0:8fdf9a60065b | 1216 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1217 | |
kadonotakashi | 0:8fdf9a60065b | 1218 | `TCPSocket::getsockopt(keepalive)` returns same value as was set with |
kadonotakashi | 0:8fdf9a60065b | 1219 | `TCPSocket::setsockopt()` or NSAPI_ERROR_UNSUPPORTED |
kadonotakashi | 0:8fdf9a60065b | 1220 | |
kadonotakashi | 0:8fdf9a60065b | 1221 | ### TCPSOCKET_SETSOCKOPT_KEEPALIVE_INVALID |
kadonotakashi | 0:8fdf9a60065b | 1222 | |
kadonotakashi | 0:8fdf9a60065b | 1223 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1224 | |
kadonotakashi | 0:8fdf9a60065b | 1225 | Test we are able to detect if an invalid TCP keepalive value is tried to |
kadonotakashi | 0:8fdf9a60065b | 1226 | be set |
kadonotakashi | 0:8fdf9a60065b | 1227 | |
kadonotakashi | 0:8fdf9a60065b | 1228 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1229 | |
kadonotakashi | 0:8fdf9a60065b | 1230 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1231 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1232 | |
kadonotakashi | 0:8fdf9a60065b | 1233 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1234 | |
kadonotakashi | 0:8fdf9a60065b | 1235 | 1. Call `TCPSocket::setsockopt(keepalive, [-1 or 7201]);` |
kadonotakashi | 0:8fdf9a60065b | 1236 | 2. Call `TCPSocket::getsockopt(keepalive);` |
kadonotakashi | 0:8fdf9a60065b | 1237 | |
kadonotakashi | 0:8fdf9a60065b | 1238 | **Postconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1239 | |
kadonotakashi | 0:8fdf9a60065b | 1240 | 1. Call `TCPSocket::close();` |
kadonotakashi | 0:8fdf9a60065b | 1241 | 2. delete socket |
kadonotakashi | 0:8fdf9a60065b | 1242 | |
kadonotakashi | 0:8fdf9a60065b | 1243 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1244 | |
kadonotakashi | 0:8fdf9a60065b | 1245 | `TCPSocket::setsockopt(keepalive)` returns error code or |
kadonotakashi | 0:8fdf9a60065b | 1246 | NSAPI_ERROR_UNSUPPORTED |
kadonotakashi | 0:8fdf9a60065b | 1247 | |
kadonotakashi | 0:8fdf9a60065b | 1248 | `TCPSocket::getsockopt()` returns 0 or NSAPI_ERROR_UNSUPPORTED |
kadonotakashi | 0:8fdf9a60065b | 1249 | |
kadonotakashi | 0:8fdf9a60065b | 1250 | |
kadonotakashi | 0:8fdf9a60065b | 1251 | Test cases for TCPServer class |
kadonotakashi | 0:8fdf9a60065b | 1252 | ------------------------------ |
kadonotakashi | 0:8fdf9a60065b | 1253 | |
kadonotakashi | 0:8fdf9a60065b | 1254 | These tests require two devices under test and connectivity between |
kadonotakashi | 0:8fdf9a60065b | 1255 | them. Therefore they can only be ran with LAN connectivity (Eth, Wifi or |
kadonotakashi | 0:8fdf9a60065b | 1256 | Mesh) or if there is no firewall between devices. |
kadonotakashi | 0:8fdf9a60065b | 1257 | |
kadonotakashi | 0:8fdf9a60065b | 1258 | |
kadonotakashi | 0:8fdf9a60065b | 1259 | ### TCPSERVER_ACCEPT |
kadonotakashi | 0:8fdf9a60065b | 1260 | |
kadonotakashi | 0:8fdf9a60065b | 1261 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1262 | |
kadonotakashi | 0:8fdf9a60065b | 1263 | Test that `TCPServer::bind()`, `TCPServer::listen()` |
kadonotakashi | 0:8fdf9a60065b | 1264 | and `TCPServer::accept()` works. |
kadonotakashi | 0:8fdf9a60065b | 1265 | |
kadonotakashi | 0:8fdf9a60065b | 1266 | Requires 2 devices. |
kadonotakashi | 0:8fdf9a60065b | 1267 | |
kadonotakashi | 0:8fdf9a60065b | 1268 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1269 | |
kadonotakashi | 0:8fdf9a60065b | 1270 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1271 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1272 | |
kadonotakashi | 0:8fdf9a60065b | 1273 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1274 | |
kadonotakashi | 0:8fdf9a60065b | 1275 | 1. DUT1: `TCPServer::bind(<port>)` |
kadonotakashi | 0:8fdf9a60065b | 1276 | 2. DUT1: `TCPServer::listen()` |
kadonotakashi | 0:8fdf9a60065b | 1277 | 3. DUT1: Create a new `TCPSocket` |
kadonotakashi | 0:8fdf9a60065b | 1278 | 4. DUT1: `TCPServer::accept()` |
kadonotakashi | 0:8fdf9a60065b | 1279 | 5. DUT2: Create a new `TCPSocket` |
kadonotakashi | 0:8fdf9a60065b | 1280 | 6. DUT2: `TCPSocket::connect(<dut1>, <port>)` |
kadonotakashi | 0:8fdf9a60065b | 1281 | 7. DUT1: should receive new socket from accept(), |
kadonotakashi | 0:8fdf9a60065b | 1282 | call `TCPSocket::send("hello",5)` for it |
kadonotakashi | 0:8fdf9a60065b | 1283 | 8. DUT2: call `TCPSocket::recv(buffer, 5)` |
kadonotakashi | 0:8fdf9a60065b | 1284 | 9. DUT2: Verify that it received "hello" |
kadonotakashi | 0:8fdf9a60065b | 1285 | 10. destroy all sockets. |
kadonotakashi | 0:8fdf9a60065b | 1286 | |
kadonotakashi | 0:8fdf9a60065b | 1287 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1288 | |
kadonotakashi | 0:8fdf9a60065b | 1289 | On DUT1 accept() call blocks until connection is received. Other calls |
kadonotakashi | 0:8fdf9a60065b | 1290 | should return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 1291 | |
kadonotakashi | 0:8fdf9a60065b | 1292 | On DUT2 all calls should return NSAPI_ERROR_OK |
kadonotakashi | 0:8fdf9a60065b | 1293 | |
kadonotakashi | 0:8fdf9a60065b | 1294 | |
kadonotakashi | 0:8fdf9a60065b | 1295 | |
kadonotakashi | 0:8fdf9a60065b | 1296 | ### TCPSERVER_LISTEN |
kadonotakashi | 0:8fdf9a60065b | 1297 | |
kadonotakashi | 0:8fdf9a60065b | 1298 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1299 | |
kadonotakashi | 0:8fdf9a60065b | 1300 | Test that `TCPServer::listen()` has the backlog functionality. |
kadonotakashi | 0:8fdf9a60065b | 1301 | |
kadonotakashi | 0:8fdf9a60065b | 1302 | Requires 2 devices. |
kadonotakashi | 0:8fdf9a60065b | 1303 | |
kadonotakashi | 0:8fdf9a60065b | 1304 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1305 | |
kadonotakashi | 0:8fdf9a60065b | 1306 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1307 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1308 | |
kadonotakashi | 0:8fdf9a60065b | 1309 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1310 | |
kadonotakashi | 0:8fdf9a60065b | 1311 | 1. DUT1: `TCPServer::bind(<port>)` |
kadonotakashi | 0:8fdf9a60065b | 1312 | 2. DUT1: `TCPServer::listen(2)` |
kadonotakashi | 0:8fdf9a60065b | 1313 | 3. loop 2 times: |
kadonotakashi | 0:8fdf9a60065b | 1314 | 1. DUT2: Create a new TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 1315 | 2. DUT2: `TCPSocket::connect(<dut1>, <port>)` |
kadonotakashi | 0:8fdf9a60065b | 1316 | |
kadonotakashi | 0:8fdf9a60065b | 1317 | 4. loop 2 times: |
kadonotakashi | 0:8fdf9a60065b | 1318 | 1. DUT1: Create a new TCPSocket |
kadonotakashi | 0:8fdf9a60065b | 1319 | 2. DUT1: `TCPServer::accept()` |
kadonotakashi | 0:8fdf9a60065b | 1320 | 3. DUT1: should receive new socket from accept(), |
kadonotakashi | 0:8fdf9a60065b | 1321 | call `TCPSocket::send("hello",5)` for it |
kadonotakashi | 0:8fdf9a60065b | 1322 | |
kadonotakashi | 0:8fdf9a60065b | 1323 | 5. DUT2: call `TCPSocket::recv(buffer, 5)` for both socket. |
kadonotakashi | 0:8fdf9a60065b | 1324 | 6. DUT2: Verify that it received "hello" |
kadonotakashi | 0:8fdf9a60065b | 1325 | 7. destroy all sockets. |
kadonotakashi | 0:8fdf9a60065b | 1326 | |
kadonotakashi | 0:8fdf9a60065b | 1327 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1328 | |
kadonotakashi | 0:8fdf9a60065b | 1329 | DUT2 should receive connection before the server have called accept(), |
kadonotakashi | 0:8fdf9a60065b | 1330 | because backlog must be minimum of 2. |
kadonotakashi | 0:8fdf9a60065b | 1331 | |
kadonotakashi | 0:8fdf9a60065b | 1332 | |
kadonotakashi | 0:8fdf9a60065b | 1333 | ### TCPSERVER_LISTEN_WITHOUT_BIND |
kadonotakashi | 0:8fdf9a60065b | 1334 | |
kadonotakashi | 0:8fdf9a60065b | 1335 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1336 | |
kadonotakashi | 0:8fdf9a60065b | 1337 | Call `TCPServer::listen()` without calling bind() first. Should fail, |
kadonotakashi | 0:8fdf9a60065b | 1338 | because no listening port have been defined. |
kadonotakashi | 0:8fdf9a60065b | 1339 | |
kadonotakashi | 0:8fdf9a60065b | 1340 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1341 | |
kadonotakashi | 0:8fdf9a60065b | 1342 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1343 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1344 | |
kadonotakashi | 0:8fdf9a60065b | 1345 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1346 | |
kadonotakashi | 0:8fdf9a60065b | 1347 | 1. Create TCPServer |
kadonotakashi | 0:8fdf9a60065b | 1348 | 2. Call `TCPServer::listen()` |
kadonotakashi | 0:8fdf9a60065b | 1349 | |
kadonotakashi | 0:8fdf9a60065b | 1350 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1351 | |
kadonotakashi | 0:8fdf9a60065b | 1352 | Should |
kadonotakashi | 0:8fdf9a60065b | 1353 | return NSAPI_ERROR_UNSUPPORTED, NSAPI_ERROR_PARAMETER, NSAPI_ERROR_NO_ADDRESS |
kadonotakashi | 0:8fdf9a60065b | 1354 | or NSAPI_ERROR_DEVICE_ERROR |
kadonotakashi | 0:8fdf9a60065b | 1355 | |
kadonotakashi | 0:8fdf9a60065b | 1356 | |
kadonotakashi | 0:8fdf9a60065b | 1357 | ### TCPSERVER_ACCEPT_WITHOUT_LISTEN |
kadonotakashi | 0:8fdf9a60065b | 1358 | |
kadonotakashi | 0:8fdf9a60065b | 1359 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1360 | |
kadonotakashi | 0:8fdf9a60065b | 1361 | Call `TCPServer::accept()` without calling listen() first. Should fail, |
kadonotakashi | 0:8fdf9a60065b | 1362 | because socket is not listening for connections. |
kadonotakashi | 0:8fdf9a60065b | 1363 | |
kadonotakashi | 0:8fdf9a60065b | 1364 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1365 | |
kadonotakashi | 0:8fdf9a60065b | 1366 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1367 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1368 | |
kadonotakashi | 0:8fdf9a60065b | 1369 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1370 | |
kadonotakashi | 0:8fdf9a60065b | 1371 | 1. Create TCPServer |
kadonotakashi | 0:8fdf9a60065b | 1372 | 2. Call `TCPServer::bind(<unused port number>)` |
kadonotakashi | 0:8fdf9a60065b | 1373 | 3. Create new TCPSocket. |
kadonotakashi | 0:8fdf9a60065b | 1374 | 4. Call `TCPServer::accept()` |
kadonotakashi | 0:8fdf9a60065b | 1375 | |
kadonotakashi | 0:8fdf9a60065b | 1376 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1377 | |
kadonotakashi | 0:8fdf9a60065b | 1378 | Should return NSAPI_ERROR_UNSUPPORTED, NSAPI_ERROR_PARAMETER |
kadonotakashi | 0:8fdf9a60065b | 1379 | or NSAPI_ERROR_DEVICE_ERROR |
kadonotakashi | 0:8fdf9a60065b | 1380 | |
kadonotakashi | 0:8fdf9a60065b | 1381 | |
kadonotakashi | 0:8fdf9a60065b | 1382 | Performance tests |
kadonotakashi | 0:8fdf9a60065b | 1383 | ----------------- |
kadonotakashi | 0:8fdf9a60065b | 1384 | |
kadonotakashi | 0:8fdf9a60065b | 1385 | |
kadonotakashi | 0:8fdf9a60065b | 1386 | ### UDPSOCKET_ECHOTEST_BURST |
kadonotakashi | 0:8fdf9a60065b | 1387 | |
kadonotakashi | 0:8fdf9a60065b | 1388 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1389 | |
kadonotakashi | 0:8fdf9a60065b | 1390 | Send burst of packets to echo server and read incoming packets back. |
kadonotakashi | 0:8fdf9a60065b | 1391 | |
kadonotakashi | 0:8fdf9a60065b | 1392 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1393 | |
kadonotakashi | 0:8fdf9a60065b | 1394 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1395 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1396 | 3. UDPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1397 | |
kadonotakashi | 0:8fdf9a60065b | 1398 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1399 | |
kadonotakashi | 0:8fdf9a60065b | 1400 | 1. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 100>, 100);` |
kadonotakashi | 0:8fdf9a60065b | 1401 | 2. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 200>, 200);` |
kadonotakashi | 0:8fdf9a60065b | 1402 | 3. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 300>, 300);` |
kadonotakashi | 0:8fdf9a60065b | 1403 | 4. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 120>, 120);` |
kadonotakashi | 0:8fdf9a60065b | 1404 | 5. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 500>, 500);` |
kadonotakashi | 0:8fdf9a60065b | 1405 | 6. Wait for incomming packets for five second. |
kadonotakashi | 0:8fdf9a60065b | 1406 | 7. Verify incomming content was the same that was sent. Allow |
kadonotakashi | 0:8fdf9a60065b | 1407 | packet reordering. |
kadonotakashi | 0:8fdf9a60065b | 1408 | 8. Repeat 100 times |
kadonotakashi | 0:8fdf9a60065b | 1409 | 9. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 1410 | |
kadonotakashi | 0:8fdf9a60065b | 1411 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1412 | |
kadonotakashi | 0:8fdf9a60065b | 1413 | All sendto() calls should return the packet size. |
kadonotakashi | 0:8fdf9a60065b | 1414 | |
kadonotakashi | 0:8fdf9a60065b | 1415 | All recvfrom() calls should return the same sized packet that was send |
kadonotakashi | 0:8fdf9a60065b | 1416 | with same content. Allow packet reordering. |
kadonotakashi | 0:8fdf9a60065b | 1417 | |
kadonotakashi | 0:8fdf9a60065b | 1418 | Calculate packet loss rate, maximum tolerated packet loss rate is 30% |
kadonotakashi | 0:8fdf9a60065b | 1419 | |
kadonotakashi | 0:8fdf9a60065b | 1420 | Calculate number of succesfull rounds, it should be higher than 70 |
kadonotakashi | 0:8fdf9a60065b | 1421 | |
kadonotakashi | 0:8fdf9a60065b | 1422 | |
kadonotakashi | 0:8fdf9a60065b | 1423 | ### UDPSOCKET_ECHOTEST_BURST_NONBLOCK |
kadonotakashi | 0:8fdf9a60065b | 1424 | |
kadonotakashi | 0:8fdf9a60065b | 1425 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1426 | |
kadonotakashi | 0:8fdf9a60065b | 1427 | Send burst of packets to echo server and read incoming packets back. Use |
kadonotakashi | 0:8fdf9a60065b | 1428 | socket in non-blocking mode |
kadonotakashi | 0:8fdf9a60065b | 1429 | |
kadonotakashi | 0:8fdf9a60065b | 1430 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1431 | |
kadonotakashi | 0:8fdf9a60065b | 1432 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1433 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1434 | 3. UDPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1435 | |
kadonotakashi | 0:8fdf9a60065b | 1436 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1437 | |
kadonotakashi | 0:8fdf9a60065b | 1438 | 1. Call `UDPSocket::set_blocking(false)` |
kadonotakashi | 0:8fdf9a60065b | 1439 | 2. Register event handler with `UDPSocket::sigio()` |
kadonotakashi | 0:8fdf9a60065b | 1440 | 3. Create another thread that constantly waits signal from sigio() |
kadonotakashi | 0:8fdf9a60065b | 1441 | handler, when received try `UDPSocket::recvfrom()` |
kadonotakashi | 0:8fdf9a60065b | 1442 | 4. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 100>, 100);` |
kadonotakashi | 0:8fdf9a60065b | 1443 | 5. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 200>, 200);` |
kadonotakashi | 0:8fdf9a60065b | 1444 | 6. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 300>, 300);` |
kadonotakashi | 0:8fdf9a60065b | 1445 | 7. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 120>, 120);` |
kadonotakashi | 0:8fdf9a60065b | 1446 | 8. Call `UDPSocket:sendto("echo.mbedcloudtesting.com", 7, <random packet, size = 500>, 500);` |
kadonotakashi | 0:8fdf9a60065b | 1447 | 9. Wait for incomming packets for five second. |
kadonotakashi | 0:8fdf9a60065b | 1448 | 10. Verify incomming content was the same that was sent. Allow |
kadonotakashi | 0:8fdf9a60065b | 1449 | packet reordering. |
kadonotakashi | 0:8fdf9a60065b | 1450 | 11. Repeat 100 times |
kadonotakashi | 0:8fdf9a60065b | 1451 | 12. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 1452 | |
kadonotakashi | 0:8fdf9a60065b | 1453 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1454 | |
kadonotakashi | 0:8fdf9a60065b | 1455 | All sendto() calls should return the packet size. |
kadonotakashi | 0:8fdf9a60065b | 1456 | |
kadonotakashi | 0:8fdf9a60065b | 1457 | All recvfrom() calls should return the same sized packet that was send |
kadonotakashi | 0:8fdf9a60065b | 1458 | with same content. Allow packet reordering. |
kadonotakashi | 0:8fdf9a60065b | 1459 | |
kadonotakashi | 0:8fdf9a60065b | 1460 | Calculate packet loss rate, maximum tolerated packet loss rate is 30% |
kadonotakashi | 0:8fdf9a60065b | 1461 | |
kadonotakashi | 0:8fdf9a60065b | 1462 | Calculate number of succesfull rounds, it should be higher than 70 |
kadonotakashi | 0:8fdf9a60065b | 1463 | |
kadonotakashi | 0:8fdf9a60065b | 1464 | |
kadonotakashi | 0:8fdf9a60065b | 1465 | |
kadonotakashi | 0:8fdf9a60065b | 1466 | ### TCPSOCKET_ECHOTEST_BURST |
kadonotakashi | 0:8fdf9a60065b | 1467 | |
kadonotakashi | 0:8fdf9a60065b | 1468 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1469 | |
kadonotakashi | 0:8fdf9a60065b | 1470 | Send burst of packets to echo server and read incoming packets back. |
kadonotakashi | 0:8fdf9a60065b | 1471 | |
kadonotakashi | 0:8fdf9a60065b | 1472 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1473 | |
kadonotakashi | 0:8fdf9a60065b | 1474 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1475 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1476 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1477 | |
kadonotakashi | 0:8fdf9a60065b | 1478 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1479 | |
kadonotakashi | 0:8fdf9a60065b | 1480 | 1. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 7);` |
kadonotakashi | 0:8fdf9a60065b | 1481 | 2. Call `TCPSocket::send(<random packet, size = 100>, 100);` |
kadonotakashi | 0:8fdf9a60065b | 1482 | 3. Call `TCPSocket::send(<random packet, size = 200>, 200);` |
kadonotakashi | 0:8fdf9a60065b | 1483 | 4. Call `TCPSocket::send(<random packet, size = 300>, 300);` |
kadonotakashi | 0:8fdf9a60065b | 1484 | 5. Call `TCPSocket::send(<random packet, size = 120>, 120);` |
kadonotakashi | 0:8fdf9a60065b | 1485 | 6. Call `TCPSocket::send(<random packet, size = 500>, 500);` |
kadonotakashi | 0:8fdf9a60065b | 1486 | 7. Call `TCPSocket::recv(buf, 1220)` |
kadonotakashi | 0:8fdf9a60065b | 1487 | 8. Verify incomming content was the same that was sent. |
kadonotakashi | 0:8fdf9a60065b | 1488 | 9. Repeat 100 times |
kadonotakashi | 0:8fdf9a60065b | 1489 | 10. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 1490 | |
kadonotakashi | 0:8fdf9a60065b | 1491 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1492 | |
kadonotakashi | 0:8fdf9a60065b | 1493 | All send() calls should return the packet size. |
kadonotakashi | 0:8fdf9a60065b | 1494 | |
kadonotakashi | 0:8fdf9a60065b | 1495 | NOTE: This is stream so recv() might return less data than what was |
kadonotakashi | 0:8fdf9a60065b | 1496 | requested. In this case you need to keep calling recv() with remaining |
kadonotakashi | 0:8fdf9a60065b | 1497 | size until all data that you have sent is returned. |
kadonotakashi | 0:8fdf9a60065b | 1498 | |
kadonotakashi | 0:8fdf9a60065b | 1499 | Consecutive calls to recv() should return all the data that has been |
kadonotakashi | 0:8fdf9a60065b | 1500 | send. Total amount of returned must match 1220. |
kadonotakashi | 0:8fdf9a60065b | 1501 | |
kadonotakashi | 0:8fdf9a60065b | 1502 | |
kadonotakashi | 0:8fdf9a60065b | 1503 | ### TCPSOCKET_ECHOTEST_BURST_NONBLOCK |
kadonotakashi | 0:8fdf9a60065b | 1504 | |
kadonotakashi | 0:8fdf9a60065b | 1505 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1506 | |
kadonotakashi | 0:8fdf9a60065b | 1507 | Send burst of packets to echo server and read incoming packets back. Use |
kadonotakashi | 0:8fdf9a60065b | 1508 | socket in non-blocking mode |
kadonotakashi | 0:8fdf9a60065b | 1509 | |
kadonotakashi | 0:8fdf9a60065b | 1510 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1511 | |
kadonotakashi | 0:8fdf9a60065b | 1512 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1513 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1514 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1515 | |
kadonotakashi | 0:8fdf9a60065b | 1516 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1517 | |
kadonotakashi | 0:8fdf9a60065b | 1518 | 1. Register event handler with `TCPSocket::sigio()` |
kadonotakashi | 0:8fdf9a60065b | 1519 | 2. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 7);` |
kadonotakashi | 0:8fdf9a60065b | 1520 | 3. Call `TCPSocket::set_blocking(false)` |
kadonotakashi | 0:8fdf9a60065b | 1521 | 4. Create another thread that constantly waits signal from sigio() |
kadonotakashi | 0:8fdf9a60065b | 1522 | handler, when received try `TCPSocket::recv()` |
kadonotakashi | 0:8fdf9a60065b | 1523 | 5. For randomly generated packets, sized 100, 200, 300, 120 and 500 do |
kadonotakashi | 0:8fdf9a60065b | 1524 | 1. Call `TCPSocket::send(packet, size);` |
kadonotakashi | 0:8fdf9a60065b | 1525 | 2. If less than size is sent, repeat with remaining. |
kadonotakashi | 0:8fdf9a60065b | 1526 | 3. If NSAPI_ERROR_WOULD_BLOCK returned, wait for next sigio() |
kadonotakashi | 0:8fdf9a60065b | 1527 | |
kadonotakashi | 0:8fdf9a60065b | 1528 | 6. Wait for incomming packets for five second. |
kadonotakashi | 0:8fdf9a60065b | 1529 | 7. Verify incomming content was the same that was sent. Allow recv() to |
kadonotakashi | 0:8fdf9a60065b | 1530 | return smaller piezes. |
kadonotakashi | 0:8fdf9a60065b | 1531 | 8. Repeat 100 times |
kadonotakashi | 0:8fdf9a60065b | 1532 | 9. destroy the socket |
kadonotakashi | 0:8fdf9a60065b | 1533 | |
kadonotakashi | 0:8fdf9a60065b | 1534 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1535 | |
kadonotakashi | 0:8fdf9a60065b | 1536 | All send() calls should return NSAPI_ERROR_WOULD_BLOCK or size which |
kadonotakashi | 0:8fdf9a60065b | 1537 | is equal or less than requested. |
kadonotakashi | 0:8fdf9a60065b | 1538 | |
kadonotakashi | 0:8fdf9a60065b | 1539 | All recv() calls should return value that is less or equal to what have |
kadonotakashi | 0:8fdf9a60065b | 1540 | been sent. With consecutive calls, size should match. |
kadonotakashi | 0:8fdf9a60065b | 1541 | |
kadonotakashi | 0:8fdf9a60065b | 1542 | When recv() returns NSAPI_ERROR_WOULD_BLOCK wait for next sigio() |
kadonotakashi | 0:8fdf9a60065b | 1543 | event. No other error codes allowed. |
kadonotakashi | 0:8fdf9a60065b | 1544 | |
kadonotakashi | 0:8fdf9a60065b | 1545 | |
kadonotakashi | 0:8fdf9a60065b | 1546 | ### TCPSOCKET_RECV_100K |
kadonotakashi | 0:8fdf9a60065b | 1547 | |
kadonotakashi | 0:8fdf9a60065b | 1548 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1549 | |
kadonotakashi | 0:8fdf9a60065b | 1550 | Download 100kB of data |
kadonotakashi | 0:8fdf9a60065b | 1551 | |
kadonotakashi | 0:8fdf9a60065b | 1552 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1553 | |
kadonotakashi | 0:8fdf9a60065b | 1554 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1555 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1556 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1557 | |
kadonotakashi | 0:8fdf9a60065b | 1558 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1559 | |
kadonotakashi | 0:8fdf9a60065b | 1560 | 1. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 19);` |
kadonotakashi | 0:8fdf9a60065b | 1561 | 2. Call `TCPSocket::recv(buffer, 100);` |
kadonotakashi | 0:8fdf9a60065b | 1562 | 3. Verify input according to known pattern. |
kadonotakashi | 0:8fdf9a60065b | 1563 | 4. Loop until 100kB of data received. |
kadonotakashi | 0:8fdf9a60065b | 1564 | 5. close socket. |
kadonotakashi | 0:8fdf9a60065b | 1565 | |
kadonotakashi | 0:8fdf9a60065b | 1566 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1567 | |
kadonotakashi | 0:8fdf9a60065b | 1568 | Each recv() call should return equal or less than 100 bytes of data. No |
kadonotakashi | 0:8fdf9a60065b | 1569 | errors should be returned. |
kadonotakashi | 0:8fdf9a60065b | 1570 | |
kadonotakashi | 0:8fdf9a60065b | 1571 | Measure time taken for receiving, report speed |
kadonotakashi | 0:8fdf9a60065b | 1572 | |
kadonotakashi | 0:8fdf9a60065b | 1573 | ### TCPSOCKET_RECV_100K_NONBLOCK |
kadonotakashi | 0:8fdf9a60065b | 1574 | |
kadonotakashi | 0:8fdf9a60065b | 1575 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1576 | |
kadonotakashi | 0:8fdf9a60065b | 1577 | Download 100kB of data |
kadonotakashi | 0:8fdf9a60065b | 1578 | |
kadonotakashi | 0:8fdf9a60065b | 1579 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1580 | |
kadonotakashi | 0:8fdf9a60065b | 1581 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1582 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1583 | 3. TCPSocket is open |
kadonotakashi | 0:8fdf9a60065b | 1584 | |
kadonotakashi | 0:8fdf9a60065b | 1585 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1586 | |
kadonotakashi | 0:8fdf9a60065b | 1587 | 1. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 19);` |
kadonotakashi | 0:8fdf9a60065b | 1588 | 2. Call `TCPSocket::set_blocking(false)` |
kadonotakashi | 0:8fdf9a60065b | 1589 | 3. Create another thread that constantly waits signal from sigio() |
kadonotakashi | 0:8fdf9a60065b | 1590 | handler, when received try `TCPSocket::recv()` |
kadonotakashi | 0:8fdf9a60065b | 1591 | 1. Call `TCPSocket::recv(buffer, 100);` |
kadonotakashi | 0:8fdf9a60065b | 1592 | 2. Verify input according to known pattern. |
kadonotakashi | 0:8fdf9a60065b | 1593 | |
kadonotakashi | 0:8fdf9a60065b | 1594 | 4. Wait until 100kB of data received. |
kadonotakashi | 0:8fdf9a60065b | 1595 | 5. close socket. |
kadonotakashi | 0:8fdf9a60065b | 1596 | |
kadonotakashi | 0:8fdf9a60065b | 1597 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1598 | |
kadonotakashi | 0:8fdf9a60065b | 1599 | Each recv() call should return equal or less than 100 bytes of data or |
kadonotakashi | 0:8fdf9a60065b | 1600 | NSAPI_ERROR_WOULD_BLOCK in which case thread should wait for another |
kadonotakashi | 0:8fdf9a60065b | 1601 | sigio(). No errors should be returned. |
kadonotakashi | 0:8fdf9a60065b | 1602 | |
kadonotakashi | 0:8fdf9a60065b | 1603 | Measure time taken for receiving, report speed |
kadonotakashi | 0:8fdf9a60065b | 1604 | |
kadonotakashi | 0:8fdf9a60065b | 1605 | ### TCPSOCKET_THREAD_PER_SOCKET_SAFETY |
kadonotakashi | 0:8fdf9a60065b | 1606 | |
kadonotakashi | 0:8fdf9a60065b | 1607 | **Description:** |
kadonotakashi | 0:8fdf9a60065b | 1608 | |
kadonotakashi | 0:8fdf9a60065b | 1609 | Run two threads which both exercise the underlying stack and driver |
kadonotakashi | 0:8fdf9a60065b | 1610 | through a dedicated socket |
kadonotakashi | 0:8fdf9a60065b | 1611 | |
kadonotakashi | 0:8fdf9a60065b | 1612 | **Preconditions:** |
kadonotakashi | 0:8fdf9a60065b | 1613 | |
kadonotakashi | 0:8fdf9a60065b | 1614 | 1. Network interface and stack are initialised |
kadonotakashi | 0:8fdf9a60065b | 1615 | 2. Network connection is up |
kadonotakashi | 0:8fdf9a60065b | 1616 | 3. 2 TCPSockets are open and one additional thread has been created |
kadonotakashi | 0:8fdf9a60065b | 1617 | 4. Both threads get their own socket instance |
kadonotakashi | 0:8fdf9a60065b | 1618 | |
kadonotakashi | 0:8fdf9a60065b | 1619 | **Test steps:** |
kadonotakashi | 0:8fdf9a60065b | 1620 | |
kadonotakashi | 0:8fdf9a60065b | 1621 | 1. Call `TCPSocket::connect("echo.mbedcloudtesting.com", 7)` |
kadonotakashi | 0:8fdf9a60065b | 1622 | in both threads - in the main thread executing the test case and on |
kadonotakashi | 0:8fdf9a60065b | 1623 | the additional one; |
kadonotakashi | 0:8fdf9a60065b | 1624 | 2. On main thread |
kadonotakashi | 0:8fdf9a60065b | 1625 | 1. For randomly generated packets, sized 1001, 901, 801,...,101,1 |
kadonotakashi | 0:8fdf9a60065b | 1626 | do |
kadonotakashi | 0:8fdf9a60065b | 1627 | 1. Call `TCPSocket::send(packet, size);` |
kadonotakashi | 0:8fdf9a60065b | 1628 | 2. Verify incoming content was the same that was sent. |
kadonotakashi | 0:8fdf9a60065b | 1629 | Allow recv() to return smaller piezes. |
kadonotakashi | 0:8fdf9a60065b | 1630 | |
kadonotakashi | 0:8fdf9a60065b | 1631 | 3. Simultaneously with the earlier step do on the additional thread |
kadonotakashi | 0:8fdf9a60065b | 1632 | 1. For randomly generated packets, sized 10 do |
kadonotakashi | 0:8fdf9a60065b | 1633 | 1. Call `TCPSocket::send(packet, size);` |
kadonotakashi | 0:8fdf9a60065b | 1634 | 2. Verify incomming content was the same that was sent. |
kadonotakashi | 0:8fdf9a60065b | 1635 | Allow recv() to return smaller piezes. |
kadonotakashi | 0:8fdf9a60065b | 1636 | 3. stop the thread if inconsistensies were found and report it |
kadonotakashi | 0:8fdf9a60065b | 1637 | to main thread |
kadonotakashi | 0:8fdf9a60065b | 1638 | |
kadonotakashi | 0:8fdf9a60065b | 1639 | 4. Kill the additional thread |
kadonotakashi | 0:8fdf9a60065b | 1640 | 5. Close and destroy the sockets |
kadonotakashi | 0:8fdf9a60065b | 1641 | |
kadonotakashi | 0:8fdf9a60065b | 1642 | **Expected result:** |
kadonotakashi | 0:8fdf9a60065b | 1643 | |
kadonotakashi | 0:8fdf9a60065b | 1644 | Echo server returns data to both threads and received data matches to |
kadonotakashi | 0:8fdf9a60065b | 1645 | send data. The additional thread isn't stopped prematurely |
kadonotakashi | 0:8fdf9a60065b | 1646 | |
kadonotakashi | 0:8fdf9a60065b | 1647 | Subset for driver test |
kadonotakashi | 0:8fdf9a60065b | 1648 | ---------------------- |
kadonotakashi | 0:8fdf9a60065b | 1649 | |
kadonotakashi | 0:8fdf9a60065b | 1650 | ### For physical layer driver (emac, PPP): |
kadonotakashi | 0:8fdf9a60065b | 1651 | |
kadonotakashi | 0:8fdf9a60065b | 1652 | - TCPSERVER_ACCEPT |
kadonotakashi | 0:8fdf9a60065b | 1653 | - TCPSERVER_LISTEN |
kadonotakashi | 0:8fdf9a60065b | 1654 | - TCPSOCKET_ECHOTEST |
kadonotakashi | 0:8fdf9a60065b | 1655 | - TCPSOCKET_ECHOTEST_BURST |
kadonotakashi | 0:8fdf9a60065b | 1656 | - TCPSOCKET_ECHOTEST_BURST_NONBLOCK |
kadonotakashi | 0:8fdf9a60065b | 1657 | - TCPSOCKET_ECHOTEST_NONBLOCK |
kadonotakashi | 0:8fdf9a60065b | 1658 | - TCPSOCKET_RECV_100K |
kadonotakashi | 0:8fdf9a60065b | 1659 | - TCPSOCKET_RECV_100K_NONBLOCK |
kadonotakashi | 0:8fdf9a60065b | 1660 | - TCPSOCKET_RECV_TIMEOUT |
kadonotakashi | 0:8fdf9a60065b | 1661 | - TCPSOCKET_SEND_REPEAT |
kadonotakashi | 0:8fdf9a60065b | 1662 | - UDPSOCKET_BIND_SENDTO |
kadonotakashi | 0:8fdf9a60065b | 1663 | - UDPSOCKET_ECHOTEST |
kadonotakashi | 0:8fdf9a60065b | 1664 | - UDPSOCKET_ECHOTEST_NONBLOCK |
kadonotakashi | 0:8fdf9a60065b | 1665 | - UDPSOCKET_RECV_TIMEOUT |
kadonotakashi | 0:8fdf9a60065b | 1666 | - UDPSOCKET_SENDTO_INVALID |
kadonotakashi | 0:8fdf9a60065b | 1667 | - UDPSOCKET_SENDTO_REPEAT |
kadonotakashi | 0:8fdf9a60065b | 1668 | - UDPSOCKET_SENDTO_TIMEOUT |
kadonotakashi | 0:8fdf9a60065b | 1669 | |
kadonotakashi | 0:8fdf9a60065b | 1670 | ### For socket layer driver (AT-driven, external IP stack): |
kadonotakashi | 0:8fdf9a60065b | 1671 | |
kadonotakashi | 0:8fdf9a60065b | 1672 | All Socket, UDPSocket, TCPSocket and TCPServer testcases. |