Skip to content

Commit

Permalink
xtest: regression: add case 1040
Browse files Browse the repository at this point in the history
Adds regression case 1040 to test panic in concurrent open/invoke/close
session.

Signed-off-by: Jens Wiklander <[email protected]>
  • Loading branch information
jenswi-linaro committed Sep 1, 2023
1 parent a286b57 commit f135dd7
Showing 1 changed file with 64 additions and 2 deletions.
66 changes: 64 additions & 2 deletions host/xtest/regression_1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -3270,7 +3270,69 @@ static void xtest_tee_test_1039(ADBG_Case_t *c)
Do_ADBG_EndSubCase(c, "Load TA with identity subkey");

}


ADBG_CASE_DEFINE(regression, 1039, xtest_tee_test_1039,
"Test subkey verification");

struct test_1040_thread_arg {
TEEC_Result res;
pthread_t thr;
};

static void *test_1040_thread(void *arg)
{
TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
struct test_1040_thread_arg *a = arg;
TEEC_Result res = TEEC_SUCCESS;
uint32_t err_orig = 0;
TEEC_Session session = { };
size_t n = 0;

while (n < 100) {
res = xtest_teec_open_session(&session, &sims_test_ta_uuid,
NULL, &err_orig);
if (res) {
if (res == TEEC_ERROR_TARGET_DEAD)
continue;
a->res = res;
return NULL;
}

memset(&op, 0, sizeof(op));
op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
TEEC_NONE, TEEC_NONE,
TEEC_NONE);
res = TEEC_InvokeCommand(&session, TA_SIMS_CMD_PANIC, &op,
&err_orig);
TEEC_CloseSession(&session);
if (res != TEEC_ERROR_TARGET_DEAD) {
a->res = res;
return NULL;
}
n++;
}
return NULL;
}

static void xtest_tee_test_1040(ADBG_Case_t *c)
{
struct test_1040_thread_arg arg[NUM_THREADS] = { };
size_t nt = NUM_THREADS;
size_t n = 0;

Do_ADBG_BeginSubCase(c, "Concurent invoke with panic in TA");
for (n = 0; n < nt; n++) {
if (!ADBG_EXPECT(c, 0, pthread_create(&arg[n].thr, NULL,
test_1040_thread,
arg + n)))
nt = n; /* break loop and start cleanup */
}
for (n = 0; n < nt; n++) {
ADBG_EXPECT(c, 0, pthread_join(arg[n].thr, NULL));
ADBG_EXPECT_TEEC_SUCCESS(c, arg[n].res);
}
Do_ADBG_EndSubCase(c, "Concurent invoke with panic in TA");

}
ADBG_CASE_DEFINE(regression, 1040, xtest_tee_test_1040,
"Test panic in concurrent open/invoke/close session");

0 comments on commit f135dd7

Please sign in to comment.