From 6790a6d36fc4d4170821ea1818630f9e1ecd00a4 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Tue, 7 Nov 2023 17:30:25 +0000 Subject: [PATCH] Add testcase for psa_crypto_input_copy_free() Signed-off-by: David Horstmann --- .../suites/test_suite_psa_crypto_memory.data | 6 ++++++ .../test_suite_psa_crypto_memory.function | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto_memory.data b/tests/suites/test_suite_psa_crypto_memory.data index 85fed8f0e1..6591ba755c 100644 --- a/tests/suites/test_suite_psa_crypto_memory.data +++ b/tests/suites/test_suite_psa_crypto_memory.data @@ -33,3 +33,9 @@ input_copy_alloc:200:PSA_SUCCESS PSA crypto input copy alloc, NULL buffer input_copy_alloc:0:PSA_SUCCESS + +PSA crypto input copy free +input_copy_free:200 + +PSA crypto input copy free, NULL buffer +input_copy_free:0 diff --git a/tests/suites/test_suite_psa_crypto_memory.function b/tests/suites/test_suite_psa_crypto_memory.function index 837ff06e9e..c40ba67f5c 100644 --- a/tests/suites/test_suite_psa_crypto_memory.function +++ b/tests/suites/test_suite_psa_crypto_memory.function @@ -109,3 +109,24 @@ exit: mbedtls_free(input); } /* END_CASE */ + +/* BEGIN_CASE */ +void input_copy_free(int input_len) +{ + psa_crypto_input_copy_t input_copy; + + input_copy.buffer = NULL; + input_copy.len = input_len; + TEST_CALLOC(input_copy.buffer, input_copy.len); + + psa_crypto_input_copy_free(&input_copy); + + TEST_ASSERT(input_copy.buffer == NULL); + TEST_EQUAL(input_copy.len, 0); + +exit: + mbedtls_free(input_copy.buffer); + input_copy.buffer = NULL; + input_copy.len = 0; +} +/* END_CASE */