1f6603c60Sopenharmony_ci/*
2f6603c60Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3f6603c60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f6603c60Sopenharmony_ci * you may not use this file except in compliance with the License.
5f6603c60Sopenharmony_ci * You may obtain a copy of the License at
6f6603c60Sopenharmony_ci *
7f6603c60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8f6603c60Sopenharmony_ci *
9f6603c60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10f6603c60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f6603c60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f6603c60Sopenharmony_ci * See the License for the specific language governing permissions and
13f6603c60Sopenharmony_ci * limitations under the License.
14f6603c60Sopenharmony_ci */
15f6603c60Sopenharmony_ci
16f6603c60Sopenharmony_ci#include <cstdio>
17f6603c60Sopenharmony_ci#include "gtest/gtest.h"
18f6603c60Sopenharmony_ci#include "parameter.h"
19f6603c60Sopenharmony_ci#include "sysparam_errno.h"
20f6603c60Sopenharmony_ciusing namespace std;
21f6603c60Sopenharmony_ciusing namespace testing::ext;
22f6603c60Sopenharmony_ci
23f6603c60Sopenharmony_cinamespace StartUpLite {
24f6603c60Sopenharmony_ci    static const int GET_DEF_PARA_FUN_MAX = 22;
25f6603c60Sopenharmony_ci    static const int MAX_LEN = 96;
26f6603c60Sopenharmony_ci    static const int WRONG_LEN = 2;
27f6603c60Sopenharmony_ci
28f6603c60Sopenharmony_ciclass ParameterTest : public testing::Test {
29f6603c60Sopenharmony_ciprotected:
30f6603c60Sopenharmony_ci    static void SetUpTestCase(void)
31f6603c60Sopenharmony_ci    {
32f6603c60Sopenharmony_ci        mkdir("/storage", S_IRUSR | S_IWUSR);
33f6603c60Sopenharmony_ci        mkdir("/storage/data", S_IRUSR | S_IWUSR);
34f6603c60Sopenharmony_ci        mkdir("/storage/data/system", S_IRUSR | S_IWUSR);
35f6603c60Sopenharmony_ci        mkdir("/storage/data/system/param", S_IRUSR | S_IWUSR);
36f6603c60Sopenharmony_ci    }
37f6603c60Sopenharmony_ci    static void TearDownTestCase(void) {}
38f6603c60Sopenharmony_ci    virtual void SetUp() {}
39f6603c60Sopenharmony_ci    virtual void TearDown() {}
40f6603c60Sopenharmony_ci    string defSysParam = "data of sys param ***...";
41f6603c60Sopenharmony_ci    using GetRdonlyPara = const char* (*)();
42f6603c60Sopenharmony_ci    using GetDefParaNode = struct TagGetDefParaNode {
43f6603c60Sopenharmony_ci        char const *funName;
44f6603c60Sopenharmony_ci        GetRdonlyPara fun;
45f6603c60Sopenharmony_ci    };
46f6603c60Sopenharmony_ci    GetDefParaNode getDefPara[StartUpLite::GET_DEF_PARA_FUN_MAX] = {
47f6603c60Sopenharmony_ci        {"GetDeviceType", GetDeviceType},
48f6603c60Sopenharmony_ci        {"GetManufacture", GetManufacture},
49f6603c60Sopenharmony_ci        {"GetBrand", GetBrand},
50f6603c60Sopenharmony_ci        {"GetMarketName", GetMarketName},
51f6603c60Sopenharmony_ci        {"GetProductSeries", GetProductSeries},
52f6603c60Sopenharmony_ci        {"GetProductModel", GetProductModel},
53f6603c60Sopenharmony_ci        {"GetSoftwareModel", GetSoftwareModel},
54f6603c60Sopenharmony_ci        {"GetHardwareModel", GetHardwareModel},
55f6603c60Sopenharmony_ci        {"GetHardwareProfile", GetHardwareProfile},
56f6603c60Sopenharmony_ci        {"GetOSFullName", GetOSFullName},
57f6603c60Sopenharmony_ci        {"GetDisplayVersion", GetDisplayVersion},
58f6603c60Sopenharmony_ci        {"GetBootloaderVersion", GetBootloaderVersion},
59f6603c60Sopenharmony_ci        {"GetSecurityPatchTag", GetSecurityPatchTag},
60f6603c60Sopenharmony_ci        {"GetAbiList", GetAbiList},
61f6603c60Sopenharmony_ci        {"GetIncrementalVersion", GetIncrementalVersion},
62f6603c60Sopenharmony_ci        {"GetVersionId", GetVersionId},
63f6603c60Sopenharmony_ci        {"GetBuildType", GetBuildType},
64f6603c60Sopenharmony_ci        {"GetBuildUser", GetBuildUser},
65f6603c60Sopenharmony_ci        {"GetBuildHost", GetBuildHost},
66f6603c60Sopenharmony_ci        {"GetBuildTime", GetBuildTime},
67f6603c60Sopenharmony_ci        {"GetBuildRootHash", GetBuildRootHash},
68f6603c60Sopenharmony_ci        {"GetSerial", GetSerial},
69f6603c60Sopenharmony_ci    };
70f6603c60Sopenharmony_ci};
71f6603c60Sopenharmony_ci
72f6603c60Sopenharmony_ci/**
73f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Setting_Legal_0010
74f6603c60Sopenharmony_ci * @tc.name      : SetParameter legal test with Lowercase alphanumeric, underscore, dot
75f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
76f6603c60Sopenharmony_ci */
77f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Setting_Legal_0010, Function | MediumTest | Level0)
78f6603c60Sopenharmony_ci{
79f6603c60Sopenharmony_ci    int ret;
80f6603c60Sopenharmony_ci
81f6603c60Sopenharmony_ci    char key[] = "rw.sys.version";
82f6603c60Sopenharmony_ci    char value[] = "OEM-10.1.0";
83f6603c60Sopenharmony_ci    ret = SetParameter(key, value);
84f6603c60Sopenharmony_ci    EXPECT_EQ(ret, 0);
85f6603c60Sopenharmony_ci}
86f6603c60Sopenharmony_ci
87f6603c60Sopenharmony_ci/**
88f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Setting_Legal_0020
89f6603c60Sopenharmony_ci * @tc.name      : SetParameter legal test with key 31 bytes, value 127 bytes
90f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
91f6603c60Sopenharmony_ci */
92f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Setting_Legal_0020, Function | MediumTest | Level0)
93f6603c60Sopenharmony_ci{
94f6603c60Sopenharmony_ci    int ret;
95f6603c60Sopenharmony_ci
96f6603c60Sopenharmony_ci    char key1[] = "rw.sys.version.version.version";
97f6603c60Sopenharmony_ci    char value1[] = "set with key = 31";
98f6603c60Sopenharmony_ci    ret = SetParameter(key1, value1);
99f6603c60Sopenharmony_ci    EXPECT_EQ(ret, 0);
100f6603c60Sopenharmony_ci
101f6603c60Sopenharmony_ci    char key2[] = "rw.sys.version.version";
102f6603c60Sopenharmony_ci    char value2[] = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuv";
103f6603c60Sopenharmony_ci    ret = SetParameter(key2, value2);
104f6603c60Sopenharmony_ci    EXPECT_EQ(ret, 0);
105f6603c60Sopenharmony_ci}
106f6603c60Sopenharmony_ci
107f6603c60Sopenharmony_ci/**
108f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Setting_ilLegal_0010
109f6603c60Sopenharmony_ci * @tc.name      : SetParameter legal test with key is nullptr, value is nullptr
110f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
111f6603c60Sopenharmony_ci */
112f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Setting_ilLegal_0010, Function | MediumTest | Level2)
113f6603c60Sopenharmony_ci{
114f6603c60Sopenharmony_ci    int ret;
115f6603c60Sopenharmony_ci
116f6603c60Sopenharmony_ci    char value[] = "test with null";
117f6603c60Sopenharmony_ci    ret = SetParameter(nullptr, value);
118f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
119f6603c60Sopenharmony_ci
120f6603c60Sopenharmony_ci    char key[] = "rw.sys.version";
121f6603c60Sopenharmony_ci    ret = SetParameter(key, nullptr);
122f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
123f6603c60Sopenharmony_ci}
124f6603c60Sopenharmony_ci
125f6603c60Sopenharmony_ci/**
126f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Setting_ilLegal_0020
127f6603c60Sopenharmony_ci * @tc.name      : SetParameter legal test with key is NULL, value is NULL
128f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
129f6603c60Sopenharmony_ci */
130f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Setting_ilLegal_0020, Function | MediumTest | Level2)
131f6603c60Sopenharmony_ci{
132f6603c60Sopenharmony_ci    int ret = SetParameter("\0", "\0");
133f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
134f6603c60Sopenharmony_ci}
135f6603c60Sopenharmony_ci
136f6603c60Sopenharmony_ci/**
137f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Setting_ilLegal_key_0010
138f6603c60Sopenharmony_ci * @tc.name      : SetParameter legal test with key 96 or more than 96 bytes
139f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
140f6603c60Sopenharmony_ci */
141f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Setting_ilLegal_key_0010, Function | MediumTest | Level2)
142f6603c60Sopenharmony_ci{
143f6603c60Sopenharmony_ci    int ret;
144f6603c60Sopenharmony_ci
145f6603c60Sopenharmony_ci    char key1[] = "rw.sys.version.version.version.version.version.version.version.version.version.version.version.v";
146f6603c60Sopenharmony_ci    char value1[] = "set with key = 96";
147f6603c60Sopenharmony_ci    ret = SetParameter(key1, value1);
148f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
149f6603c60Sopenharmony_ci
150f6603c60Sopenharmony_ci    char key2[] = "rw.sys.version.version.version.version.version.version.version.version.version.version.version.v1";
151f6603c60Sopenharmony_ci    char value2[] = "set with key > 96";
152f6603c60Sopenharmony_ci    ret = SetParameter(key2, value2);
153f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
154f6603c60Sopenharmony_ci}
155f6603c60Sopenharmony_ci
156f6603c60Sopenharmony_ci/**
157f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Setting_ilLegal_key_0030
158f6603c60Sopenharmony_ci * @tc.name      : SetParameter legal test with illegal characters
159f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
160f6603c60Sopenharmony_ci */
161f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Setting_ilLegal_key_0030, Function | MediumTest | Level2)
162f6603c60Sopenharmony_ci{
163f6603c60Sopenharmony_ci    int ret;
164f6603c60Sopenharmony_ci
165f6603c60Sopenharmony_ci    char key[] = "rw.sys.version*%version";
166f6603c60Sopenharmony_ci    char value[] = "set value with illegal key";
167f6603c60Sopenharmony_ci    ret = SetParameter(key, value);
168f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
169f6603c60Sopenharmony_ci}
170f6603c60Sopenharmony_ci
171f6603c60Sopenharmony_ci/**
172f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Setting_ilLegal_value_0010
173f6603c60Sopenharmony_ci * @tc.name      : SetParameter legal test with value is 96 or more than 96 bytes
174f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
175f6603c60Sopenharmony_ci */
176f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Setting_ilLegal_value_0010, Function | MediumTest | Level2)
177f6603c60Sopenharmony_ci{
178f6603c60Sopenharmony_ci    int ret;
179f6603c60Sopenharmony_ci
180f6603c60Sopenharmony_ci    char key1[] = "rw.sys.version.version";
181f6603c60Sopenharmony_ci    char value1[] = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuv11";
182f6603c60Sopenharmony_ci    ret = SetParameter(key1, value1);
183f6603c60Sopenharmony_ci    EXPECT_EQ(ret, SYSPARAM_INVALID_VALUE);
184f6603c60Sopenharmony_ci
185f6603c60Sopenharmony_ci    char key2[] = "rw.sys.version.version";
186f6603c60Sopenharmony_ci    char value2[] = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuv222";
187f6603c60Sopenharmony_ci    ret = SetParameter(key2, value2);
188f6603c60Sopenharmony_ci    EXPECT_EQ(ret, SYSPARAM_INVALID_VALUE);
189f6603c60Sopenharmony_ci}
190f6603c60Sopenharmony_ci
191f6603c60Sopenharmony_ci/**
192f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_Legal_0010
193f6603c60Sopenharmony_ci * @tc.name      : GetParameter legal test with Lowercase alphanumeric, underscore, dot
194f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
195f6603c60Sopenharmony_ci */
196f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_Legal_0010, Function | MediumTest | Level0)
197f6603c60Sopenharmony_ci{
198f6603c60Sopenharmony_ci    int ret;
199f6603c60Sopenharmony_ci
200f6603c60Sopenharmony_ci    char key[] = "rw.sys.version";
201f6603c60Sopenharmony_ci    char rightVal[] = "OEM-10.1.0";
202f6603c60Sopenharmony_ci    char value[StartUpLite::MAX_LEN] = {0};
203f6603c60Sopenharmony_ci    ret = GetParameter(key, defSysParam.c_str(), value, StartUpLite::MAX_LEN);
204f6603c60Sopenharmony_ci    EXPECT_EQ(ret, (int)strlen(rightVal));
205f6603c60Sopenharmony_ci    value[MAX_LEN - 1] = '\0';
206f6603c60Sopenharmony_ci    EXPECT_STREQ(value, rightVal);
207f6603c60Sopenharmony_ci}
208f6603c60Sopenharmony_ci
209f6603c60Sopenharmony_ci/**
210f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_Legal_0020
211f6603c60Sopenharmony_ci * @tc.name      : GetParameter legal test with defaut value point is nullptr
212f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
213f6603c60Sopenharmony_ci */
214f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_Legal_0020, Function | MediumTest | Level0)
215f6603c60Sopenharmony_ci{
216f6603c60Sopenharmony_ci    int ret;
217f6603c60Sopenharmony_ci
218f6603c60Sopenharmony_ci    char key[] = "rw.sys.version";
219f6603c60Sopenharmony_ci    char rightVal[] = "OEM-10.1.0";
220f6603c60Sopenharmony_ci    char value[StartUpLite::MAX_LEN] = {0};
221f6603c60Sopenharmony_ci    ret = GetParameter(key, nullptr, value, StartUpLite::MAX_LEN);
222f6603c60Sopenharmony_ci    EXPECT_EQ(ret, (int)strlen(rightVal));
223f6603c60Sopenharmony_ci    value[MAX_LEN - 1] = '\0';
224f6603c60Sopenharmony_ci    EXPECT_STREQ(value, rightVal);
225f6603c60Sopenharmony_ci}
226f6603c60Sopenharmony_ci
227f6603c60Sopenharmony_ci/**
228f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_Legal_0030
229f6603c60Sopenharmony_ci * @tc.name      : GetParameter legal test with length is 95 bytes, value is 95 bytes
230f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
231f6603c60Sopenharmony_ci */
232f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_Legal_0030, Function | MediumTest | Level0)
233f6603c60Sopenharmony_ci{
234f6603c60Sopenharmony_ci    int ret;
235f6603c60Sopenharmony_ci
236f6603c60Sopenharmony_ci    char key1[] = "rw.sys.version.version.version";
237f6603c60Sopenharmony_ci    char rightVal1[] = "set with key = 31";
238f6603c60Sopenharmony_ci    char value1[StartUpLite::MAX_LEN] = {0};
239f6603c60Sopenharmony_ci    ret = GetParameter(key1, defSysParam.c_str(), value1, StartUpLite::MAX_LEN);
240f6603c60Sopenharmony_ci    EXPECT_EQ(ret, (int)strlen(rightVal1));
241f6603c60Sopenharmony_ci    value1[MAX_LEN - 1] = '\0';
242f6603c60Sopenharmony_ci    EXPECT_STREQ(value1, rightVal1);
243f6603c60Sopenharmony_ci
244f6603c60Sopenharmony_ci    char key2[] = "rw.sys.version.version";
245f6603c60Sopenharmony_ci    char rightVal2[] = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuv";
246f6603c60Sopenharmony_ci    char value2[StartUpLite::MAX_LEN] = {0};
247f6603c60Sopenharmony_ci    ret = GetParameter(key2, defSysParam.c_str(), value2, StartUpLite::MAX_LEN);
248f6603c60Sopenharmony_ci    value2[MAX_LEN - 1] = '\0';
249f6603c60Sopenharmony_ci    EXPECT_EQ(ret, (int)strlen(rightVal2));
250f6603c60Sopenharmony_ci    EXPECT_STREQ(value2, rightVal2);
251f6603c60Sopenharmony_ci}
252f6603c60Sopenharmony_ci
253f6603c60Sopenharmony_ci/**
254f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_ilLegal_0010
255f6603c60Sopenharmony_ci * @tc.name      : GetParameter legal test with value length is too short
256f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
257f6603c60Sopenharmony_ci */
258f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_ilLegal_0010, Function | MediumTest | Level2)
259f6603c60Sopenharmony_ci{
260f6603c60Sopenharmony_ci    int ret;
261f6603c60Sopenharmony_ci
262f6603c60Sopenharmony_ci    char key[] = "rw.sys.version";
263f6603c60Sopenharmony_ci    char value[StartUpLite::WRONG_LEN] = {0};
264f6603c60Sopenharmony_ci    ret = GetParameter(key, defSysParam.c_str(), value, StartUpLite::WRONG_LEN);
265f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
266f6603c60Sopenharmony_ci}
267f6603c60Sopenharmony_ci
268f6603c60Sopenharmony_ci/**
269f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_ilLegal_0020
270f6603c60Sopenharmony_ci * @tc.name      : GetParameter legal test with value point is nullptr
271f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
272f6603c60Sopenharmony_ci */
273f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_ilLegal_0020, Function | MediumTest | Level2)
274f6603c60Sopenharmony_ci{
275f6603c60Sopenharmony_ci    int ret;
276f6603c60Sopenharmony_ci
277f6603c60Sopenharmony_ci    char key[] = "rw.sys.version";
278f6603c60Sopenharmony_ci    ret = GetParameter(key, defSysParam.c_str(), nullptr, StartUpLite::MAX_LEN);
279f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
280f6603c60Sopenharmony_ci}
281f6603c60Sopenharmony_ci
282f6603c60Sopenharmony_ci/**
283f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_ilLegal_0030
284f6603c60Sopenharmony_ci * @tc.name      : GetParameter legal test with key is not exist and vlan len is too short
285f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
286f6603c60Sopenharmony_ci */
287f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_ilLegal_0030, Function | MediumTest | Level2)
288f6603c60Sopenharmony_ci{
289f6603c60Sopenharmony_ci    int ret;
290f6603c60Sopenharmony_ci
291f6603c60Sopenharmony_ci    char key1[] = "rw.product.not.exist";
292f6603c60Sopenharmony_ci    char value1[StartUpLite::MAX_LEN] = {0};
293f6603c60Sopenharmony_ci    ret = GetParameter(key1, defSysParam.c_str(), value1, StartUpLite::MAX_LEN);
294f6603c60Sopenharmony_ci    EXPECT_EQ(ret, (int)strlen(defSysParam.c_str()));
295f6603c60Sopenharmony_ci    value1[MAX_LEN - 1] = '\0';
296f6603c60Sopenharmony_ci    EXPECT_STREQ(value1, defSysParam.c_str());
297f6603c60Sopenharmony_ci
298f6603c60Sopenharmony_ci    char value2[StartUpLite::WRONG_LEN] = {0};
299f6603c60Sopenharmony_ci    ret = GetParameter(key1, defSysParam.c_str(), value2, StartUpLite::WRONG_LEN);
300f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
301f6603c60Sopenharmony_ci}
302f6603c60Sopenharmony_ci
303f6603c60Sopenharmony_ci/**
304f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_ilLegal_0040
305f6603c60Sopenharmony_ci * @tc.name      : GetParameter legal test with key is 96 bytes
306f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
307f6603c60Sopenharmony_ci */
308f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_ilLegal_0040, Function | MediumTest | Level2)
309f6603c60Sopenharmony_ci{
310f6603c60Sopenharmony_ci    int ret;
311f6603c60Sopenharmony_ci
312f6603c60Sopenharmony_ci    char key[] = "rw.sys.version.version.version.v";
313f6603c60Sopenharmony_ci    char value[StartUpLite::MAX_LEN] = {0};
314f6603c60Sopenharmony_ci    ret = GetParameter(key, defSysParam.c_str(), value, StartUpLite::MAX_LEN);
315f6603c60Sopenharmony_ci    EXPECT_STREQ(value, defSysParam.c_str());
316f6603c60Sopenharmony_ci}
317f6603c60Sopenharmony_ci
318f6603c60Sopenharmony_ci/**
319f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_ilLegal_0050
320f6603c60Sopenharmony_ci * @tc.name      : GetParameter legal test with key is nullptr
321f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
322f6603c60Sopenharmony_ci */
323f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_ilLegal_0050, Function | MediumTest | Level2)
324f6603c60Sopenharmony_ci{
325f6603c60Sopenharmony_ci    int ret;
326f6603c60Sopenharmony_ci
327f6603c60Sopenharmony_ci    char value[StartUpLite::MAX_LEN] = {0};
328f6603c60Sopenharmony_ci    ret = GetParameter(nullptr, defSysParam.c_str(), value, StartUpLite::MAX_LEN);
329f6603c60Sopenharmony_ci    EXPECT_EQ(ret, -9);
330f6603c60Sopenharmony_ci}
331f6603c60Sopenharmony_ci
332f6603c60Sopenharmony_ci/**
333f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_ilLegal_0060
334f6603c60Sopenharmony_ci * @tc.name      : GetParameter legal test with key is illegal with Special characters
335f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
336f6603c60Sopenharmony_ci */
337f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_ilLegal_0060, Function | MediumTest | Level2)
338f6603c60Sopenharmony_ci{
339f6603c60Sopenharmony_ci    int ret;
340f6603c60Sopenharmony_ci
341f6603c60Sopenharmony_ci    char key[] = "rw.sys.version*%version";
342f6603c60Sopenharmony_ci    char value[StartUpLite::MAX_LEN] = {0};
343f6603c60Sopenharmony_ci    ret = GetParameter(key, defSysParam.c_str(), value, StartUpLite::MAX_LEN);
344f6603c60Sopenharmony_ci    EXPECT_STREQ(value, defSysParam.c_str());
345f6603c60Sopenharmony_ci}
346f6603c60Sopenharmony_ci
347f6603c60Sopenharmony_ci/**
348f6603c60Sopenharmony_ci * @tc.number    : SUB_START_Para_Getting_ReadOnly_0010
349f6603c60Sopenharmony_ci * @tc.name      : GetParameter read only parameter legal test
350f6603c60Sopenharmony_ci * @tc.desc      : [C- SOFTWARE -0200]
351f6603c60Sopenharmony_ci */
352f6603c60Sopenharmony_ciHWTEST_F(ParameterTest, SUB_START_Para_Getting_ReadOnly_0010, Function | MediumTest | Level0)
353f6603c60Sopenharmony_ci{
354f6603c60Sopenharmony_ci    const char *value = nullptr;
355f6603c60Sopenharmony_ci
356f6603c60Sopenharmony_ci    for (int loop = 0; loop < StartUpLite::GET_DEF_PARA_FUN_MAX; loop++) {
357f6603c60Sopenharmony_ci        value = getDefPara[loop].fun();
358f6603c60Sopenharmony_ci        EXPECT_STRNE(value, (char *)nullptr);
359f6603c60Sopenharmony_ci    }
360f6603c60Sopenharmony_ci    EXPECT_GT(GetFirstApiVersion(), 0);
361f6603c60Sopenharmony_ci    EXPECT_GT(GetSdkApiVersion(), 0);
362f6603c60Sopenharmony_ci}
363f6603c60Sopenharmony_ci}