From 765bb31d242eaa7106010461503b72170c5fc784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 27 Nov 2014 11:55:27 +0100 Subject: [PATCH] Add test_suite_memory_buffer_alloc --- tests/CMakeLists.txt | 1 + tests/Makefile | 5 +++++ tests/suites/main_test.function | 6 ++++-- tests/suites/test_suite_memory_buffer_alloc.data | 2 ++ .../test_suite_memory_buffer_alloc.function | 16 ++++++++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/suites/test_suite_memory_buffer_alloc.data create mode 100644 tests/suites/test_suite_memory_buffer_alloc.function diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2e4d9d4a9b..ab6c59f1d1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -77,6 +77,7 @@ add_test_suite(hmac_drbg hmac_drbg.pr) add_test_suite(hmac_shax) add_test_suite(md) add_test_suite(mdx) +add_test_suite(memory_buffer_alloc) add_test_suite(mpi) add_test_suite(pbkdf2) add_test_suite(pem) diff --git a/tests/Makefile b/tests/Makefile index c37b790fa2..37e1aacc3e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -59,6 +59,7 @@ APPS = test_suite_aes.ecb test_suite_aes.cbc \ test_suite_hmac_drbg.nopr \ test_suite_hmac_drbg.pr \ test_suite_md test_suite_mdx \ + test_suite_memory_buffer_alloc \ test_suite_mpi test_suite_pbkdf2 \ test_suite_pem \ test_suite_pkcs1_v21 test_suite_pkcs5 \ @@ -336,6 +337,10 @@ test_suite_mdx: test_suite_mdx.c $(DEP) echo " CC $@.c" $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ +test_suite_memory_buffer_alloc: test_suite_memory_buffer_alloc.c $(DEP) + echo " CC $@.c" + $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ + test_suite_mpi: test_suite_mpi.c $(DEP) echo " CC $@.c" $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function index 318ca9aedd..fae56f4252 100644 --- a/tests/suites/main_test.function +++ b/tests/suites/main_test.function @@ -211,7 +211,8 @@ int main() char buf[5000]; char *params[50]; -#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) +#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && \ + !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) unsigned char alloc_buf[1000000]; memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) ); #endif @@ -298,7 +299,8 @@ int main() fprintf( stdout, " (%d / %d tests (%d skipped))\n", total_tests - total_errors, total_tests, total_skipped ); -#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) +#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && \ + !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) #if defined(POLARSSL_MEMORY_DEBUG) memory_buffer_alloc_status(); #endif diff --git a/tests/suites/test_suite_memory_buffer_alloc.data b/tests/suites/test_suite_memory_buffer_alloc.data new file mode 100644 index 0000000000..2542d4d869 --- /dev/null +++ b/tests/suites/test_suite_memory_buffer_alloc.data @@ -0,0 +1,2 @@ +Memory buffer alloc self test +memory_buffer_alloc_self_test: diff --git a/tests/suites/test_suite_memory_buffer_alloc.function b/tests/suites/test_suite_memory_buffer_alloc.function new file mode 100644 index 0000000000..88c36abc55 --- /dev/null +++ b/tests/suites/test_suite_memory_buffer_alloc.function @@ -0,0 +1,16 @@ +/* BEGIN_HEADER */ +#include +#define TEST_SUITE_MEMORY_BUFFER_ALLOC +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:POLARSSL_MEMORY_BUFFER_ALLOC_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE depends_on:POLARSSL_SELF_TEST */ +void memory_buffer_alloc_self_test( ) +{ + TEST_ASSERT( memory_buffer_alloc_self_test( 0 ) == 0 ); +} +/* END_CASE */