tests: arm_thread_swap_tz: increase computational length for secure call

In some platforms, such as the nucleo L552ZE_Q, the hash computation
is done very fast, before the delayed work manages to trigger (and
perform the assert-based validations). Increase the length of the
computations so this race condition can be avoided.

Also, this commit adds some messages in the assert statements for
ease of debugging.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
Ioannis Glaropoulos 2021-07-27 15:29:40 +02:00
commit 08510d5b2c

View file

@ -13,7 +13,7 @@
#define EXC_RETURN_S (0x00000040UL)
#endif
#define HASH_LEN 32
#define HASH_LEN 64
static struct k_work_delayable interrupting_work;
static volatile bool work_done;
@ -27,11 +27,11 @@ static void do_hash(char *hash)
size_t len;
/* Calculate correct hash. */
psa_status_t status = psa_hash_compute(PSA_ALG_SHA_256, dummy_string,
psa_status_t status = psa_hash_compute(PSA_ALG_SHA_512, dummy_string,
sizeof(dummy_string), hash, HASH_LEN, &len);
zassert_equal(PSA_SUCCESS, status, NULL);
zassert_equal(HASH_LEN, len, NULL);
zassert_equal(PSA_SUCCESS, status, "psa_hash_compute_fail\n");
zassert_equal(HASH_LEN, len, "hash length not correct\n");
}
static void work_func(struct k_work *work)
@ -70,10 +70,11 @@ static void work_func(struct k_work *work)
/* Call a secure service here as well, to test the added complexity of
* calling secure services from two threads.
*/
psa_status_t status = psa_hash_compare(PSA_ALG_SHA_256, dummy_string,
psa_status_t status = psa_hash_compare(PSA_ALG_SHA_512, dummy_string,
sizeof(dummy_string), dummy_digest_correct, HASH_LEN);
zassert_equal(PSA_SUCCESS, status, NULL);
zassert_equal(PSA_SUCCESS, status, "psa_hash_compare failed\n");
}
void test_thread_swap_tz(void)