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 static const int TESTS_TIMEOUT = (10 * 60);
56 #endif
57 static const int TLS_OS_STACK_SIZE = 2048;
58 
59 static const int RX_BUFF_SIZE = 1220;
60 static const int TX_BUFF_SIZE = 1220;
61 
62 extern char rx_buffer[RX_BUFF_SIZE];
63 extern char tx_buffer[TX_BUFF_SIZE];
64 extern const char *cert;
65 }
66 
67 /*
68  * Test cases
69  */
70 void TLSSOCKET_CONNECT_INVALID();
71 void TLSSOCKET_HANDSHAKE_INVALID();
72 void TLSSOCKET_ECHOTEST();
73 void TLSSOCKET_ECHOTEST_NONBLOCK();
74 void TLSSOCKET_ECHOTEST_BURST();
75 void TLSSOCKET_ECHOTEST_BURST_NONBLOCK();
76 void TLSSOCKET_ENDPOINT_CLOSE();
77 void TLSSOCKET_RECV_TIMEOUT();
78 void TLSSOCKET_OPEN_TWICE();
79 void TLSSOCKET_OPEN_LIMIT();
80 void TLSSOCKET_OPEN_DESTRUCT();
81 void TLSSOCKET_SEND_UNCONNECTED();
82 void TLSSOCKET_SEND_CLOSED();
83 void TLSSOCKET_SEND_REPEAT();
84 void TLSSOCKET_NO_CERT();
85 void TLSSOCKET_SIMULTANEOUS();
86 void TLSSOCKET_SEND_TIMEOUT();
87 
88 #endif // defined(MBEDTLS_SSL_CLI_C) || defined(DOXYGEN_ONLY)
89 
90 #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:47
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.