You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See [Network Socket Documentation](https://os.mbed.com/docs/mbed-os/latest/apis/network-socket.html) for reference.
23
24
24
25
Tools to use
25
26
----------------
26
27
27
28
- Mbed OS.
28
-
- Standard Mbed OS development tools as described in https://os.mbed.com/docs/latest/tools/index.html.
29
+
- Standard Mbed OS development tools as described in [Arm Mbed tools overview](https://os.mbed.com/docs/latest/tools/index.html).
29
30
- Test server.
30
31
31
32
These test cases themselves do not require any special tooling, other than
@@ -227,6 +228,20 @@ pass the test if the driver implements the feature in question.
227
228
| 60 | TLSSOCKET_SIMULTANEOUS_TEST | SHOULD |
228
229
| 61 | TLSSOCKET_ECHOTEST_BURST | SHOULD |
229
230
| 62 | TLSSOCKET_ECHOTEST_BURST_NONBLOCK | SHOULD |
231
+
| 63 | ASYNCHRONOUS_DNS | MUST |
232
+
| 64 | ASYNCHRONOUS_DNS_CACHE | MUST |
233
+
| 65 | ASYNCHRONOUS_DNS_CANCEL | MUST |
234
+
| 66 | ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE | MUST |
235
+
| 67 | ASYNCHRONOUS_DNS_INVALID_HOST | MUST |
236
+
| 68 | ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC | MUST |
237
+
| 69 | ASYNCHRONOUS_DNS_SIMULTANEOUS_CACHE | MUST |
238
+
| 70 | ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT | MUST |
239
+
| 71 | ASYNCHRONOUS_DNS_SIMULTANEOUS | MUST |
240
+
| 72 | ASYNCHRONOUS_DNS_TIMEOUTS | MUST |
241
+
| 73 | SYNCHRONOUS_DNS | MUST |
242
+
| 74 | SYNCHRONOUS_DNS_CACHE | MUST |
243
+
| 75 | SYNCHRONOUS_DNS_INVALID_HOST | MUST |
244
+
| 76 | SYNCHRONOUS_DNS_MULTIPLE | MUST |
230
245
231
246
232
247
@@ -1654,6 +1669,311 @@ through a dedicated socket
1654
1669
Echo server returns data to both threads and received data matches to
1655
1670
send data. The additional thread isn't stopped prematurely.
1656
1671
1672
+
Test cases for DNS class
1673
+
---------------------------
1674
+
1675
+
### ASYNCHRONOUS_DNS
1676
+
1677
+
**Description:**
1678
+
1679
+
Verify basic functionality of asynchronous DNS. Call `NetworkInterface::gethostbyname_async()` with a valid host name and verify result.
1680
+
1681
+
**Preconditions:**
1682
+
1683
+
1. Network interface is initialised.
1684
+
2. Network connection is up.
1685
+
1686
+
**Test steps:**
1687
+
1688
+
1. Call `gethostbyname_async()` with a valid host name and a callback.
1689
+
2. Verify that callback is called with correct parameters.
1690
+
1691
+
**Expected result:**
1692
+
1693
+
Callback is called with NSAPI_ERROR_OK and IP address.
1694
+
1695
+
### ASYNCHRONOUS_DNS_SIMULTANEOUS
1696
+
1697
+
**Description:**
1698
+
1699
+
Verify that simultaneous asynchronous DNS queries work correctly. Call `NetworkInterface::gethostbyname_async()` in a row 6 times with a different host names. Wait for all requests to complete and verify result. Cache shall not contain host names used in asynchronous request.
1700
+
1701
+
**Preconditions:**
1702
+
1703
+
1. Network interface is initialised.
1704
+
2. Network connection is up.
1705
+
1706
+
**Test steps:**
1707
+
1708
+
1. Call `gethostbyname_async()` in a row 6 times with a different host names. Host names shall not be found from cache.
1709
+
2. Verify that last `gethostbyname_async()` operation is rejected since there is room only for 5 simultaneous operations.
1710
+
3. Verify that callback is called with correct parameters 5 times.
1711
+
1712
+
**Expected result:**
1713
+
1714
+
Sixth `gethostbyname_async()` is rejected. Callback is called with NSAPI_ERROR_OK and IP address 5 times.
1715
+
1716
+
### ASYNCHRONOUS_DNS_SIMULTANEOUS_CACHE
1717
+
1718
+
**Description:**
1719
+
1720
+
Verify that the caching of DNS results works correctly with simultaneous asynchronous DNS queries. Call `NetworkInterface::gethostbyname_async()` in a row 6 times with a different host names. Wait for all requests to complete and verify result. Cache shall contain at least one host name used in asynchronous request. This can be achieved e.g. by running test "Asynchronous DNS simultaneous" before this test and using same host names in this run.
1721
+
1722
+
**Preconditions:**
1723
+
1724
+
1. Network interface is initialised.
1725
+
2. Network connection is up.
1726
+
1727
+
**Test steps:**
1728
+
1729
+
1. Call `gethostbyname_async()` in a row 6 times with a different host names. At least one host name shall be found from cache.
1730
+
2. Verify that callback is called with correct parameters 6 times.
1731
+
1732
+
**Expected result:**
1733
+
1734
+
Callback is called with NSAPI_ERROR_OK and IP address 6 times.
1735
+
1736
+
### ASYNCHRONOUS_DNS_CACHE
1737
+
1738
+
**Description:**
1739
+
1740
+
Verify that the caching of DNS results works correctly. Call `NetworkInterface::gethostbyname_async()` 5 times with the same host name and verify result after each request. For first request, cache shall not contain the host name. Verify that first request completes slower than the requests made after it (where the response is found from cache).
1741
+
1742
+
**Preconditions:**
1743
+
1744
+
1. Network interface is initialised.
1745
+
2. Network connection is up.
1746
+
1747
+
**Test steps:**
1748
+
1749
+
1. Call `gethostbyname_async()` with a host name. For first request, host name shall not be found from cache.
1750
+
2. Verify that callback is called with correct parameters.
1751
+
3. Repeat the sequence 4 times using the same host name.
1752
+
4. For each request, calculate how long time it takes for DNS query to complete.
1753
+
1754
+
**Expected result:**
1755
+
1756
+
Callback is called with NSAPI_ERROR_OK and IP address 5 times. First request shall complete slower than the requests made after it (where the response is found from cache).
1757
+
1758
+
### ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC
1759
+
1760
+
**Description:**
1761
+
1762
+
Verify that non-asynchronous i.e. blocking DNS queries and asynchronous i.e. non-blocking queries work at the same time. Call `NetworkInterface::gethostbyname_async()`. Right after that make 6 non-asynchronous `NetworkInterface::gethostbyname()` calls with different host names.
1763
+
1764
+
**Preconditions:**
1765
+
1766
+
1. Network interface is initialised.
1767
+
2. Network connection is up.
1768
+
1769
+
**Test steps:**
1770
+
1771
+
1. Call `gethostbyname_async()` with a host name. Host name shall not be found from cache.
1772
+
2. Call `gethostbyname()` 6 times with a different host names (none of the names shall be same as in step 1).
1773
+
3. Verify that each `gethostbyname()` returns success.
1774
+
4. Verify that the asynchronous callback is called with correct parameters.
1775
+
1776
+
**Expected result:**
1777
+
1778
+
All operations shall return NSAPI_ERROR_OK and IP address.
1779
+
1780
+
### ASYNCHRONOUS_DNS_CANCEL
1781
+
1782
+
**Description:**
1783
+
1784
+
Verify that asynchronous DNS query cancel works correctly. Call `NetworkInterface::gethostbyname_async()` in a row 6 times with a different host names. Cache shall contain 3 host names used in requests. This can be achieved e.g. by running test "Asynchronous DNS non-asynchronous and asynchronous" before this test and using same host names in this run. For each request that was given an unique id, call cancel. Verify that callback is not called for cancelled requests.
1785
+
1786
+
**Preconditions:**
1787
+
1788
+
1. Network interface is initialised.
1789
+
2. Network connection is up.
1790
+
1791
+
**Test steps:**
1792
+
1793
+
1. Call `gethostbyname_async()` in a row 6 times with a different host names. Cache shall contain in maximum 3 host names used in requests.
1794
+
2. Call `gethostbyname_async_cancel()` for each request that was given an unique id.
1795
+
3. Verify that for cancelled requests, callback is not called.
1796
+
4. Verify that for other request, callback is called.
1797
+
1798
+
**Expected result:**
1799
+
1800
+
Callback shall be called only for requests that were not cancelled.
1801
+
1802
+
### ASYNCHRONOUS_DNS_EXTERNAL_EVENT_QUEUE
1803
+
1804
+
**Description:**
1805
+
1806
+
Verify that providing an external event queue works correctly. Define a thread and an event queue running on it. Define a DNS call in callback function that uses the event queue (call_in_callback_cb_t). Enable external event queue. Call `NetworkInterface::gethostbyname_async()` in a row 6 times with a different host names.
1807
+
1808
+
**Preconditions:**
1809
+
1810
+
1. Network interface is initialised.
1811
+
2. Network connection is up.
1812
+
1813
+
**Test steps:**
1814
+
1815
+
1. Define a thread and an event queue running on it.
1816
+
2. Define a DNS call in callback function that uses the event queue (call_in_callback_cb_t).
1817
+
3. Start thread and event queue.
1818
+
4. Set DNS callback function using the `nsapi_dns_call_in_set()` call.
1819
+
5. Call `gethostbyname_async()` in a row 6 times with a different host names. Host names shall not be found from cache.
1820
+
6. Verify that last `gethostbyname_async()` operation is rejected since there is room only for 5 simultaneous operations.
1821
+
7. Verify that callback is called with correct parameters 5 times.
1822
+
8. Restore default DNS callback function using the `nsapi_dns_call_in_set()` call.
1823
+
1824
+
**Expected result:**
1825
+
1826
+
Sixth `gethostbyname_async()` is rejected. Callback is called with NSAPI_ERROR_OK and IP address 5 times.
1827
+
1828
+
### ASYNCHRONOUS_DNS_INVALID_HOST
1829
+
1830
+
**Description:**
1831
+
1832
+
Verify that DNS failure error is provided for invalid hosts. Call `NetworkInterface::gethostbyname_async()` in a row 6 times with a different host names. First, third and fifth host name shall be invalid.
1833
+
1834
+
**Preconditions:**
1835
+
1836
+
1. Network interface is initialised.
1837
+
2. Network connection is up.
1838
+
1839
+
**Test steps:**
1840
+
1841
+
1. Call `gethostbyname_async()` in a row 6 times with a different host names. Host names shall not be found from cache. First, third and fifth host name shall be invalid.
1842
+
2. Verify that last `gethostbyname_async()` operation is rejected since there is room only for 5 simultaneous operations.
1843
+
3. Verify that callback is called with correct parameters 5 times.
1844
+
1845
+
**Expected result:**
1846
+
1847
+
Sixth `gethostbyname_async()` is rejected. Callback is called with NSAPI_ERROR_DNS_FAILURE for first, third and fifth host name. Callback is called with NSAPI_ERROR_OK and IP address for second and fourth host name.
1848
+
1849
+
### ASYNCHRONOUS_DNS_TIMEOUTS
1850
+
1851
+
**Description:**
1852
+
1853
+
Test DNS timeouts using an external event queue that is modified to timeout the events faster that standard event queue. In this test event queue shall not delay events, instead it handles those immediately. Call `NetworkInterface::gethostbyname_async()` in a row 6 times with a different host names. All or some of the request shall timeout and timeout return value is returned.
1854
+
1855
+
**Preconditions:**
1856
+
1857
+
1. Network interface is initialised.
1858
+
2. Network connection is up.
1859
+
1860
+
**Test steps:**
1861
+
1862
+
1. Define a thread and an event queue running on it.
1863
+
2. Define a DNS call in callback function that uses the event queue (call_in_callback_cb_t). Callback function shall not delay callbacks; instead it shall handle those immediately.
1864
+
3. Start thread and event queue.
1865
+
4. Set DNS callback function using the `nsapi_dns_call_in_set()` call.
1866
+
5. Call `gethostbyname_async()` in a row 6 times with a different host names. Host names shall not be found from cache.
1867
+
6. Verify that last `gethostbyname_async()` operation is rejected since there is room only for 5 simultaneous operations.
1868
+
7. Verify that callback is called with correct parameters 5 times.
1869
+
1870
+
**Expected result:**
1871
+
1872
+
Sixth `gethostbyname_async()` is rejected. At least for one operation, callback is called with NSAPI_ERROR_TIMEOUT value.
1873
+
1874
+
### ASYNCHRONOUS_DNS_SIMULTANEOUS_REPEAT
1875
+
1876
+
**Description:**
1877
+
1878
+
Verify that simultaneous asynchronous DNS queries work correctly when repeated in sequence. Call `NetworkInterface::gethostbyname_async()` in a row 5 times with a different host names. Wait for all requests to complete and verify result. Repeat the procedure 100 times.
1879
+
1880
+
**Preconditions:**
1881
+
1882
+
1. Network interface is initialised.
1883
+
2. Network connection is up.
1884
+
1885
+
**Test steps:**
1886
+
1887
+
1. Call `gethostbyname_async()` in a row 5 times with a different host names.
1888
+
2. Verify that callback is called with correct parameters 5 times for first operation.
1889
+
3. Repeat 100 times steps 1 to 2.
1890
+
1891
+
**Expected result:**
1892
+
1893
+
Callback is called with NSAPI_ERROR_OK and IP address 5 times for every repeat.
1894
+
1895
+
### SYNCHRONOUS_DNS
1896
+
1897
+
**Description:**
1898
+
1899
+
Verify basic functionality of synchronous DNS. Call `NetworkInterface::gethostbyname()` with a valid host name and verify result.
1900
+
1901
+
**Preconditions:**
1902
+
1903
+
1. Network interface is initialised.
1904
+
2. Network connection is up.
1905
+
1906
+
**Test steps:**
1907
+
1908
+
1. Call `gethostbyname()` with a valid host name.
1909
+
2. Verify that address was resolved and return value was valid.
1910
+
1911
+
**Expected result:**
1912
+
1913
+
Return value is NSAPI_ERROR_OK and IP address is obtained from the function call.
1914
+
1915
+
### SYNCHRONOUS_DNS_MULTIPLE
1916
+
1917
+
**Description:**
1918
+
1919
+
Verify basic functionality of synchronous DNS. Call `NetworkInterface::gethostbyname()` with a list of 6 host names and verify result.
1920
+
1921
+
**Preconditions:**
1922
+
1923
+
1. Network interface is initialised.
1924
+
2. Network connection is up.
1925
+
1926
+
**Test steps:**
1927
+
1928
+
1. Call `gethostbyname()` with a list of 6 host names
1929
+
2. Verify that each of the addresses was resolved and return value was valid.
1930
+
1931
+
**Expected result:**
1932
+
1933
+
Return value is NSAPI_ERROR_OK and IP addresses are obtained from the function call.
1934
+
1935
+
### SYNCHRONOUS_DNS_CACHE
1936
+
1937
+
**Description:**
1938
+
1939
+
Verify that the caching of DNS results works correctly. Call `NetworkInterface::gethostbyname()` 5 times with the same host name and verify result after each request. For first request, cache shall not contain the host name. Verify that first request completes slower than the requests made after it (where the response is found from cache).
1940
+
1941
+
**Preconditions:**
1942
+
1943
+
1. Network interface is initialised.
1944
+
2. Network connection is up.
1945
+
1946
+
**Test steps:**
1947
+
1948
+
1. Call `gethostbyname()` with a host name. For the first request, host name shall not be found from cache.
1949
+
2. Verify that address was resolved and return value was valid.
1950
+
3. Repeat the sequence 4 times using the same host name.
1951
+
4. For each request, calculate how long time it takes for DNS query to complete.
1952
+
1953
+
**Expected result:**
1954
+
1955
+
Return value is NSAPI_ERROR_OK and IP address is obtained from the function call 5 times. First request shall complete slower than the requests made after it (where the response is found from cache).
1956
+
1957
+
### SYNCHRONOUS_DNS_INVALID_HOST
1958
+
1959
+
**Description:**
1960
+
1961
+
Verify that DNS failure error is provided for invalid hosts. Call `NetworkInterface::gethostbyname()` in a row 6 times with a different host names. First, third and fifth host name shall be invalid.
1962
+
1963
+
**Preconditions:**
1964
+
1965
+
1. Network interface is initialised.
1966
+
2. Network connection is up.
1967
+
1968
+
**Test steps:**
1969
+
1970
+
1. Call `gethostbyname()` in a row 6 times with a different host names. Host names shall not be found from cache. First, third and fifth host name shall be invalid.
1971
+
2. Verify that return value was valid and for valid hostnames the address was resolved 6 times.
1972
+
1973
+
**Expected result:**
1974
+
1975
+
Return value is NSAPI_ERROR_DNS_FAILURE for first, third and fifth host name. Return value is NSAPI_ERROR_OK and IP address is obtained for second and fourth host name.
1976
+
1657
1977
Subset for driver test
1658
1978
----------------------
1659
1979
@@ -1677,4 +1997,4 @@ Subset for driver test
1677
1997
1678
1998
### For socket layer driver (AT-driven, external IP stack):
1679
1999
1680
-
All Socket, UDPSocket, TCPSocket and TLSSocket testcases.
2000
+
All Socket, UDPSocket, TCPSocket and TLSSocket testcases.
0 commit comments