aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Cosgrove <tom.cosgrove@arm.com>2024-06-18 13:22:21 +0100
committerTom Cosgrove <tom.cosgrove@arm.com>2024-06-18 13:22:21 +0100
commita60d9223d602ef4fc29ef2917691c8abfa695b77 (patch)
tree3752928c7b989e48d89f7643dadbb8c1a932d79e
parent37610024e9b46f6da86bd0665e72b6fd9bf4000f (diff)
downloadmbedtls-a60d9223d602ef4fc29ef2917691c8abfa695b77.zip
mbedtls-a60d9223d602ef4fc29ef2917691c8abfa695b77.tar.gz
mbedtls-a60d9223d602ef4fc29ef2917691c8abfa695b77.tar.bz2
Update psa_sim_serialise.pl to create the psa_sim_serialise.c we want
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
-rw-r--r--tests/psa-client-server/psasim/src/psa_sim_serialise.c15
-rwxr-xr-xtests/psa-client-server/psasim/src/psa_sim_serialise.pl12
2 files changed, 15 insertions, 12 deletions
diff --git a/tests/psa-client-server/psasim/src/psa_sim_serialise.c b/tests/psa-client-server/psasim/src/psa_sim_serialise.c
index 703e430..aaf47db 100644
--- a/tests/psa-client-server/psasim/src/psa_sim_serialise.c
+++ b/tests/psa-client-server/psasim/src/psa_sim_serialise.c
@@ -110,8 +110,7 @@ static ssize_t allocate_aead_operation_slot(void)
{
psasim_client_handle_t handle = next_aead_operation_handle++;
if (next_aead_operation_handle == 0) { /* wrapped around */
- fprintf(stderr, "MAX HASH HANDLES REACHED\n");
- exit(1);
+ FATAL("Aead operation handle wrapped");
}
for (ssize_t i = 0; i < MAX_LIVE_HANDLES_PER_CLASS; i++) {
@@ -121,6 +120,8 @@ static ssize_t allocate_aead_operation_slot(void)
}
}
+ ERROR("All slots are currently used. Unable to allocate a new one.");
+
return -1; /* all in use */
}
@@ -133,7 +134,9 @@ static ssize_t find_aead_slot_by_handle(psasim_client_handle_t handle)
}
}
- return -1; /* all in use */
+ ERROR("Unable to find slot by handle %u", handle);
+
+ return -1; /* not found */
}
size_t psasim_serialise_begin_needs(void)
@@ -710,9 +713,3 @@ int psasim_deserialise_mbedtls_svc_key_id_t(uint8_t **pos,
return 1;
}
-
-void psa_sim_serialize_reset(void)
-{
- memset(hash_operation_handles, 0, sizeof(hash_operation_handles));
- memset(hash_operations, 0, sizeof(hash_operations));
-}
diff --git a/tests/psa-client-server/psasim/src/psa_sim_serialise.pl b/tests/psa-client-server/psasim/src/psa_sim_serialise.pl
index e09bb81..c795fd4 100755
--- a/tests/psa-client-server/psasim/src/psa_sim_serialise.pl
+++ b/tests/psa-client-server/psasim/src/psa_sim_serialise.pl
@@ -724,6 +724,7 @@ sub c_header
*/
#include "psa_sim_serialise.h"
+#include "util.h"
#include <stdlib.h>
#include <string.h>
@@ -788,6 +789,8 @@ sub define_operation_type_data_and_functions
{
my ($type) = @_; # e.g. 'hash' rather than 'psa_hash_operation_t'
+ my $utype = ucfirst($type);
+
return <<EOF;
static psa_${type}_operation_t ${type}_operations[MAX_LIVE_HANDLES_PER_CLASS];
@@ -799,8 +802,7 @@ static ssize_t allocate_${type}_operation_slot(void)
{
psasim_client_handle_t handle = next_${type}_operation_handle++;
if (next_${type}_operation_handle == 0) { /* wrapped around */
- fprintf(stderr, "MAX HASH HANDLES REACHED\\n");
- exit(1);
+ FATAL("$utype operation handle wrapped");
}
for (ssize_t i = 0; i < MAX_LIVE_HANDLES_PER_CLASS; i++) {
@@ -810,6 +812,8 @@ static ssize_t allocate_${type}_operation_slot(void)
}
}
+ ERROR("All slots are currently used. Unable to allocate a new one.");
+
return -1; /* all in use */
}
@@ -822,7 +826,9 @@ static ssize_t find_${type}_slot_by_handle(psasim_client_handle_t handle)
}
}
- return -1; /* all in use */
+ ERROR("Unable to find slot by handle %u", handle);
+
+ return -1; /* not found */
}
EOF
}