• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  * http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 
13 #include <common_test.h>
14 
SetUp()15 void TrustedStorageTest::SetUp()
16 {
17     TEEC_Result ret;
18     TEEC_UUID testId = TRUSTED_STORAGE_API_UUID;
19     ret = session.Start(&testId);
20     ASSERT_EQ(ret, TEEC_SUCCESS);
21     operation.started = 1;
22     operation.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_WHOLE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
23     testMem.sharedMem.size = FUN_NAME_LEN;
24     testMem.sharedMem.flags = TEEC_MEM_OUTPUT | TEEC_MEM_INPUT;
25     ret = TEEC_AllocateSharedMemory(&session.context, &testMem.sharedMem);
26     (void)memset_s(reinterpret_cast<char*>(testMem.sharedMem.buffer), FUN_NAME_LEN, 0, FUN_NAME_LEN);
27     ASSERT_EQ(ret, TEEC_SUCCESS);
28 }
29 
TearDown()30 void TrustedStorageTest::TearDown()
31 {
32     TEEC_ReleaseSharedMemory(&testMem.sharedMem);
33     session.Destroy();
34 }
35 
InvokeTest(const char * casename)36 TEEC_Result TrustedStorageTest::InvokeTest(const char *casename)
37 {
38     int rc = strcpy_s(reinterpret_cast<char*>(testMem.sharedMem.buffer), FUN_NAME_LEN, casename);
39     if (rc != 0) {
40         return TEEC_FAIL;
41     }
42     operation.params[0].memref.parent = &testMem.sharedMem;
43     operation.params[0].memref.offset = 0;
44     operation.params[0].memref.size = testMem.sharedMem.size;
45     return TEEC_InvokeCommand(&session.session, CMD_RUN_BY_FUN_SEQ, &operation, &origin);
46 }
47