parameter_reli_test.c 14.2 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
#include <securec.h>
#include "hctest.h"
#include "parameter.h"
#include "parameter_utils.h"

#define QUERY_TIMES    50

/**
 * @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 ParameterReliTestSuite
 */
LITE_TEST_SUIT(utils, parameter, ParameterReliTestSuite);

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

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

/**
M
mamingshuai 已提交
52 53
 * @tc.number    : SUB_UTILS_PARAMETER_5800
 * @tc.name      : Obtaining ProductType for multiple times
W
wenjun 已提交
54 55
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
56
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli001, Function | MediumTest | Level1)
W
wenjun 已提交
57 58 59 60 61 62 63 64 65
{
    char* value1 = GetProductType();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetProductType();
    free(value);
    }
    char* value2 = GetProductType();
M
mamingshuai 已提交
66
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
67 68 69 70 71
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
72 73
 * @tc.number    : SUB_UTILS_PARAMETER_5900
 * @tc.name      : Obtaining Manufacture for multiple times
W
wenjun 已提交
74 75
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
76
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli002, Function | MediumTest | Level1)
W
wenjun 已提交
77 78 79 80 81 82 83 84 85
{
    char* value1 = GetManufacture();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetManufacture();
    free(value);
    }
    char* value2 = GetManufacture();
M
mamingshuai 已提交
86
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
87 88 89 90 91
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
92 93
 * @tc.number    : SUB_UTILS_PARAMETER_6000
 * @tc.name      : Obtaining Brand for multiple times
W
wenjun 已提交
94 95
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
96
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli003, Function | MediumTest | Level1)
W
wenjun 已提交
97 98 99 100 101 102 103 104 105
{
    char* value1 = GetBrand();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetBrand();
    free(value);
    }
    char* value2 = GetBrand();
M
mamingshuai 已提交
106
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
107 108 109 110 111
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
112 113
 * @tc.number    : SUB_UTILS_PARAMETER_6100
 * @tc.name      : Obtaining MarketName for multiple times
W
wenjun 已提交
114 115
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
116
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli004, Function | MediumTest | Level1)
W
wenjun 已提交
117 118 119 120 121 122 123 124 125
{
    char* value1 = GetMarketName();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetMarketName();
    free(value);
    }
    char* value2 = GetMarketName();
M
mamingshuai 已提交
126
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
127 128 129 130 131
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
132 133
 * @tc.number    : SUB_UTILS_PARAMETER_6200
 * @tc.name      : Obtaining ProductSeries for multiple times
W
wenjun 已提交
134 135
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
136
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli005, Function | MediumTest | Level1)
W
wenjun 已提交
137 138 139 140 141 142 143 144 145
{
    char* value1 = GetProductSeries();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetProductSeries();
    free(value);
    }
    char* value2 = GetProductSeries();
M
mamingshuai 已提交
146
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
147 148 149 150 151
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
152 153
 * @tc.number    : SUB_UTILS_PARAMETER_6300
 * @tc.name      : Obtaining ProductModel for multiple times
W
wenjun 已提交
154 155
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
156
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli006, Function | MediumTest | Level1)
W
wenjun 已提交
157 158 159 160 161 162 163 164 165
{
    char* value1 = GetProductModel();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetProductModel();
    free(value);
    }
    char* value2 = GetProductModel();
M
mamingshuai 已提交
166
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
167 168 169 170 171
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
172 173
 * @tc.number    : SUB_UTILS_PARAMETER_6400
 * @tc.name      : Obtaining HardwareModel for multiple times
W
wenjun 已提交
174 175
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
176
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli007, Function | MediumTest | Level1)
W
wenjun 已提交
177 178 179 180 181 182 183 184 185
{
    char* value1 = GetHardwareModel();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetHardwareModel();
    free(value);
    }
    char* value2 = GetHardwareModel();
M
mamingshuai 已提交
186
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
187 188 189 190 191
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
192 193
 * @tc.number    : SUB_UTILS_PARAMETER_6500
 * @tc.name      : Obtaining HardwareProfile for multiple times
W
wenjun 已提交
194 195
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
196
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli008, Function | MediumTest | Level1)
W
wenjun 已提交
197 198 199 200 201 202 203 204 205
{
    char* value1 = GetHardwareProfile();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetHardwareProfile();
    free(value);
    }
    char* value2 = GetHardwareProfile();
M
mamingshuai 已提交
206
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
207 208 209 210 211
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
212 213
 * @tc.number    : SUB_UTILS_PARAMETER_6600
 * @tc.name      : Obtaining Serial for multiple times
W
wenjun 已提交
214 215
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
216
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli009, Function | MediumTest | Level1)
W
wenjun 已提交
217 218 219 220 221
{
    char* value1 = GetSerial();
    if (value1 == NULL) {
        printf("The serial number needs to be written\n");
        TEST_IGNORE();
M
mamingshuai 已提交
222
    }
W
wenjun 已提交
223 224 225 226 227 228
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetSerial();
    free(value);
    }
    char* value2 = GetSerial();
M
mamingshuai 已提交
229
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
230 231 232 233 234
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
235 236
 * @tc.number    : SUB_UTILS_PARAMETER_6700
 * @tc.name      : Obtaining OsName for multiple times
W
wenjun 已提交
237 238
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
239
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli010, Function | MediumTest | Level1)
W
wenjun 已提交
240 241 242 243 244 245 246 247 248
{
    char* value1 = GetOsName();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetOsName();
    free(value);
    }
    char* value2 = GetOsName();
M
mamingshuai 已提交
249
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
250 251 252 253 254
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
255 256
 * @tc.number    : SUB_UTILS_PARAMETER_6800
 * @tc.name      : Obtaining DisplayVersion for multiple times
W
wenjun 已提交
257 258
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
259
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli011, Function | MediumTest | Level1)
W
wenjun 已提交
260 261 262 263 264 265 266 267 268
{
    char* value1 = GetDisplayVersion();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetDisplayVersion();
    free(value);
    }
    char* value2 = GetDisplayVersion();
M
mamingshuai 已提交
269
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
270 271 272 273 274
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
275 276
 * @tc.number    : SUB_UTILS_PARAMETER_6900
 * @tc.name      : Obtaining BootloaderVersion for multiple times
W
wenjun 已提交
277 278
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
279
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli012, Function | MediumTest | Level1)
W
wenjun 已提交
280 281 282 283 284 285 286 287 288
{
    char* value1 = GetBootloaderVersion();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetBootloaderVersion();
    free(value);
    }
    char* value2 = GetBootloaderVersion();
M
mamingshuai 已提交
289
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
290 291 292 293 294
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
295 296
 * @tc.number    : SUB_UTILS_PARAMETER_7000
 * @tc.name      : Obtaining SecurityPatchTag for multiple times
W
wenjun 已提交
297 298
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
299
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli013, Function | MediumTest | Level1)
W
wenjun 已提交
300 301 302 303 304 305 306 307 308
{
    char* value1 = GetSecurityPatchTag();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetSecurityPatchTag();
    free(value);
    }
    char* value2 = GetSecurityPatchTag();
M
mamingshuai 已提交
309
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
310 311 312 313 314
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
315 316
 * @tc.number    : SUB_UTILS_PARAMETER_7100
 * @tc.name      : Obtaining AbiList for multiple times
W
wenjun 已提交
317 318
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
319
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli014, Function | MediumTest | Level1)
W
wenjun 已提交
320 321 322 323 324 325 326 327 328
{
    char* value1 = GetAbiList();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetAbiList();
    free(value);
    }
    char* value2 = GetAbiList();
M
mamingshuai 已提交
329
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
330 331 332 333 334
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
335 336
 * @tc.number    : SUB_UTILS_PARAMETER_7200
 * @tc.name      : Obtaining FirstApiLevel for multiple times
W
wenjun 已提交
337 338
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
339
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli015, Function | MediumTest | Level1)
W
wenjun 已提交
340 341 342 343 344 345 346 347 348
{
    char* value1 = GetFirstApiLevel();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetFirstApiLevel();
    free(value);
    }
    char* value2 = GetFirstApiLevel();
M
mamingshuai 已提交
349
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
350 351 352 353 354
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
355 356
 * @tc.number    : SUB_UTILS_PARAMETER_7300
 * @tc.name      : Obtaining IncrementalVersion for multiple times
W
wenjun 已提交
357 358
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
359
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli016, Function | MediumTest | Level1)
W
wenjun 已提交
360 361 362 363 364 365 366 367 368
{
    char* value1 = GetIncrementalVersion();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetIncrementalVersion();
    free(value);
    }
    char* value2 = GetIncrementalVersion();
M
mamingshuai 已提交
369
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
370 371 372 373 374
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
375 376
 * @tc.number    : SUB_UTILS_PARAMETER_7400
 * @tc.name      : Obtaining VersionId for multiple times
W
wenjun 已提交
377 378
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
379
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli017, Function | MediumTest | Level1)
W
wenjun 已提交
380 381 382 383 384 385 386 387 388
{
    char* value1 = GetVersionId();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetVersionId();
    free(value);
    }
    char* value2 = GetVersionId();
M
mamingshuai 已提交
389
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
390 391 392 393 394
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
395 396
 * @tc.number    : SUB_UTILS_PARAMETER_7500
 * @tc.name      : Obtaining BuildType for multiple times
W
wenjun 已提交
397 398
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
399
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli018, Function | MediumTest | Level1)
W
wenjun 已提交
400 401 402 403 404 405 406 407 408
{
    char* value1 = GetBuildType();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetBuildType();
    free(value);
    }
    char* value2 = GetBuildType();
M
mamingshuai 已提交
409
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
410 411 412 413 414
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
415 416
 * @tc.number    : SUB_UTILS_PARAMETER_7600
 * @tc.name      : Obtaining BuildUser for multiple times
W
wenjun 已提交
417 418
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
419
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli019, Function | MediumTest | Level1)
W
wenjun 已提交
420 421 422 423 424 425 426 427 428
{
    char* value1 = GetBuildUser();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetBuildUser();
    free(value);
    }
    char* value2 = GetBuildUser();
M
mamingshuai 已提交
429
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
430 431 432 433 434
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
435 436
 * @tc.number    : SUB_UTILS_PARAMETER_7700
 * @tc.name      : Obtaining BuildHost for multiple times
W
wenjun 已提交
437 438
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
439
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli020, Function | MediumTest | Level1)
W
wenjun 已提交
440 441 442 443 444 445 446 447 448
{
    char* value1 = GetBuildHost();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetBuildHost();
    free(value);
    }
    char* value2 = GetBuildHost();
M
mamingshuai 已提交
449
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
450 451 452 453 454
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
455 456
 * @tc.number    : SUB_UTILS_PARAMETER_7800
 * @tc.name      : Obtaining BuildTime for multiple times
W
wenjun 已提交
457 458
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
459
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli021, Function | MediumTest | Level1)
W
wenjun 已提交
460 461 462 463 464 465 466 467 468
{
    char* value1 = GetBuildTime();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetBuildTime();
    free(value);
    }
    char* value2 = GetBuildTime();
M
mamingshuai 已提交
469
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
470 471 472 473 474
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
475 476
 * @tc.number    : SUB_UTILS_PARAMETER_7900
 * @tc.name      : Obtaining BuildRootHash for multiple times
W
wenjun 已提交
477 478
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
479
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli022, Function | MediumTest | Level1)
W
wenjun 已提交
480 481 482 483 484 485 486 487 488
{
    char* value1 = GetBuildRootHash();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetBuildRootHash();
    free(value);
    }
    char* value2 = GetBuildRootHash();
M
mamingshuai 已提交
489
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
490 491 492 493 494
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
495 496
 * @tc.number    : SUB_UTILS_PARAMETER_8000
 * @tc.name      : Obtaining SoftwareModel for multiple times
W
wenjun 已提交
497 498
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
499
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli023, Function | MediumTest | Level1)
W
wenjun 已提交
500 501 502 503 504 505 506 507 508
{
    char* value1 = GetSoftwareModel();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetSoftwareModel();
    free(value);
    }
    char* value2 = GetSoftwareModel();
M
mamingshuai 已提交
509
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
510 511 512 513 514
    free(value1);
    free(value2);
};

/**
M
mamingshuai 已提交
515 516
 * @tc.number    : SUB_UTILS_PARAMETER_8100
 * @tc.name      : Obtaining SdkApiLevel for multiple times
W
wenjun 已提交
517 518
 * @tc.desc      : [C- SOFTWARE -0200]
 */
M
mamingshuai 已提交
519
LITE_TEST_CASE(ParameterReliTestSuite, testObtainSysParaReli024, Function | MediumTest | Level1)
W
wenjun 已提交
520 521 522 523 524 525 526 527 528
{
    char* value1 = GetSdkApiLevel();
    IsEmpty(value1);
    for (int i = 0; i < QUERY_TIMES; i++)
    {
    char* value = GetSdkApiLevel();
    free(value);
    }
    char* value2 = GetSdkApiLevel();
M
mamingshuai 已提交
529
    TEST_ASSERT_EQUAL_STRING(value1, value2);
W
wenjun 已提交
530 531 532 533 534
    free(value1);
    free(value2);
};

RUN_TEST_SUITE(ParameterReliTestSuite);