• 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 #include <gtest/gtest.h>
15 #include <securec.h>
16 #include <tee_client_api.h>
17 #include <tee_client_type.h>
18 #include <test_defines.h>
19 #include <test_log.h>
20 #include <test_tcf_cmdid.h>
21 
22 using namespace testing::ext;
23 /**
24  * @testcase.name      : TEE_Free_With_BufferIsNull
25  * @testcase.desc      : test TA call TEE_Free to while buff is null
26  * @testcase.expect    : return TEEC_SUCCESS
27 */
28 TEE_TEST(TeeTCF2Test, TEE_Free_With_BufferIsNull, Function | MediumTest | Level0)
29 {
30     TEEC_Result ret;
31     uint32_t origin;
32     uint32_t caseId = INPUT_ISNULL;
33 
34     ret = Invoke_Free(GetSession(), CMD_TEE_Free, caseId, &origin);
35     ASSERT_EQ(ret, TEEC_SUCCESS);
36     ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
37 }
38 
39 /**
40  * @testcase.name      : TEE_Free_With_Normal
41  * @testcase.desc      : test TA call TEE_Free after normal TEE_Malloc
42  * @testcase.expect    : return TEEC_SUCCESS
43 */
44 TEE_TEST(TeeTCF2Test, TEE_Free_With_Normal, Function | MediumTest | Level0)
45 {
46     TEEC_Result ret;
47     uint32_t origin;
48     uint32_t caseId = 0;
49 
50     ret = Invoke_Free(GetSession(), CMD_TEE_Free, caseId, &origin);
51     ASSERT_EQ(ret, TEEC_SUCCESS);
52     ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP);
53 }
54