Skip to content

Commit f75732b

Browse files
michalpasztamobicaArto Kinnunen
authored andcommitted
(split) Add unit tests for TLSSocket and TLSSocketWrapper
This also includes their Datagram counterparts: DTLSSocket and DTLSSocketWrapper. Coverage missing for timer-related functionality, but this would require more advanced stub development. The extra (d)tls_test_config.h is necessary for successful compilation without HW support for the mbedtls features in unittests. I reused the mbedtls stub found in features/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c and amended it slightly with a few missing functions.
1 parent c45afcd commit f75732b

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

test/coap-service/unittest/stub/mbedtls_stub.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ void mbedtls_ssl_conf_max_version(mbedtls_ssl_config *conf, int major, int minor
5959

6060
}
6161

62-
void mbedtls_ssl_config_init(mbedtls_ssl_config *a)
62+
void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport )
63+
{
64+
65+
}
66+
67+
void mbedtls_ssl_config_init( mbedtls_ssl_config *a )
6368
{
6469

6570
}
@@ -198,6 +203,16 @@ int mbedtls_ssl_write(mbedtls_ssl_context *a, const unsigned char *b, size_t c)
198203
return mbedtls_stub.expected_int;
199204
}
200205

206+
int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname )
207+
{
208+
return 0;
209+
}
210+
211+
const mbedtls_x509_crt *mbedtls_ssl_get_peer_cert( const mbedtls_ssl_context *ssl )
212+
{
213+
return NULL;
214+
}
215+
201216

202217

203218
//From crt_drbg.h
@@ -252,6 +267,18 @@ int mbedtls_x509_crt_parse(mbedtls_x509_crt *a, const unsigned char *b, size_t c
252267
return mbedtls_stub.expected_int;
253268
}
254269

270+
int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix,
271+
const mbedtls_x509_crt *crt )
272+
{
273+
return 0;
274+
}
275+
276+
int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix,
277+
uint32_t flags )
278+
{
279+
return 0;
280+
}
281+
255282
//From entropy.h
256283
void mbedtls_entropy_init(mbedtls_entropy_context *a)
257284
{
@@ -356,3 +383,6 @@ int mbedtls_ssl_session_reset(mbedtls_ssl_context *ssl)
356383
}
357384
return mbedtls_stub.expected_int;
358385
}
386+
387+
void mbedtls_strerror( int ret, char *buf, size_t buflen ){
388+
}

0 commit comments

Comments
 (0)