Add extra testcases for buffer copying

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann 2023-10-31 18:43:09 +00:00
parent 83eef383c7
commit f06ac88284
2 changed files with 24 additions and 4 deletions

View File

@ -7416,6 +7416,12 @@ psa_crypto_copy_input:10:20:PSA_SUCCESS
PSA input buffer copy: copy buffer too small
psa_crypto_copy_input:20:10:PSA_ERROR_BUFFER_TOO_SMALL
PSA input buffer copy: zero-length source buffer
psa_crypto_copy_input:0:10:PSA_SUCCESS
PSA input buffer copy: zero-length both buffers
psa_crypto_copy_input:0:0:PSA_SUCCESS
PSA output buffer copy: straightforward copy
psa_crypto_copy_output:20:20:PSA_SUCCESS
@ -7425,6 +7431,12 @@ psa_crypto_copy_output:10:20:PSA_SUCCESS
PSA output buffer copy: output buffer too small
psa_crypto_copy_output:20:10:PSA_ERROR_BUFFER_TOO_SMALL
PSA output buffer copy: zero-length source buffer
psa_crypto_copy_output:0:10:PSA_SUCCESS
PSA output buffer copy: zero-length both buffers
psa_crypto_copy_output:0:0:PSA_SUCCESS
PSA buffers alloc and copy
psa_crypto_alloc_and_copy:0:20:0:20:PSA_SUCCESS

View File

@ -10314,8 +10314,12 @@ void psa_crypto_copy_input(int src_len, int dst_len, int exp_ret)
uint8_t *dst_buffer = NULL;
psa_status_t ret;
TEST_CALLOC(src_buffer, src_len);
TEST_CALLOC(dst_buffer, dst_len);
/* Special case, when src_len or dst_len is 0, we want to test on a real
* buffer. Calling TEST_CALLOC with 0 will return NULL. */
size_t src_calloc_len = (src_len == 0 ? 1 : src_len);
size_t dst_calloc_len = (dst_len == 0 ? 1 : dst_len);
TEST_CALLOC(src_buffer, src_calloc_len);
TEST_CALLOC(dst_buffer, dst_calloc_len);
for (int i = 0; i < src_len; i++) {
src_buffer[i] = data[i % sizeof(data)];
@ -10343,8 +10347,12 @@ void psa_crypto_copy_output(int src_len, int dst_len, int exp_ret)
uint8_t *dst_buffer = NULL;
psa_status_t ret;
TEST_CALLOC(src_buffer, src_len);
TEST_CALLOC(dst_buffer, dst_len);
/* Special case, when src_len or dst_len is 0, we want to test on a real
* buffer. Calling TEST_CALLOC with 0 will return NULL. */
size_t src_calloc_len = (src_len == 0 ? 1 : src_len);
size_t dst_calloc_len = (dst_len == 0 ? 1 : dst_len);
TEST_CALLOC(src_buffer, src_calloc_len);
TEST_CALLOC(dst_buffer, dst_calloc_len);
for (int i = 0; i < src_len; i++) {
src_buffer[i] = data[i % sizeof(data)];