diff options
author | Piotr Nowicki <piotr.nowicki@arm.com> | 2019-11-26 16:32:40 +0100 |
---|---|---|
committer | Andrzej Kurek <andrzej.kurek@arm.com> | 2020-03-04 06:18:52 -0500 |
commit | 195a8f72992370b85324e0488728faf7216c82b0 (patch) | |
tree | bc2d62798ade02739773ffffc719226a55077148 /programs/ssl/ssl_server2.c | |
parent | 9d86720c338dd3fb7e88ff82f041ff87d97be48d (diff) | |
download | mbedtls-archive/dev/buffer-resizing.zip mbedtls-archive/dev/buffer-resizing.tar.gz mbedtls-archive/dev/buffer-resizing.tar.bz2 |
Add an acceptance test for memory usage after handshakearchive/dev/buffer-resizing
Signed-off-by: Piotr Nowicki <piotr.nowicki@arm.com>
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
Diffstat (limited to 'programs/ssl/ssl_server2.c')
-rw-r--r-- | programs/ssl/ssl_server2.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index d23a700..13031d5 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1838,7 +1838,10 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) ); -#endif +#if defined(MBEDTLS_MEMORY_DEBUG) + size_t current_heap_memory, peak_heap_memory, heap_blocks; +#endif /* MBEDTLS_MEMORY_DEBUG */ +#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */ /* * Make sure memory references are valid in case we exit early. @@ -3742,6 +3745,13 @@ handshake: } #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_memory_buffer_alloc_cur_get( ¤t_heap_memory, &heap_blocks ); + mbedtls_memory_buffer_alloc_max_get( &peak_heap_memory, &heap_blocks ); + mbedtls_printf( "Heap memory usage after handshake: %lu bytes. Peak memory usage was %lu\n", + (unsigned long) current_heap_memory, (unsigned long) peak_heap_memory ); +#endif /* MBEDTLS_MEMORY_DEBUG */ + if( opt.exchanges == 0 ) goto close_notify; |