• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "begetctl.h"
16 #include "init_unittest.h"
17 #include "securec.h"
18 #include "shell.h"
19 
20 using namespace std;
21 using namespace testing::ext;
22 
23 namespace init_ut {
24 class BegetctlUnitTest : public testing::Test {
25 public:
SetUpTestCase(void)26     static void SetUpTestCase(void) {};
TearDownTestCase(void)27     static void TearDownTestCase(void) {};
SetUp(void)28     void SetUp(void) {};
TearDown(void)29     void TearDown(void) {};
30 };
31 
32 HWTEST_F(BegetctlUnitTest, TestShellInit, TestSize.Level0)
33 {
34     BShellParamCmdRegister(GetShellHandle(), 0);
35     const char *args[] = {
36         "param"
37     };
38     BShellEnvDirectExecute(GetShellHandle(), 1, (char **)args);
39 }
40 
41 HWTEST_F(BegetctlUnitTest, TestShellLs, TestSize.Level1)
42 {
43     BShellParamCmdRegister(GetShellHandle(), 0);
44     const char *args[] = {
45         "param", "ls"
46     };
47     BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
48 }
49 
50 HWTEST_F(BegetctlUnitTest, TestShellLsWithR, TestSize.Level1)
51 {
52     BShellParamCmdRegister(GetShellHandle(), 0);
53     const char *args[] = {
54         "param", "ls", "-r"
55     };
56     BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
57 }
58 
59 HWTEST_F(BegetctlUnitTest, TestShellLsGet, TestSize.Level1)
60 {
61     BShellParamCmdRegister(GetShellHandle(), 0);
62     const char *args[] = {
63         "param", "get"
64     };
65     BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
66 }
67 
68 HWTEST_F(BegetctlUnitTest, TestShellSet, TestSize.Level1)
69 {
70     BShellParamCmdRegister(GetShellHandle(), 0);
71     const char *args[] = {
72         "param", "set", "aaaaa", "1234567"
73     };
74     BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
75 }
76 
77 HWTEST_F(BegetctlUnitTest, TestShellGetWithKey, TestSize.Level1)
78 {
79     BShellParamCmdRegister(GetShellHandle(), 0);
80     const char *args[] = {
81         "param", "get", "aaaaa"
82     };
83     BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
84 }
85 
86 HWTEST_F(BegetctlUnitTest, TestShellWait, TestSize.Level1)
87 {
88     BShellParamCmdRegister(GetShellHandle(), 0);
89     const char *args[] = {
90         "param", "wait", "aaaaa"
91     };
92     BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
93 }
94 
95 HWTEST_F(BegetctlUnitTest, TestShellWaitWithKey, TestSize.Level1)
96 {
97     BShellParamCmdRegister(GetShellHandle(), 0);
98     const char *args[] = {
99         "param", "wait", "aaaaa", "12*", "30"
100     };
101     BShellEnvDirectExecute(GetShellHandle(), sizeof(args) / sizeof(args[0]), (char **)args);
102 }
103 }  // namespace init_ut
104