From 2c25eb0b0a9ed089c60b3e16728805b32b60fd2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 30 May 2014 10:38:18 +0200 Subject: [PATCH] Add test_suite_entropy --- tests/.gitignore | 1 + tests/CMakeLists.txt | 1 + tests/Makefile | 6 ++++- tests/suites/test_suite_entropy.data | 8 +++++++ tests/suites/test_suite_entropy.function | 29 ++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/suites/test_suite_entropy.data create mode 100644 tests/suites/test_suite_entropy.function diff --git a/tests/.gitignore b/tests/.gitignore index a83ad32ac..6590f0fca 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -3,3 +3,4 @@ data_files/mpi_write data_files/hmac_drbg_seed data_files/ctr_drbg_seed +data_files/entropy_seed diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bc40eb173..44904fa3b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -61,6 +61,7 @@ add_test_suite(dhm) add_test_suite(ecp) add_test_suite(ecdh) add_test_suite(ecdsa) +add_test_suite(entropy) add_test_suite(error) add_test_suite(gcm gcm.aes128_en) add_test_suite(gcm gcm.aes192_en) diff --git a/tests/Makefile b/tests/Makefile index dd9f205b4..c37b790fa 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -46,7 +46,7 @@ APPS = test_suite_aes.ecb test_suite_aes.cbc \ test_suite_des test_suite_dhm \ test_suite_ecdh test_suite_ecdsa \ test_suite_ecp \ - test_suite_error \ + test_suite_error test_suite_entropy \ test_suite_gcm.aes128_de \ test_suite_gcm.aes192_de \ test_suite_gcm.aes256_de \ @@ -272,6 +272,10 @@ test_suite_ecp: test_suite_ecp.c $(DEP) echo " CC $@.c" $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ +test_suite_entropy: test_suite_entropy.c $(DEP) + echo " CC $@.c" + $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ + test_suite_error: test_suite_error.c $(DEP) echo " CC $@.c" $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ diff --git a/tests/suites/test_suite_entropy.data b/tests/suites/test_suite_entropy.data new file mode 100644 index 000000000..5a43ffdc9 --- /dev/null +++ b/tests/suites/test_suite_entropy.data @@ -0,0 +1,8 @@ +Entropy write/update seed file +entropy_seed_file:"data_files/entropy_seed":0 + +Entropy write/update seed file +entropy_seed_file:"no_such_dir/file":POLARSSL_ERR_ENTROPY_FILE_IO_ERROR + +Entropy self test +entropy_selftest: diff --git a/tests/suites/test_suite_entropy.function b/tests/suites/test_suite_entropy.function new file mode 100644 index 000000000..31286ba19 --- /dev/null +++ b/tests/suites/test_suite_entropy.function @@ -0,0 +1,29 @@ +/* BEGIN_HEADER */ +#include +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:POLARSSL_ENTROPY_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE depends_on:POLARSSL_FS_IO */ +void entropy_seed_file( char *path, int ret ) +{ + entropy_context ctx; + + entropy_init( &ctx ); + + TEST_ASSERT( entropy_write_seed_file( &ctx, path ) == ret ); + TEST_ASSERT( entropy_update_seed_file( &ctx, path ) == ret ); + + entropy_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:POLARSSL_SELF_TEST */ +void entropy_selftest( ) +{ + TEST_ASSERT( entropy_self_test( 0 ) == 0 ); +} +/* END_CASE */