Skip to content

Commit

Permalink
[review] core: pta: test: invoke pta command to test interrupt notif
Browse files Browse the repository at this point in the history
Adds mutex around itr_notif tests to prevent deadlock and errors
if invoked tiwce at the same time. This prevent messing in interrupt
notifier registration during the tests.

Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms committed Mar 15, 2023
1 parent de45d78 commit 24a0661
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/pta/tests/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ static struct notif_itr test_itr_notif[TEST_ITR_NOTIF_CNT];
/* Helper to release only registered resources in case of error */
static bool test_itr_notif_registered[TEST_ITR_NOTIF_CNT];

struct mutex itr_notif_test_lock = MUTEX_INITIALIZER;

static TEE_Result register_test_itr_notif(unsigned int test_itr_index,
const struct notif_itr_ops *ops)
{
Expand Down Expand Up @@ -119,6 +121,8 @@ static TEE_Result test1_itr_notif_do(void)

static_assert(TEST_ITR_NOTIF_CNT >= 8);

mutex_lock(&itr_notif_test_lock);

res = register_test1_itr_notif();
if (res)
goto out;
Expand Down Expand Up @@ -236,6 +240,8 @@ static TEE_Result test1_itr_notif_do(void)

out:
unregister_test_all_notif();
mutex_unlock(&itr_notif_test_lock);


if (res)
EMSG("Itr-notif test1: failed with %#"PRIx32, res);
Expand Down Expand Up @@ -279,6 +285,8 @@ static TEE_Result test2_itr_notif_do(void)

static_assert(TEST_ITR_NOTIF_CNT >= 4);

mutex_lock(&itr_notif_test_lock);

for (n = 0; n <= 3; n++) {
res = register_test_itr_notif(n, &test2_notif_ops);
if (res)
Expand Down Expand Up @@ -322,6 +330,7 @@ static TEE_Result test2_itr_notif_do(void)

out:
unregister_test_all_notif();
mutex_unlock(&itr_notif_test_lock);

if (res)
EMSG("Itr-notif test2: failed with %#"PRIx32, res);
Expand Down

0 comments on commit 24a0661

Please sign in to comment.