tf_fuzz: skip tests that run out of memory during key generation
For more complex keys, key generation can fail with
PSA_ERROR_INSUFFICIENT_MEMORY. When this happens, skip the test instead
of failing it.
Change-Id: I66f50edc8ff204849e2f53a112d40c49e94bb2fd
Signed-off-by: Nik Dewally <Nik.Dewally@arm.com>
diff --git a/tf_fuzz/lib/tfm_boilerplate.txt b/tf_fuzz/lib/tfm_boilerplate.txt
index c093730..d7bbb90 100644
--- a/tf_fuzz/lib/tfm_boilerplate.txt
+++ b/tf_fuzz/lib/tfm_boilerplate.txt
@@ -84,8 +84,6 @@
`002
-/* This is not yet right for how to run a test; need to register tests, etc. */
-
void test_thread (struct test_result_t *ret) {
psa_status_t crypto_status; /* result from Crypto calls */
psa_status_t sst_status;
@@ -246,10 +244,17 @@
`050
crypto_status = psa_generate_key (&$policy, &$key);
`051
- if (crypto_status != $expect) {
+ if (crypto_status != $expect && crypto_status != PSA_ERROR_INSUFFICIENT_MEMORY) {
TEST_FAIL("psa_generate_key() expected $expect.");
return;
}
+
+ if (crypto_status == PSA_ERROR_INSUFFICIENT_MEMORY) {
+ TEST_FAIL("psa_generate_key() call ran out of memory. To test this combination, try increasing the MbedTLS static allocator memory.");
+ TEST_LOG("psa_generate_key() call ran out of memory. To test this combination, try increasing the MbedTLS static allocator memory.");
+ ret->val = TEST_SKIPPED;
+ return;
+ }
`052
crypto_status
= psa_import_key (&$policy, $data, $length, &$key);