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 <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
jenswi-linaro committed Sep 27, 2023
1 parent 1013c49 commit b8f5f92
Showing 1 changed file with 70 additions and 2 deletions.
72 changes: 70 additions & 2 deletions host/xtest/regression_1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -3270,7 +3270,75 @@ 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 loop_count = 100;
size_t n = 0;

if (level == 0)
loop_count /= 2;

while (n < loop_count) {
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) {
if (res)
a->res = res;
else
a->res = TEEC_ERROR_GENERIC;
return NULL;
}
n++;
}
a->res = TEEC_SUCCESS;
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 b8f5f92

Please sign in to comment.