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 
24 #if defined(MBEDTLS_SSL_CLI_C) || defined(DOXYGEN_ONLY)
25 
26 NetworkInterface *get_interface();
27 void drop_bad_packets(TLSSocket &sock, int orig_timeout);
28 void fill_tx_buffer_ascii(char *buff, size_t len);
29 nsapi_error_t tlssocket_connect_to_echo_srv(TLSSocket &sock);
30 nsapi_error_t tlssocket_connect_to_discard_srv(TLSSocket &sock);
31 bool is_tcp_supported();
32 
33 #define SKIP_IF_TCP_UNSUPPORTED() \
34  if (!is_tcp_supported()) { \
35  TEST_SKIP_MESSAGE("TCP not supported"); \
36  }
37 
38 #if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
39 extern mbed_stats_socket_t tls_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT];
40 int fetch_stats(void);
41 #endif
42 
43 /**
44  * Single testcase might take only half of the remaining execution time
45  */
46 int split2half_rmng_tls_test_time(); // [s]
47 
48 namespace tls_global {
49 #ifdef MBED_GREENTEA_TEST_TLSSOCKET_TIMEOUT_S
50 static const int TESTS_TIMEOUT = MBED_GREENTEA_TEST_TLSSOCKET_TIMEOUT_S;
51 #else
52 static const int TESTS_TIMEOUT = (10 * 60);
53 #endif
54 static const int TLS_OS_STACK_SIZE = 2048;
55 
56 static const int RX_BUFF_SIZE = 1220;
57 static const int TX_BUFF_SIZE = 1220;
58 
59 extern char rx_buffer[RX_BUFF_SIZE];
60 extern char tx_buffer[TX_BUFF_SIZE];
61 extern const char *cert;
62 }
63 
64 /*
65  * Test cases
66  */
67 void TLSSOCKET_CONNECT_INVALID();
68 void TLSSOCKET_HANDSHAKE_INVALID();
69 void TLSSOCKET_ECHOTEST();
70 void TLSSOCKET_ECHOTEST_NONBLOCK();
71 void TLSSOCKET_ECHOTEST_BURST();
72 void TLSSOCKET_ECHOTEST_BURST_NONBLOCK();
73 void TLSSOCKET_ENDPOINT_CLOSE();
74 void TLSSOCKET_RECV_TIMEOUT();
75 void TLSSOCKET_OPEN_TWICE();
76 void TLSSOCKET_OPEN_LIMIT();
77 void TLSSOCKET_OPEN_DESTRUCT();
78 void TLSSOCKET_SEND_UNCONNECTED();
79 void TLSSOCKET_SEND_CLOSED();
80 void TLSSOCKET_SEND_REPEAT();
81 void TLSSOCKET_NO_CERT();
82 void TLSSOCKET_SIMULTANEOUS();
83 void TLSSOCKET_SEND_TIMEOUT();
84 
85 #endif // defined(MBEDTLS_SSL_CLI_C) || defined(DOXYGEN_ONLY)
86 
87 #endif //TLS_TESTS_H
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:95
TLSSocket is a wrapper around TCPSocket for interacting with TLS servers.
Definition: TLSSocket.h:44
Common interface that is shared between network devices.
TLSSocket.
Structure to parse socket statistics.
Definition: SocketStats.h:45
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.