parameter_func_test.c 29.0 KB
Newer Older
W
wenjun 已提交
1
/*
M
mamingshuai 已提交
2
 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
W
wenjun 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

M
mamingshuai 已提交
16
#include "ohos_types.h"
W
wenjun 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#include <securec.h>
#include "hctest.h"
#include "parameter.h"
#include "parameter_utils.h"

#define MAX_LEN    128
#define INVALID_LEN    2
#define COMMON_ERROR (-1)
#define INVALID_PARAMETER (-9)

static const char* g_defSysParam = "data of sys param ***...";

/**
 * @tc.desc      : register a test suite, this suite is used to test basic flow and interface dependency
 * @param        : subsystem name is utils
 * @param        : module name is parameter
 * @param        : test suit name is ParameterFuncTestSuite
 */
LITE_TEST_SUIT(utils, parameter, ParameterFuncTestSuite);

/**
 * @tc.setup     : setup for all testcases
 * @return       : setup result, TRUE is success, FALSE is fail
 */
static BOOL ParameterFuncTestSuiteSetUp(void)
{
    return TRUE;
}

/**
 * @tc.teardown  : teardown for all testcases
 * @return       : teardown result, TRUE is success, FALSE is fail
 */
static BOOL ParameterFuncTestSuiteTearDown(void)
{
    printf("+-------------------------------------------+\n");
    return TRUE;
}

/**
M
mamingshuai 已提交
57
 * @tc.number    : SUB_UTILS_PARAMETER_0100
58
 * @tc.name      : Obtaining system parameter DeviceType
W
wenjun 已提交
59 60
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
61
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara001, Function | MediumTest | Level1)
W
wenjun 已提交
62
{
L
lanxueyuan 已提交
63
    const char* value = GetDeviceType();
64
    printf("Device Type=%s\n", value);
65
    AssertNotEmpty(value);
W
wenjun 已提交
66 67 68
};

/**
M
mamingshuai 已提交
69 70
 * @tc.number    : SUB_UTILS_PARAMETER_0200
 * @tc.name      : Obtaining system parameter Manufacture
W
wenjun 已提交
71 72
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
73
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara002, Function | MediumTest | Level1)
W
wenjun 已提交
74
{
L
lanxueyuan 已提交
75
    const char* value = GetManufacture();
W
wenjun 已提交
76
    printf("Manufacture=%s\n", value);
77
    AssertNotEmpty(value);
W
wenjun 已提交
78 79 80
};

/**
M
mamingshuai 已提交
81 82
 * @tc.number    : SUB_UTILS_PARAMETER_0300
 * @tc.name      : Obtaining system parameter Brand
W
wenjun 已提交
83 84
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
85
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara003, Function | MediumTest | Level1)
W
wenjun 已提交
86
{
L
lanxueyuan 已提交
87
    const char* value = GetBrand();
W
wenjun 已提交
88
    printf("Brand=%s\n", value);
89
    AssertNotEmpty(value);
W
wenjun 已提交
90 91 92
};

/**
M
mamingshuai 已提交
93 94
 * @tc.number    : SUB_UTILS_PARAMETER_0400
 * @tc.name      : Obtaining system parameter MarketName
W
wenjun 已提交
95 96
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
97
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara004, Function | MediumTest | Level1)
W
wenjun 已提交
98
{
L
lanxueyuan 已提交
99
    const char* value = GetMarketName();
W
wenjun 已提交
100
    printf("Market Name=%s\n", value);
101
    AssertNotEmpty(value);
W
wenjun 已提交
102 103 104
};

/**
M
mamingshuai 已提交
105 106
 * @tc.number    : SUB_UTILS_PARAMETER_0500
 * @tc.name      : Obtaining system parameter ProductSeries
W
wenjun 已提交
107 108
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
109
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara005, Function | MediumTest | Level1)
W
wenjun 已提交
110
{
L
lanxueyuan 已提交
111
    const char* value = GetProductSeries();
W
wenjun 已提交
112
    printf("Product Series=%s\n", value);
113
    AssertNotEmpty(value);
W
wenjun 已提交
114 115 116
};

/**
M
mamingshuai 已提交
117 118
 * @tc.number    : SUB_UTILS_PARAMETER_0600
 * @tc.name      : Obtaining system parameter ProductModel
W
wenjun 已提交
119 120
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
121
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara006, Function | MediumTest | Level1)
W
wenjun 已提交
122
{
L
lanxueyuan 已提交
123
    const char* value = GetProductModel();
W
wenjun 已提交
124
    printf("Product Model=%s\n", value);
125
    AssertNotEmpty(value);
W
wenjun 已提交
126 127 128
};

/**
M
mamingshuai 已提交
129 130
 * @tc.number    : SUB_UTILS_PARAMETER_0700
 * @tc.name      : Obtaining system parameter HardwareModel
W
wenjun 已提交
131 132
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
133
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara007, Function | MediumTest | Level1)
W
wenjun 已提交
134
{
L
lanxueyuan 已提交
135
    const char* value = GetHardwareModel();
W
wenjun 已提交
136
    printf("Hardware Model=%s\n", value);
137
    AssertNotEmpty(value);
W
wenjun 已提交
138 139 140
};

/**
M
mamingshuai 已提交
141 142
 * @tc.number    : SUB_UTILS_PARAMETER_0800
 * @tc.name      : Obtaining system parameter HardwareProfile
W
wenjun 已提交
143 144
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
145
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara008, Function | MediumTest | Level1)
W
wenjun 已提交
146
{
L
lanxueyuan 已提交
147
    const char* value = GetHardwareProfile();
W
wenjun 已提交
148
    printf("Hardware Profile=%s\n", value);
149
    AssertNotEmpty(value);
W
wenjun 已提交
150 151 152
};

/**
M
mamingshuai 已提交
153 154
 * @tc.number    : SUB_UTILS_PARAMETER_0900
 * @tc.name      : Obtaining system parameter Serial
W
wenjun 已提交
155 156
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
157
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara009, Function | MediumTest | Level1)
W
wenjun 已提交
158
{
L
lanxueyuan 已提交
159
    const char* value = GetSerial();
W
wenjun 已提交
160
    printf("Serial=%s\n", value);
161
    AssertNotEmpty(value);
W
wenjun 已提交
162 163 164
};

/**
M
mamingshuai 已提交
165 166
 * @tc.number    : SUB_UTILS_PARAMETER_1000
 * @tc.name      : Obtaining system parameter OsName
W
wenjun 已提交
167 168
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
169
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara010, Function | MediumTest | Level1)
W
wenjun 已提交
170
{
L
lanxueyuan 已提交
171
    const char* value = GetOSFullName();
W
wenjun 已提交
172
    printf("Os Name=%s\n", value);
173
    AssertNotEmpty(value);
W
wenjun 已提交
174 175 176
};

/**
M
mamingshuai 已提交
177 178
 * @tc.number    : SUB_UTILS_PARAMETER_1100
 * @tc.name      : Obtaining system parameter DisplayVersion
W
wenjun 已提交
179 180
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
181
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara011, Function | MediumTest | Level1)
W
wenjun 已提交
182
{
L
lanxueyuan 已提交
183
    const char* value = GetDisplayVersion();
W
wenjun 已提交
184
    printf("Display Version=%s\n", value);
185
    AssertNotEmpty(value);
W
wenjun 已提交
186 187 188
};

/**
M
mamingshuai 已提交
189 190
 * @tc.number    : SUB_UTILS_PARAMETER_1200
 * @tc.name      : Obtaining system parameter BootloaderVersion
W
wenjun 已提交
191 192
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
193
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara012, Function | MediumTest | Level1)
W
wenjun 已提交
194
{
L
lanxueyuan 已提交
195
    const char* value = GetBootloaderVersion();
W
wenjun 已提交
196
    printf("Bootloader Version=%s\n", value);
197
    AssertNotEmpty(value);
W
wenjun 已提交
198 199 200
};

/**
M
mamingshuai 已提交
201 202
 * @tc.number    : SUB_UTILS_PARAMETER_1300
 * @tc.name      : Obtaining system parameter SecurityPatchTag
W
wenjun 已提交
203 204
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
205
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara013, Function | MediumTest | Level1)
W
wenjun 已提交
206
{
L
lanxueyuan 已提交
207
    const char* value = GetSecurityPatchTag();
W
wenjun 已提交
208
    printf("Secure Patch Level=%s\n", value);
209
    AssertNotEmpty(value);
W
wenjun 已提交
210 211 212
};

/**
M
mamingshuai 已提交
213 214
 * @tc.number    : SUB_UTILS_PARAMETER_1400
 * @tc.name      : Obtaining system parameter AbiList
W
wenjun 已提交
215 216
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
217
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara014, Function | MediumTest | Level1)
W
wenjun 已提交
218
{
L
lanxueyuan 已提交
219
    const char* value = GetAbiList();
W
wenjun 已提交
220
    printf("Abi List=%s\n", value);
221
    AssertNotEmpty(value);
W
wenjun 已提交
222 223 224
};

/**
M
mamingshuai 已提交
225 226
 * @tc.number    : SUB_UTILS_PARAMETER_1500
 * @tc.name      : Obtaining system parameter FirstApiLevel
W
wenjun 已提交
227 228
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
229
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara015, Function | MediumTest | Level1)
W
wenjun 已提交
230
{
L
lanxueyuan 已提交
231 232
    int value = GetFirstApiVersion();
    printf("First Api Level=%d\n", value);
233
    TEST_ASSERT_TRUE(value > 0);
W
wenjun 已提交
234 235 236
};

/**
M
mamingshuai 已提交
237 238
 * @tc.number    : SUB_UTILS_PARAMETER_1600
 * @tc.name      : Obtaining system parameter IncrementalVersion
W
wenjun 已提交
239 240
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
241
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara016, Function | MediumTest | Level1)
W
wenjun 已提交
242
{
L
lanxueyuan 已提交
243
    const char* value = GetIncrementalVersion();
W
wenjun 已提交
244
    printf("Incremental Version=%s\n", value);
245
    AssertNotEmpty(value);
W
wenjun 已提交
246 247 248
};

/**
M
mamingshuai 已提交
249 250
 * @tc.number    : SUB_UTILS_PARAMETER_1700
 * @tc.name      : Obtaining system parameter VersionId
W
wenjun 已提交
251 252
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
253
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara017, Function | MediumTest | Level1)
W
wenjun 已提交
254
{
L
lanxueyuan 已提交
255
    const char* value = GetVersionId();
W
wenjun 已提交
256
    printf("Version Id=%s\n", value);
257
    AssertNotEmpty(value);
W
wenjun 已提交
258 259 260
};

/**
M
mamingshuai 已提交
261 262
 * @tc.number    : SUB_UTILS_PARAMETER_1800
 * @tc.name      : Obtaining system parameter BuildType
W
wenjun 已提交
263 264
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
265
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara018, Function | MediumTest | Level1)
W
wenjun 已提交
266
{
L
lanxueyuan 已提交
267
    const char* value = GetBuildType();
W
wenjun 已提交
268
    printf("Build Type=%s\n", value);
269
    AssertNotEmpty(value);
W
wenjun 已提交
270 271 272
};

/**
M
mamingshuai 已提交
273 274
 * @tc.number    : SUB_UTILS_PARAMETER_1900
 * @tc.name      : Obtaining system parameter BuildUser
W
wenjun 已提交
275 276
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
277
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara019, Function | MediumTest | Level1)
W
wenjun 已提交
278
{
L
lanxueyuan 已提交
279
    const char* value = GetBuildUser();
W
wenjun 已提交
280
    printf("Build User=%s\n", value);
281
    AssertNotEmpty(value);
W
wenjun 已提交
282 283 284
};

/**
M
mamingshuai 已提交
285 286
 * @tc.number    : SUB_UTILS_PARAMETER_2000
 * @tc.name      : Obtaining system parameter BuildHost
W
wenjun 已提交
287 288
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
289
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara020, Function | MediumTest | Level1)
W
wenjun 已提交
290
{
L
lanxueyuan 已提交
291
    const char* value = GetBuildHost();
W
wenjun 已提交
292
    printf("Build Host=%s\n", value);
293
    AssertNotEmpty(value);
W
wenjun 已提交
294 295 296
};

/**
M
mamingshuai 已提交
297 298
 * @tc.number    : SUB_UTILS_PARAMETER_2100
 * @tc.name      : Obtaining system parameter BuildTime
W
wenjun 已提交
299 300
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
301
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara021, Function | MediumTest | Level1)
W
wenjun 已提交
302
{
L
lanxueyuan 已提交
303
    const char* value = GetBuildTime();
W
wenjun 已提交
304
    printf("Build Time=%s\n", value);
305
    AssertNotEmpty(value);
W
wenjun 已提交
306 307 308
};

/**
M
mamingshuai 已提交
309 310
 * @tc.number    : SUB_UTILS_PARAMETER_2200
 * @tc.name      : Obtaining system parameter BuildRootHash
W
wenjun 已提交
311 312
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
313
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara022, Function | MediumTest | Level1)
W
wenjun 已提交
314
{
L
lanxueyuan 已提交
315
    const char* value = GetBuildRootHash();
W
wenjun 已提交
316
    printf("Build Root Hash=%s\n", value);
317
    TEST_ASSERT_NOT_NULL(value);
W
wenjun 已提交
318 319 320
};

/**
M
mamingshuai 已提交
321 322
 * @tc.number    : SUB_UTILS_PARAMETER_2300
 * @tc.name      : Obtaining system parameter SoftwareModel
W
wenjun 已提交
323 324
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
325
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara023, Function | MediumTest | Level1)
W
wenjun 已提交
326
{
L
lanxueyuan 已提交
327
    const char* value = GetSoftwareModel();
W
wenjun 已提交
328
    printf("Software Model=%s\n", value);
329
    AssertNotEmpty(value);
W
wenjun 已提交
330 331 332
};

/**
M
mamingshuai 已提交
333 334
 * @tc.number    : SUB_UTILS_PARAMETER_2400
 * @tc.name      : Obtaining system parameter SdkApiLevel
W
wenjun 已提交
335 336
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
337
LITE_TEST_CASE(ParameterFuncTestSuite, testObtainSysPara024, Function | MediumTest | Level1)
W
wenjun 已提交
338
{
L
lanxueyuan 已提交
339 340
    int value = GetSdkApiVersion();
    printf("Sdk Api Level=%d\n", value);
341
    TEST_ASSERT_TRUE(value > 0);
W
wenjun 已提交
342 343 344
};

/**
M
mamingshuai 已提交
345 346
 * @tc.number    : SUB_UTILS_PARAMETER_2500
 * @tc.name      : SetParameter parameter legal test
W
wenjun 已提交
347 348
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
349
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter001, Function | MediumTest | Level1)
W
wenjun 已提交
350 351 352 353
{
    int ret;

    char key[] = "rw.sys.version_606";
M
mamingshuai 已提交
354
    char value[] = "OEM-10.1.0";
W
wenjun 已提交
355 356 357 358 359
    ret = SetParameter(key, value);
    TEST_ASSERT_EQUAL_INT(0, ret);
};

/**
M
mamingshuai 已提交
360 361
 * @tc.number    : SUB_UTILS_PARAMETER_2600
 * @tc.name      : SetParameter parameter legal test with Special characters
W
wenjun 已提交
362 363
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
364
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter002, Function | MediumTest | Level1)
W
wenjun 已提交
365 366 367 368 369 370 371 372 373 374
{
    int ret;

    char key[] = "_._..__...___";
    char value[] = "!@#¥%……&*()——+~《》?,。、“‘;:、12345767890";
    ret = SetParameter(key, value);
    TEST_ASSERT_EQUAL_INT(0, ret);
};

/**
M
mamingshuai 已提交
375 376
 * @tc.number    : SUB_UTILS_PARAMETER_2700
 * @tc.name      : SetParameter parameter legal test using key with only lowercase
W
wenjun 已提交
377 378
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
379
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter003, Function | MediumTest | Level1)
W
wenjun 已提交
380 381 382 383 384 385 386 387 388 389
{
    int ret;

    char key[] = "keywithonlylowercase";
    char value[] = "test key with only lowercase";
    ret = SetParameter(key, value);
    TEST_ASSERT_EQUAL_INT(0, ret);
};

/**
M
mamingshuai 已提交
390 391
 * @tc.number    : SUB_UTILS_PARAMETER_2800
 * @tc.name      : SetParameter parameter legal test using key with only number
W
wenjun 已提交
392 393
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
394
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter004, Function | MediumTest | Level1)
W
wenjun 已提交
395 396 397 398 399 400 401 402 403 404
{
    int ret;

    char key[] = "202006060602";
    char value[] = "test key with only number";
    ret = SetParameter(key, value);
    TEST_ASSERT_EQUAL_INT(0, ret);
};

/**
M
mamingshuai 已提交
405 406
 * @tc.number    : SUB_UTILS_PARAMETER_2900
 * @tc.name      : SetParameter parameter legal test using key and value with maximum length
W
wenjun 已提交
407 408
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
409
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter005, Function | MediumTest | Level1)
W
wenjun 已提交
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
{
    int ret;

    char key1[] = "rw.sys.version.version.version.";
    char value1[] = "set with key = 31";
    ret = SetParameter(key1, value1);
    TEST_ASSERT_EQUAL_INT(0, ret);

    char key2[] = "rw.sys.version.version";
    char value2[] = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890\
abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrs";
    ret = SetParameter(key2, value2);
    TEST_ASSERT_EQUAL_INT(0, ret);
};

/**
M
mamingshuai 已提交
426 427
 * @tc.number    : SUB_UTILS_PARAMETER_3000
 * @tc.name      : SetParameter parameter illegal test when key is nullptr and value is nullptr
W
wenjun 已提交
428 429
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
430
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter006, Function | MediumTest | Level1)
W
wenjun 已提交
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
{
    int ret;

    char value[] = "test with null";
    ret = SetParameter(NULL, value);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }

    char key[] = "rw.sys.version";
    ret = SetParameter(key, NULL);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
450 451
 * @tc.number    : SUB_UTILS_PARAMETER_3100
 * @tc.name      : SetParameter parameter illegal test when key is NULL and value is NULL
W
wenjun 已提交
452 453
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
454
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter007, Function | MediumTest | Level1)
W
wenjun 已提交
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
{
    int ret;

    char value[] = "test with null";
    ret = SetParameter("\0", value);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }

    char key[] = "rw.sys.version";
    ret = SetParameter(key, "\0");
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
474 475
 * @tc.number    : SUB_UTILS_PARAMETER_3200
 * @tc.name      : SetParameter parameter illegal test when key len is 32 or more than 32 bytes
W
wenjun 已提交
476 477
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
478
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter008, Function | MediumTest | Level1)
W
wenjun 已提交
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
{
    int ret;

    char key1[] = "rw.sys.version.version.version.v";
    char value1[] = "set with key = 32";
    ret = SetParameter(key1, value1);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }

    char key2[] = "rw.sys.version.version.version.version";
    char value2[] = "set with key > 32";
    ret = SetParameter(key2, value2);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
500 501
 * @tc.number    : SUB_UTILS_PARAMETER_3300
 * @tc.name      : SetParameter parameter illegal test using key with uppercase
W
wenjun 已提交
502 503
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
504
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter009, Function | MediumTest | Level1)
W
wenjun 已提交
505 506 507 508 509 510 511 512 513 514 515 516 517
{
    int ret;

    char key[] = "Rw.Sys.Version.Version";
    char value[] = "set value with uppercase";
    ret = SetParameter(key, value);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
518 519
 * @tc.number    : SUB_UTILS_PARAMETER_3400
 * @tc.name      : SetParameter parameter illegal test using key with blank
W
wenjun 已提交
520 521
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
522
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter010, Function | MediumTest | Level1)
W
wenjun 已提交
523 524 525 526 527 528 529 530 531 532 533 534 535
{
    int ret;

    char key[] = "rw sys version version";
    char value[] = "set value with blank";
    ret = SetParameter(key, value);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
536 537
 * @tc.number    : SUB_UTILS_PARAMETER_3500
 * @tc.name      : SetParameter parameter illegal test using key with invalid special characters
W
wenjun 已提交
538 539
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
540
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter011, Function | MediumTest | Level1)
W
wenjun 已提交
541 542 543 544 545 546 547 548 549 550 551 552 553
{
    int ret;

    char key[] = "rw+sys&version%version*";
    char value[] = "set value with special characters";
    ret = SetParameter(key, value);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
554 555
 * @tc.number    : SUB_UTILS_PARAMETER_3600
 * @tc.name      : SetParameter parameter illegal test when value length is 128 or more than 128 bytes
W
wenjun 已提交
556 557
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
558
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter012, Function | MediumTest | Level1)
W
wenjun 已提交
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
{
    int ret;

    char key1[] = "rw.sys.version.version1";
    char value1[] = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890\
abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrst";
    ret = SetParameter(key1, value1);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }

    char key2[] = "rw.sys.version.version2";
    char value2[] = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890\
abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890";
    ret = SetParameter(key2, value2);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
582 583
 * @tc.number    : SUB_UTILS_PARAMETER_3700
 * @tc.name      : SetParameter parameter legal test when value contains only blanks
W
wenjun 已提交
584 585
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
586
LITE_TEST_CASE(ParameterFuncTestSuite, testSetParameter013, Function | MediumTest | Level1)
W
wenjun 已提交
587 588 589 590 591 592 593 594 595 596
{
    int ret;

    char key[] = "key_for_blank_value";
    char value[] = "                         ";
    ret = SetParameter(key, value);
    TEST_ASSERT_EQUAL_INT(0, ret);
};

/**
M
mamingshuai 已提交
597 598
 * @tc.number    : SUB_UTILS_PARAMETER_3800
 * @tc.name      : GetParameter parameter legal test
W
wenjun 已提交
599 600
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
601
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter001, Function | MediumTest | Level1)
W
wenjun 已提交
602 603 604 605
{
    int ret;

    char key[] = "rw.sys.version_606";
M
mamingshuai 已提交
606
    char rightVal[] = "OEM-10.1.0";
W
wenjun 已提交
607 608 609 610
    char value[MAX_LEN] = {0};
    SetParameter(key, rightVal);
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal), ret);
M
mamingshuai 已提交
611
    TEST_ASSERT_EQUAL_STRING(rightVal, value);
W
wenjun 已提交
612 613 614
};

/**
M
mamingshuai 已提交
615 616
 * @tc.number    : SUB_UTILS_PARAMETER_3900
 * @tc.name      : GetParameter parameter legal test with Special characters
W
wenjun 已提交
617 618
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
619
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter002, Function | MediumTest | Level1)
W
wenjun 已提交
620 621 622 623 624 625 626 627 628
{
    int ret;

    char key[] = "_._..__...___";
    char rightVal[] = "!@#¥%……&*()——+~《》?,。、“‘;:、12345767890";
    char value[MAX_LEN] = {0};
    SetParameter(key, rightVal);
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal), ret);
M
mamingshuai 已提交
629
    TEST_ASSERT_EQUAL_STRING(rightVal, value);
W
wenjun 已提交
630 631 632
};

/**
M
mamingshuai 已提交
633 634
 * @tc.number    : SUB_UTILS_PARAMETER_4000
 * @tc.name      : GetParameter parameter legal test using key with only lowercase
W
wenjun 已提交
635 636
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
637
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter003, Function | MediumTest | Level1)
W
wenjun 已提交
638 639 640 641 642 643 644 645 646
{
    int ret;

    char key[] = "keywithonlylowercase";
    char rightVal[] = "test key with only lowercase";
    char value[MAX_LEN] = {0};
    SetParameter(key, rightVal);
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal), ret);
M
mamingshuai 已提交
647
    TEST_ASSERT_EQUAL_STRING(rightVal, value);
W
wenjun 已提交
648 649 650
};

/**
M
mamingshuai 已提交
651 652
 * @tc.number    : SUB_UTILS_PARAMETER_4100
 * @tc.name      : GetParameter parameter legal test using key with only number
W
wenjun 已提交
653 654
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
655
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter004, Function | MediumTest | Level1)
W
wenjun 已提交
656 657 658 659 660 661 662 663 664
{
    int ret;

    char key[] = "202006060602";
    char rightVal[] = "test key with only number";
    char value[MAX_LEN] = {0};
    SetParameter(key, rightVal);
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal), ret);
M
mamingshuai 已提交
665
    TEST_ASSERT_EQUAL_STRING(rightVal, value);
W
wenjun 已提交
666 667 668
};

/**
M
mamingshuai 已提交
669 670
 * @tc.number    : SUB_UTILS_PARAMETER_4200
 * @tc.name      : GetParameter parameter legal test when defaut value point is nullptr
W
wenjun 已提交
671 672
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
673
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter005, Function | MediumTest | Level1)
W
wenjun 已提交
674 675 676 677
{
    int ret;

    char key[] = "rw.sys.version_606";
M
mamingshuai 已提交
678
    char rightVal[] = "OEM-10.1.0";
W
wenjun 已提交
679 680 681 682
    char value[MAX_LEN] = {0};
    SetParameter(key, rightVal);
    ret = GetParameter(key, NULL, value, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal), ret);
M
mamingshuai 已提交
683
    TEST_ASSERT_EQUAL_STRING(rightVal, value);
W
wenjun 已提交
684 685 686
};

/**
M
mamingshuai 已提交
687 688
 * @tc.number    : SUB_UTILS_PARAMETER_4300
 * @tc.name      : GetParameter parameter legal test when the key is not exist
W
wenjun 已提交
689 690
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
691
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter006, Function | MediumTest | Level1)
W
wenjun 已提交
692 693 694 695 696 697 698
{
    int ret;

    char key[] = "none.exist.key";
    char value[MAX_LEN] = {0};
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(g_defSysParam), ret);
M
mamingshuai 已提交
699
    TEST_ASSERT_EQUAL_STRING(g_defSysParam, value);
W
wenjun 已提交
700 701 702
};

/**
M
mamingshuai 已提交
703 704
 * @tc.number    : SUB_UTILS_PARAMETER_4400
 * @tc.name      : GetParameter parameter legal test using key and value with maximum length
W
wenjun 已提交
705 706
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
707
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter007, Function | MediumTest | Level1)
W
wenjun 已提交
708 709 710 711 712 713 714 715 716
{
    int ret;

    char key1[] = "rw.sys.version.version.version.";
    char rightVal1[] = "set with key = 31";
    char value1[MAX_LEN] = {0};
    SetParameter(key1, rightVal1);
    ret = GetParameter(key1, g_defSysParam, value1, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal1), ret);
M
mamingshuai 已提交
717
    TEST_ASSERT_EQUAL_STRING(rightVal1, value1);
W
wenjun 已提交
718 719 720 721 722 723 724 725

    char key2[] = "rw.sys.version.version";
    char rightVal2[] = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890\
abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrs";
    char value2[MAX_LEN] = {0};
    SetParameter(key2, rightVal2);
    ret = GetParameter(key2, g_defSysParam, value2, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal2), ret);
M
mamingshuai 已提交
726
    TEST_ASSERT_EQUAL_STRING(rightVal2, value2);
W
wenjun 已提交
727 728 729
};

/**
M
mamingshuai 已提交
730 731
 * @tc.number    : SUB_UTILS_PARAMETER_4500
 * @tc.name      : GetParameter parameter illegal test with invalid value length
W
wenjun 已提交
732 733
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
734
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter008, Function | MediumTest | Level1)
W
wenjun 已提交
735 736 737 738
{
    int ret;

    char key[] = "rw.sys.version_606";
M
mamingshuai 已提交
739
    char rightVal[] = "OEM-10.1.0";
W
wenjun 已提交
740 741 742 743 744 745 746 747 748 749
    char value[INVALID_LEN] = {0};
    SetParameter(key, rightVal);
    ret = GetParameter(key, g_defSysParam, value, INVALID_LEN);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
750 751
 * @tc.number    : SUB_UTILS_PARAMETER_4600
 * @tc.name      : GetParameter parameter illegal test when value point is nullptr
W
wenjun 已提交
752 753
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
754
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter009, Function | MediumTest | Level1)
W
wenjun 已提交
755 756 757 758
{
    int ret;

    char key[] = "rw.sys.version_606";
M
mamingshuai 已提交
759
    char rightVal[] = "OEM-10.1.0";
W
wenjun 已提交
760 761 762 763 764 765 766 767 768
    SetParameter(key, rightVal);
    ret = GetParameter(key, g_defSysParam, NULL, MAX_LEN);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
769 770
 * @tc.number    : SUB_UTILS_PARAMETER_4700
 * @tc.name      : GetParameter parameter illegal test when key is not exist and value len is invalid
W
wenjun 已提交
771 772
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
773
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter010, Function | MediumTest | Level1)
W
wenjun 已提交
774 775 776 777 778 779 780 781 782 783
{
    int ret;

    char key[] = "none.exist.key";
    char value[INVALID_LEN] = {0};
    ret = GetParameter(key, g_defSysParam, value, INVALID_LEN);
    TEST_ASSERT_EQUAL_INT(-1, ret);
};

/**
M
mamingshuai 已提交
784 785
 * @tc.number    : SUB_UTILS_PARAMETER_4800
 * @tc.name      : GetParameter parameter illegal test when key is not exist and defaut value point is nullptr
W
wenjun 已提交
786 787
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
788
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter011, Function | MediumTest | Level1)
W
wenjun 已提交
789 790 791 792 793 794 795 796 797 798
{
    int ret;

    char key[] = "none.exist.key";
    char value[MAX_LEN] = {0};
    ret = GetParameter(key, NULL, value, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(-1, ret);
};

/**
M
mamingshuai 已提交
799 800
 * @tc.number    : SUB_UTILS_PARAMETER_4900
 * @tc.name      : GetParameter parameter illegal test when key len is 32 bytes
W
wenjun 已提交
801 802
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
803
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter012, Function | MediumTest | Level1)
W
wenjun 已提交
804 805 806 807 808 809 810 811 812 813 814 815 816
{
    int ret;

    char key[] = "rw.sys.version.version.version.v";
    char value[MAX_LEN] = {0};
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
817 818
 * @tc.number    : SUB_UTILS_PARAMETER_5000
 * @tc.name      : GetParameter parameter illegal test when key len is more than 32 bytes
W
wenjun 已提交
819 820
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
821
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter013, Function | MediumTest | Level1)
W
wenjun 已提交
822 823 824 825 826 827 828 829 830 831 832 833 834
{
    int ret;

    char key[] = "rw.sys.version.version.version.version";
    char value[MAX_LEN] = {0};
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
835 836
 * @tc.number    : SUB_UTILS_PARAMETER_5100
 * @tc.name      : GetParameter parameter illegal test when key is nullptr
W
wenjun 已提交
837 838
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
839
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter014, Function | MediumTest | Level1)
W
wenjun 已提交
840 841 842 843 844 845 846 847 848 849 850 851
{
    int ret;

    char value[MAX_LEN] = {0};
    ret = GetParameter(NULL, g_defSysParam, value, MAX_LEN);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
852 853
 * @tc.number    : SUB_UTILS_PARAMETER_5200
 * @tc.name      : GetParameter parameter illegal test using key with uppercase
W
wenjun 已提交
854 855
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
856
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter015, Function | MediumTest | Level1)
W
wenjun 已提交
857 858 859 860 861 862 863 864 865 866 867 868 869
{
    int ret;

    char key[] = "Rw.Sys.Version.Version";
    char value[MAX_LEN] = {0};
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
870 871
 * @tc.number    : SUB_UTILS_PARAMETER_5300
 * @tc.name      : GetParameter parameter illegal test using key with blank
W
wenjun 已提交
872 873
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
874
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter016, Function | MediumTest | Level1)
W
wenjun 已提交
875 876 877 878 879 880 881 882 883 884 885 886 887
{
    int ret;

    char key[] = "rw sys version version";
    char value[MAX_LEN] = {0};
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
888 889
 * @tc.number    : SUB_UTILS_PARAMETER_5400
 * @tc.name      : GetParameter parameter illegal test using key with invalid special characters
W
wenjun 已提交
890 891
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
892
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter017, Function | MediumTest | Level1)
W
wenjun 已提交
893 894 895 896 897 898 899 900 901 902 903 904 905
{
    int ret;

    char key[] = "rw+sys&version%version*";
    char value[MAX_LEN] = {0};
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
906 907
 * @tc.number    : SUB_UTILS_PARAMETER_5500
 * @tc.name      : GetParameter parameter illegal test when key is NULL
W
wenjun 已提交
908 909
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
910
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter018, Function | MediumTest | Level1)
W
wenjun 已提交
911 912 913 914 915 916 917 918 919 920 921 922
{
    int ret;

    char value[MAX_LEN] = {0};
    ret = GetParameter("\0", g_defSysParam, value, MAX_LEN);
    if ((ret == COMMON_ERROR) || (ret == INVALID_PARAMETER))
    {
        TEST_ASSERT_EQUAL_INT(1, 1);
    }
};

/**
M
mamingshuai 已提交
923 924
 * @tc.number    : SUB_UTILS_PARAMETER_5600
 * @tc.name      : GetParameter parameter legal test when value contains only blanks
W
wenjun 已提交
925 926
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
927
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter019, Function | MediumTest | Level1)
W
wenjun 已提交
928 929 930 931 932 933 934 935 936
{
    int ret;

    char key[] = "key_for_blank_value";
    char rightVal[] = "                         ";
    char value[MAX_LEN] = {0};
    SetParameter(key, rightVal);
    ret = GetParameter(key, g_defSysParam, value, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal), ret);
M
mamingshuai 已提交
937
    TEST_ASSERT_EQUAL_STRING(rightVal, value);
W
wenjun 已提交
938 939 940
};

/**
M
mamingshuai 已提交
941
 * @tc.number    : SUB_UTILS_PARAMETER_5700
W
wenjun 已提交
942 943 944
 * @tc.name      : Update value of parameter legal test
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
945
LITE_TEST_CASE(ParameterFuncTestSuite, testGetParameter020, Function | MediumTest | Level1)
W
wenjun 已提交
946 947 948 949
{
    int ret;

    char key[] = "rw.sys.version_606";
M
mamingshuai 已提交
950
    char rightVal1[] = "OEM-10.1.0";
W
wenjun 已提交
951 952 953 954 955
    char value1[MAX_LEN] = {0};
    ret = SetParameter(key, rightVal1);
    TEST_ASSERT_EQUAL_INT(0, ret);
    ret = GetParameter(key, g_defSysParam, value1, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal1), ret);
M
mamingshuai 已提交
956
    TEST_ASSERT_EQUAL_STRING(rightVal1, value1);
W
wenjun 已提交
957

M
mamingshuai 已提交
958
    char rightVal2[] = "update the value of OEM-10.1.0";
W
wenjun 已提交
959 960 961 962 963
    char value2[MAX_LEN] = {0};
    ret = SetParameter(key, rightVal2);
    TEST_ASSERT_EQUAL_INT(0, ret);
    ret = GetParameter(key, g_defSysParam, value2, MAX_LEN);
    TEST_ASSERT_EQUAL_INT(strlen(rightVal2), ret);
M
mamingshuai 已提交
964
    TEST_ASSERT_EQUAL_STRING(rightVal2, value2);
W
wenjun 已提交
965 966 967
};

RUN_TEST_SUITE(ParameterFuncTestSuite);