Mistake on this page?
Report an issue in GitHub or email us
tls_tests.h
1 /*
2  * Copyright (c) 2019, 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 TLS_TESTS_H
19 #define TLS_TESTS_H
20 
21 #include "../test_params.h"
22 #include "TLSSocket.h"
23 #include "mbed_trace.h"
24 
25 #define TRACE_GROUP "GRNT"
26 
27 #if defined(MBEDTLS_SSL_CLI_C) || defined(DOXYGEN_ONLY)
28 
29 NetworkInterface *get_interface();
30 void drop_bad_packets(TLSSocket &sock, int orig_timeout);
31 void fill_tx_buffer_ascii(char *buff, size_t len);
32 nsapi_error_t tlssocket_connect_to_echo_srv(TLSSocket &sock);
33 nsapi_error_t tlssocket_connect_to_discard_srv(TLSSocket &sock);
34 bool is_tcp_supported();
35 
36 #define SKIP_IF_TCP_UNSUPPORTED() \
37  if (!is_tcp_supported()) { \
38  TEST_SKIP_MESSAGE("TCP not supported"); \
39  }
40 
41 #if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
42 extern mbed_stats_socket_t tls_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT];
43 int fetch_stats(void);
44 #endif
45 
46 /**
47  * Single testcase might take only half of the remaining execution time
48  */
49 int split2half_rmng_tls_test_time(); // [s]
50 
51 namespace tls_global {
52 #ifdef MBED_GREENTEA_TEST_TLSSOCKET_TIMEOUT_S
53 static const int TESTS_TIMEOUT = MBED_GREENTEA_TEST_TLSSOCKET_TIMEOUT_S;
54 #else
55 #define MESH 3
56 #define WISUN 0x2345
57 #if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH && MBED_CONF_NSAPI_DEFAULT_MESH_TYPE == WISUN
58 static const int TESTS_TIMEOUT = (25 * 60);
59 #else
60 static const int TESTS_TIMEOUT = (10 * 60);
61 #endif
62 #endif
63 
64 static const int TLS_OS_STACK_SIZE = 2048;
65 
66 static const int RX_BUFF_SIZE = 1220;
67 static const int TX_BUFF_SIZE = 1220;
68 
69 extern char rx_buffer[RX_BUFF_SIZE];
70 extern char tx_buffer[TX_BUFF_SIZE];
71 extern const char *cert;
72 }
73 
74 /*
75  * Test cases
76  */
77 void TLSSOCKET_CONNECT_INVALID();
78 void TLSSOCKET_HANDSHAKE_INVALID();
79 void TLSSOCKET_ECHOTEST();
80 void TLSSOCKET_ECHOTEST_NONBLOCK();
81 void TLSSOCKET_ECHOTEST_BURST();
82 void TLSSOCKET_ECHOTEST_BURST_NONBLOCK();
83 void TLSSOCKET_ENDPOINT_CLOSE();
84 void TLSSOCKET_RECV_TIMEOUT();
85 void TLSSOCKET_OPEN_TWICE();
86 void TLSSOCKET_OPEN_LIMIT();
87 void TLSSOCKET_OPEN_DESTRUCT();
88 void TLSSOCKET_SEND_UNCONNECTED();
89 void TLSSOCKET_SEND_CLOSED();
90 void TLSSOCKET_SEND_REPEAT();
91 void TLSSOCKET_NO_CERT();
92 void TLSSOCKET_SIMULTANEOUS();
93 void TLSSOCKET_SEND_TIMEOUT();
94 
95 #endif // defined(MBEDTLS_SSL_CLI_C) || defined(DOXYGEN_ONLY)
96 
97 #endif //TLS_TESTS_H
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:142
TLSSocket is a wrapper around TCPSocket for interacting with TLS servers.
Definition: TLSSocket.h:47
Common interface that is shared between network devices.
TLSSocket.
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.