1 /*
2  * Copyright (c) 2024 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 <gtest/gtest.h>
17 #include <cstdlib>
18 #include <unistd.h>
19 #include <sys/wait.h>
20 #include <csignal>
21 #include <cerrno>
22 #include <cstring>
23 #include <sys/prctl.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <fcntl.h>
27 #include <sys/syscall.h>
28 #include <asm/unistd.h>
29 #include <syscall.h>
30 #include <climits>
31 #include <sched.h>
32 
33 using namespace std;
34 using namespace testing::ext;
35 
36 namespace init_ut {
37 class TokenUnitTest : public testing::Test {
38 public:
SetUpTestCase(void)39     static void SetUpTestCase(void) {};
TearDownTestCase(void)40     static void TearDownTestCase(void) {};
SetUp(void)41     void SetUp(void) {};
TearDown(void)42     void TearDown(void) {};
43 };
44 
HWTEST_F(TokenUnitTest, Init_HalReadToken_001, TestSize.Level0)45 HWTEST_F(TokenUnitTest, Init_HalReadToken_001, TestSize.Level0)
46 {
47     char *token;
48     unsigned int len;
49     int ret = HalReadToken(token, len);
50     EXPECT_EQ(ret, 0);
51 }
52 
HWTEST_F(TokenUnitTest, Init_HalWriteToken_001, TestSize.Level0)53 HWTEST_F(TokenUnitTest, Init_HalWriteToken_001, TestSize.Level0)
54 {
55     const char *token;
56     unsigned int len;
57     int ret = HalWriteToken(token, len);
58     EXPECT_EQ(ret, 0);
59 }
60 
HWTEST_F(TokenUnitTest, Init_HalGetAcKey_001, TestSize.Level0)61 HWTEST_F(TokenUnitTest, Init_HalGetAcKey_001, TestSize.Level0)
62 {
63     char *acKey;
64     unsigned int len;
65     int ret = HalGetAcKey(acKey, len);
66     EXPECT_EQ(ret, 0);
67 }
68 
HWTEST_F(TokenUnitTest, Init_HalGetProdId_001, TestSize.Level0)69 HWTEST_F(TokenUnitTest, Init_HalGetProdId_001, TestSize.Level0)
70 {
71     char *productId;
72     unsigned int len;
73     int ret = HalGetProdId(productId, len);
74     EXPECT_EQ(ret, 0);
75 }
76 
HWTEST_F(TokenUnitTest, Init_FsHvbGetValueFromCmdLine_001, TestSize.Level0)77 HWTEST_F(TokenUnitTest, Init_FsHvbGetValueFromCmdLine_001, TestSize.Level0)
78 {
79     char *productKey;
80     unsigned int len;
81     int ret = HalGetProdKey(productKey, len);
82     EXPECT_EQ(ret, 0);
83 }
84 }
85