Mistake on this page?
Report an issue in GitHub or email us
udp_tests.h
1 /*
2  * Copyright (c) 2018, ARM Limited, All Rights Reserved
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef UDP_TESTS_H
19 #define UDP_TESTS_H
20 
21 #include "../test_params.h"
22 #include "mbed_trace.h"
23 
24 using namespace std::chrono;
25 
26 #define TRACE_GROUP "GRNT"
27 
28 NetworkInterface *get_interface();
29 void drop_bad_packets(UDPSocket &sock, int orig_timeout);
30 nsapi_version_t get_ip_version();
31 bool check_oversized_packets(nsapi_error_t error, int &size);
32 void fill_tx_buffer_ascii(char *buff, size_t len);
33 
34 #if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
35 extern mbed_stats_socket_t udp_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT];
36 int fetch_stats(void);
37 #endif
38 
39 /**
40  * Single testcase might take only half of the remaining execution time
41  */
42 microseconds split2half_rmng_udp_test_time();
43 
44 namespace udp_global {
45 #ifdef MBED_GREENTEA_TEST_UDPSOCKET_TIMEOUT_S
46 static constexpr seconds TESTS_TIMEOUT(MBED_GREENTEA_TEST_UDPSOCKET_TIMEOUT_S);
47 #else
48 #define MESH 3
49 #define WISUN 0x2345
50 #if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH && MBED_CONF_NSAPI_DEFAULT_MESH_TYPE == WISUN
51 static constexpr seconds TESTS_TIMEOUT = 25min;
52 #else
53 static constexpr seconds TESTS_TIMEOUT = 20min;
54 #endif
55 #endif
56 
57 static const int MAX_SEND_SIZE_IPV4 = 536;
58 static const int MAX_SEND_SIZE_IPV6 = 1220;
59 }
60 
61 /*
62  * Test cases
63  */
64 void UDPSOCKET_ECHOTEST();
65 void UDPSOCKET_ECHOTEST_CONNECT_SEND_RECV();
66 void UDPSOCKET_ECHOTEST_NONBLOCK();
67 void UDPSOCKET_ECHOTEST_NONBLOCK_CONNECT_SEND_RECV();
68 void UDPSOCKET_ECHOTEST_BURST();
69 void UDPSOCKET_ECHOTEST_BURST_NONBLOCK();
70 void UDPSOCKET_OPEN_CLOSE_REPEAT();
71 void UDPSOCKET_OPEN_DESTRUCT();
72 void UDPSOCKET_OPEN_LIMIT();
73 void UDPSOCKET_OPEN_TWICE();
74 void UDPSOCKET_BIND_PORT();
75 void UDPSOCKET_BIND_PORT_FAIL();
76 void UDPSOCKET_BIND_ADDRESS_PORT();
77 void UDPSOCKET_BIND_ADDRESS_NULL();
78 void UDPSOCKET_BIND_ADDRESS_INVALID();
79 void UDPSOCKET_BIND_ADDRESS();
80 void UDPSOCKET_BIND_WRONG_TYPE();
81 void UDPSOCKET_BIND_UNOPENED();
82 void UDPSOCKET_RECV_TIMEOUT();
83 void UDPSOCKET_SENDTO_INVALID();
84 void UDPSOCKET_SENDTO_REPEAT();
85 void UDPSOCKET_SENDTO_TIMEOUT();
86 
87 #endif //UDP_TESTS_H
MBED_NORETURN void error(const char *format,...) MBED_PRINTF(1
To generate a fatal compile-time error, you can use the pre-processor error directive.
UDP socket implementation.
Definition: UDPSocket.h:34
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:142
Common interface that is shared between network devices.
Structure to parse socket statistics.
Definition: SocketStats.h:46
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.