Skip to content

Commit

Permalink
xtest: regression: add case 6021 object usage
Browse files Browse the repository at this point in the history
Adds case 6021 to test modifying and checking object usage of a
persistent object.

Link: OP-TEE/optee_os#6495
Signed-off-by: Jens Wiklander <[email protected]>
  • Loading branch information
jenswi-linaro committed Nov 29, 2023
1 parent f936751 commit 1e1d39f
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions host/xtest/regression_6000.c
Original file line number Diff line number Diff line change
Expand Up @@ -2254,3 +2254,62 @@ static void xtest_tee_test_6020_single(ADBG_Case_t *c, uint32_t storage_id)
DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6020)
ADBG_CASE_DEFINE(regression, 6020, xtest_tee_test_6020,
"Object IDs in SHM (negative)");

static void xtest_tee_test_6021_single(ADBG_Case_t *c, uint32_t storage_id)
{
const uint32_t flags = TEE_DATA_FLAG_ACCESS_READ |
TEE_DATA_FLAG_ACCESS_WRITE |
TEE_DATA_FLAG_ACCESS_WRITE_META;
TEEC_Result res = TEEC_ERROR_GENERIC;
TEE_ObjectInfo obj_info = { };
TEEC_Session sess = { };
uint32_t orig = 0;
uint32_t obj = 0;

res = xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig);
if (!ADBG_EXPECT_TEEC_SUCCESS(c, res))
return;

res = fs_create(&sess, file_01, sizeof(file_01), flags, 0,
data_00, sizeof(data_00), &obj, storage_id);
if (!ADBG_EXPECT_TEEC_SUCCESS(c, res))
goto exit;

res = fs_get_obj_info(&sess, obj, &obj_info);
if (!ADBG_EXPECT_TEEC_SUCCESS(c, res))
goto exit;
ADBG_EXPECT_COMPARE_UNSIGNED(c, obj_info.objectUsage, ==, 0xffffffff);

res = fs_restrict_usage(&sess, obj, 0xfffffffe);
if (!ADBG_EXPECT_TEEC_SUCCESS(c, res))
goto exit;

res = fs_get_obj_info(&sess, obj, &obj_info);
if (!ADBG_EXPECT_TEEC_SUCCESS(c, res))
goto exit;
ADBG_EXPECT_COMPARE_UNSIGNED(c, obj_info.objectUsage, ==, 0xfffffffe);

ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj));
TEEC_CloseSession(&sess);

res = xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig);
if (!ADBG_EXPECT_TEEC_SUCCESS(c, res))
return;

res = fs_open(&sess, file_01, sizeof(file_01), flags, &obj, storage_id);
if (!ADBG_EXPECT_TEEC_SUCCESS(c, res))
goto exit;

res = fs_get_obj_info(&sess, obj, &obj_info);
if (!ADBG_EXPECT_TEEC_SUCCESS(c, res))
goto exit;
ADBG_EXPECT_COMPARE_UNSIGNED(c, obj_info.objectUsage, ==, 0xfffffffe);

exit:
ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj));
TEEC_CloseSession(&sess);
return;
}
DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6021)
ADBG_CASE_DEFINE(regression, 6021, xtest_tee_test_6021,
"Modify and check object usage");

0 comments on commit 1e1d39f

Please sign in to comment.