1 /*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "hks_cipher_test.h"
17
18 #include "hctest.h"
19 #include "hi_watchdog.h"
20 #include "hks_api.h"
21 #include "hks_param.h"
22 #include "hks_test_cipher.h"
23 #include "securec.h"
24
25 #define TEST_INDEX_0 0
26 #define TEST_INDEX_1 1
27 #define TEST_INDEX_2 2
28 #define TEST_INDEX_3 3
29 #define TEST_INDEX_4 4
30
31 /*
32 * @tc.register: register a test suit named "CalcMultiTest"
33 * @param: test subsystem name
34 * @param: c_example module name
35 * @param: CalcMultiTest test suit name
36 */
37 LITE_TEST_SUIT(husk, huks_lite, HksCipherTest);
38
39 /**
40 * @tc.setup: define a setup for test suit, format:"CalcMultiTest + SetUp"
41 * @return: true——setup success
42 */
HksCipherTestSetUp()43 static BOOL HksCipherTestSetUp()
44 {
45 LiteTestPrint("setup\n");
46 hi_watchdog_disable();
47 TEST_ASSERT_TRUE(HksInitialize() == 0);
48 return TRUE;
49 }
50
51 /**
52 * @tc.teardown: define a setup for test suit, format:"CalcMultiTest + TearDown"
53 * @return: true——teardown success
54 */
HksCipherTestTearDown()55 static BOOL HksCipherTestTearDown()
56 {
57 LiteTestPrint("tearDown\n");
58 hi_watchdog_enable();
59 return TRUE;
60 }
61
62
63 /**
64 * @tc.name: HksCipherTest.HksCipherTest001
65 * @tc.desc: The static function will return true;
66 * @tc.type: FUNC
67 */
LITE_TEST_CASE(HksCipherTest,HksCipherTest001,Level1)68 LITE_TEST_CASE(HksCipherTest, HksCipherTest001, Level1)
69 {
70 TEST_ASSERT_TRUE(BaseTestCipher(1, TEST_INDEX_0, 1) == 0);
71 }
72
73 #ifndef _CUT_AUTHENTICATE_
74
LITE_TEST_CASE(HksCipherTest,HksCipherTest002,Level1)75 LITE_TEST_CASE(HksCipherTest, HksCipherTest002, Level1)
76 {
77 TEST_ASSERT_TRUE(BaseTestCipher(1, TEST_INDEX_1, 1) == 0);
78 }
79
LITE_TEST_CASE(HksCipherTest,HksCipherTest003,Level1)80 LITE_TEST_CASE(HksCipherTest, HksCipherTest003, Level1)
81 {
82 TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_0, 1) == 0);
83 }
84
LITE_TEST_CASE(HksCipherTest,HksCipherTest004,Level1)85 LITE_TEST_CASE(HksCipherTest, HksCipherTest004, Level1)
86 {
87 TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_1, 1) == 0);
88 }
89
LITE_TEST_CASE(HksCipherTest,HksCipherTest006,Level1)90 LITE_TEST_CASE(HksCipherTest, HksCipherTest006, Level1)
91 {
92 TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_3, 1) == 0);
93 }
94
LITE_TEST_CASE(HksCipherTest,HksCipherTest007,Level1)95 LITE_TEST_CASE(HksCipherTest, HksCipherTest007, Level1)
96 {
97 TEST_ASSERT_TRUE(BaseTestEncrypt(1, TEST_INDEX_4, 1) == 0);
98 }
99
LITE_TEST_CASE(HksCipherTest,HksCipherTest008,Level1)100 LITE_TEST_CASE(HksCipherTest, HksCipherTest008, Level1)
101 {
102 TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_0, 1) == 0);
103 }
104
LITE_TEST_CASE(HksCipherTest,HksCipherTest009,Level1)105 LITE_TEST_CASE(HksCipherTest, HksCipherTest009, Level1)
106 {
107 TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_1, 1) == 0);
108 }
109
LITE_TEST_CASE(HksCipherTest,HksCipherTest011,Level1)110 LITE_TEST_CASE(HksCipherTest, HksCipherTest011, Level1)
111 {
112 TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_3, 1) == 0);
113 }
114
LITE_TEST_CASE(HksCipherTest,HksCipherTest012,Level1)115 LITE_TEST_CASE(HksCipherTest, HksCipherTest012, Level1)
116 {
117 TEST_ASSERT_TRUE(BaseTestDecrypt(1, TEST_INDEX_4, 1) == 0);
118 }
119 #endif /* _CUT_AUTHENTICATE_ */
120
121 RUN_TEST_SUITE(HksCipherTest);
122