1 /*
2 * Copyright (c) 2020-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
16 #include <securec.h>
17 #include "hctest.h"
18 #include "ohos_types.h"
19 #include "parameter.h"
20 #include "parameter_utils.h"
21
22 #define QUERY_TIMES 50
23
24 /**
25 * @tc.desc : register a test suite, this suite is used to test basic flow
26 * and interface dependency
27 * @param : subsystem name is utils
28 * @param : module name is parameter
29 * @param : test suit name is ParameterReliTestSuite
30 */
31 LITE_TEST_SUIT(utils, parameter, ParameterReliTestSuite);
32
33 /**
34 * @tc.setup : setup for all testcases
35 * @return : setup result, TRUE is success, FALSE is fail
36 */
ParameterReliTestSuiteSetUp(void)37 static BOOL ParameterReliTestSuiteSetUp(void)
38 {
39 return TRUE;
40 }
41
42 /**
43 * @tc.teardown : teardown for all testcases
44 * @return : teardown result, TRUE is success, FALSE is fail
45 */
ParameterReliTestSuiteTearDown(void)46 static BOOL ParameterReliTestSuiteTearDown(void)
47 {
48 printf("+-------------------------------------------+\n");
49 return TRUE;
50 }
51
52 /**
53 * @tc.number : SUB_UTILS_PARAMETER_5800
54 * @tc.name : Obtaining ProductType for multiple times
55 * @tc.desc : [C- SOFTWARE -0200]
56 */
57 LITE_TEST_CASE(ParameterReliTestSuite,
58 testObtainSysParaReli001,
59 Function | MediumTest | Level1) {
60 const char* value1 = GetDeviceType();
61 AssertNotEmpty(value1);
62 for (int i = 0; i < QUERY_TIMES; i++) {
63 const char* value = GetDeviceType();
64 }
65 const char* value2 = GetDeviceType();
66 TEST_ASSERT_EQUAL_STRING(value1, value2);
67 };
68
69 /**
70 * @tc.number : SUB_UTILS_PARAMETER_5900
71 * @tc.name : Obtaining Manufacture for multiple times
72 * @tc.desc : [C- SOFTWARE -0200]
73 */
74 LITE_TEST_CASE(ParameterReliTestSuite,
75 testObtainSysParaReli002,
76 Function | MediumTest | Level1) {
77 const char* value1 = GetManufacture();
78 AssertNotEmpty(value1);
79 for (int i = 0; i < QUERY_TIMES; i++) {
80 const char* value = GetManufacture();
81 }
82 const char* value2 = GetManufacture();
83 TEST_ASSERT_EQUAL_STRING(value1, value2);
84 };
85
86 /**
87 * @tc.number : SUB_UTILS_PARAMETER_6000
88 * @tc.name : Obtaining Brand for multiple times
89 * @tc.desc : [C- SOFTWARE -0200]
90 */
91 LITE_TEST_CASE(ParameterReliTestSuite,
92 testObtainSysParaReli003,
93 Function | MediumTest | Level1) {
94 const char* value1 = GetBrand();
95 AssertNotEmpty(value1);
96 for (int i = 0; i < QUERY_TIMES; i++) {
97 const char* value = GetBrand();
98 }
99 const char* value2 = GetBrand();
100 TEST_ASSERT_EQUAL_STRING(value1, value2);
101 };
102
103 /**
104 * @tc.number : SUB_UTILS_PARAMETER_6100
105 * @tc.name : Obtaining MarketName for multiple times
106 * @tc.desc : [C- SOFTWARE -0200]
107 */
108 LITE_TEST_CASE(ParameterReliTestSuite,
109 testObtainSysParaReli004,
110 Function | MediumTest | Level1) {
111 const char* value1 = GetMarketName();
112 AssertNotEmpty(value1);
113 for (int i = 0; i < QUERY_TIMES; i++) {
114 const char* value = GetMarketName();
115 }
116 const char* value2 = GetMarketName();
117 TEST_ASSERT_EQUAL_STRING(value1, value2);
118 };
119
120 /**
121 * @tc.number : SUB_UTILS_PARAMETER_6200
122 * @tc.name : Obtaining ProductSeries for multiple times
123 * @tc.desc : [C- SOFTWARE -0200]
124 */
125 LITE_TEST_CASE(ParameterReliTestSuite,
126 testObtainSysParaReli005,
127 Function | MediumTest | Level1) {
128 const char* value1 = GetProductSeries();
129 AssertNotEmpty(value1);
130 for (int i = 0; i < QUERY_TIMES; i++) {
131 const char* value = GetProductSeries();
132 }
133 const char* value2 = GetProductSeries();
134 TEST_ASSERT_EQUAL_STRING(value1, value2);
135 };
136
137 /**
138 * @tc.number : SUB_UTILS_PARAMETER_6300
139 * @tc.name : Obtaining ProductModel for multiple times
140 * @tc.desc : [C- SOFTWARE -0200]
141 */
142 LITE_TEST_CASE(ParameterReliTestSuite,
143 testObtainSysParaReli006,
144 Function | MediumTest | Level1) {
145 const char* value1 = GetProductModel();
146 AssertNotEmpty(value1);
147 for (int i = 0; i < QUERY_TIMES; i++) {
148 const char* value = GetProductModel();
149 }
150 const char* value2 = GetProductModel();
151 TEST_ASSERT_EQUAL_STRING(value1, value2);
152 };
153
154 /**
155 * @tc.number : SUB_UTILS_PARAMETER_6400
156 * @tc.name : Obtaining HardwareModel for multiple times
157 * @tc.desc : [C- SOFTWARE -0200]
158 */
159 LITE_TEST_CASE(ParameterReliTestSuite,
160 testObtainSysParaReli007,
161 Function | MediumTest | Level1) {
162 const char* value1 = GetHardwareModel();
163 AssertNotEmpty(value1);
164 for (int i = 0; i < QUERY_TIMES; i++) {
165 const char* value = GetHardwareModel();
166 }
167 const char* value2 = GetHardwareModel();
168 TEST_ASSERT_EQUAL_STRING(value1, value2);
169 };
170
171 /**
172 * @tc.number : SUB_UTILS_PARAMETER_6500
173 * @tc.name : Obtaining HardwareProfile for multiple times
174 * @tc.desc : [C- SOFTWARE -0200]
175 */
176 LITE_TEST_CASE(ParameterReliTestSuite,
177 testObtainSysParaReli008,
178 Function | MediumTest | Level1) {
179 const char* value1 = GetHardwareProfile();
180 AssertNotEmpty(value1);
181 for (int i = 0; i < QUERY_TIMES; i++) {
182 const char* value = GetHardwareProfile();
183 }
184 const char* value2 = GetHardwareProfile();
185 TEST_ASSERT_EQUAL_STRING(value1, value2);
186 };
187
188 /**
189 * @tc.number : SUB_UTILS_PARAMETER_6600
190 * @tc.name : Obtaining Serial for multiple times
191 * @tc.desc : [C- SOFTWARE -0200]
192 */
193 LITE_TEST_CASE(ParameterReliTestSuite,
194 testObtainSysParaReli009,
195 Function | MediumTest | Level1) {
196 const char* value1 = GetSerial();
197 if (value1 == NULL) {
198 printf("The serial number needs to be written\n");
199 TEST_IGNORE();
200 }
201 for (int i = 0; i < QUERY_TIMES; i++) {
202 const char* value = GetSerial();
203 }
204 const char* value2 = GetSerial();
205 TEST_ASSERT_EQUAL_STRING(value1, value2);
206 };
207
208 /**
209 * @tc.number : SUB_UTILS_PARAMETER_6700
210 * @tc.name : Obtaining OsName for multiple times
211 * @tc.desc : [C- SOFTWARE -0200]
212 */
213 LITE_TEST_CASE(ParameterReliTestSuite,
214 testObtainSysParaReli010,
215 Function | MediumTest | Level1) {
216 const char* value1 = GetOSFullName();
217 AssertNotEmpty(value1);
218 for (int i = 0; i < QUERY_TIMES; i++) {
219 const char* value = GetOSFullName();
220 }
221 const char* value2 = GetOSFullName();
222 TEST_ASSERT_EQUAL_STRING(value1, value2);
223 };
224
225 /**
226 * @tc.number : SUB_UTILS_PARAMETER_6800
227 * @tc.name : Obtaining DisplayVersion for multiple times
228 * @tc.desc : [C- SOFTWARE -0200]
229 */
230 LITE_TEST_CASE(ParameterReliTestSuite,
231 testObtainSysParaReli011,
232 Function | MediumTest | Level1) {
233 const char* value1 = GetDisplayVersion();
234 AssertNotEmpty(value1);
235 for (int i = 0; i < QUERY_TIMES; i++) {
236 const char* value = GetDisplayVersion();
237 }
238 const char* value2 = GetDisplayVersion();
239 TEST_ASSERT_EQUAL_STRING(value1, value2);
240 };
241
242 /**
243 * @tc.number : SUB_UTILS_PARAMETER_6900
244 * @tc.name : Obtaining BootloaderVersion for multiple times
245 * @tc.desc : [C- SOFTWARE -0200]
246 */
247 LITE_TEST_CASE(ParameterReliTestSuite,
248 testObtainSysParaReli012,
249 Function | MediumTest | Level1) {
250 const char* value1 = GetBootloaderVersion();
251 AssertNotEmpty(value1);
252 for (int i = 0; i < QUERY_TIMES; i++) {
253 const char* value = GetBootloaderVersion();
254 }
255 const char* value2 = GetBootloaderVersion();
256 TEST_ASSERT_EQUAL_STRING(value1, value2);
257 };
258
259 /**
260 * @tc.number : SUB_UTILS_PARAMETER_7000
261 * @tc.name : Obtaining SecurityPatchTag for multiple times
262 * @tc.desc : [C- SOFTWARE -0200]
263 */
264 LITE_TEST_CASE(ParameterReliTestSuite,
265 testObtainSysParaReli013,
266 Function | MediumTest | Level1) {
267 const char* value1 = GetSecurityPatchTag();
268 AssertNotEmpty(value1);
269 for (int i = 0; i < QUERY_TIMES; i++) {
270 const char* value = GetSecurityPatchTag();
271 }
272 const char* value2 = GetSecurityPatchTag();
273 TEST_ASSERT_EQUAL_STRING(value1, value2);
274 };
275
276 /**
277 * @tc.number : SUB_UTILS_PARAMETER_7100
278 * @tc.name : Obtaining AbiList for multiple times
279 * @tc.desc : [C- SOFTWARE -0200]
280 */
281 LITE_TEST_CASE(ParameterReliTestSuite,
282 testObtainSysParaReli014,
283 Function | MediumTest | Level1) {
284 const char* value1 = GetAbiList();
285 AssertNotEmpty(value1);
286 for (int i = 0; i < QUERY_TIMES; i++) {
287 const char* value = GetAbiList();
288 }
289 const char* value2 = GetAbiList();
290 TEST_ASSERT_EQUAL_STRING(value1, value2);
291 };
292
293 /**
294 * @tc.number : SUB_UTILS_PARAMETER_7200
295 * @tc.name : Obtaining FirstApiLevel for multiple times
296 * @tc.desc : [C- SOFTWARE -0200]
297 */
298 LITE_TEST_CASE(ParameterReliTestSuite,
299 testObtainSysParaReli015,
300 Function | MediumTest | Level1) {
301 int value1 = GetFirstApiVersion();
302 TEST_ASSERT_NOT_NULL(&value1);
303 TEST_ASSERT_TRUE((int)value1 == value1);
304 for (int i = 0; i < QUERY_TIMES; i++) {
305 int value = GetFirstApiVersion();
306 }
307 int value2 = GetFirstApiVersion();
308 TEST_ASSERT_EQUAL_INT(value1, value2);
309 };
310
311 /**
312 * @tc.number : SUB_UTILS_PARAMETER_7300
313 * @tc.name : Obtaining IncrementalVersion for multiple times
314 * @tc.desc : [C- SOFTWARE -0200]
315 */
316 LITE_TEST_CASE(ParameterReliTestSuite,
317 testObtainSysParaReli016,
318 Function | MediumTest | Level1) {
319 const char* value1 = GetIncrementalVersion();
320 AssertNotEmpty(value1);
321 for (int i = 0; i < QUERY_TIMES; i++) {
322 const char* value = GetIncrementalVersion();
323 }
324 const char* value2 = GetIncrementalVersion();
325 TEST_ASSERT_EQUAL_STRING(value1, value2);
326 };
327
328 /**
329 * @tc.number : SUB_UTILS_PARAMETER_7400
330 * @tc.name : Obtaining VersionId for multiple times
331 * @tc.desc : [C- SOFTWARE -0200]
332 */
333 LITE_TEST_CASE(ParameterReliTestSuite,
334 testObtainSysParaReli017,
335 Function | MediumTest | Level1) {
336 const char* value1 = GetVersionId();
337 AssertNotEmpty(value1);
338 for (int i = 0; i < QUERY_TIMES; i++) {
339 const char* value = GetVersionId();
340 }
341 const char* value2 = GetVersionId();
342 TEST_ASSERT_EQUAL_STRING(value1, value2);
343 };
344
345 /**
346 * @tc.number : SUB_UTILS_PARAMETER_7500
347 * @tc.name : Obtaining BuildType for multiple times
348 * @tc.desc : [C- SOFTWARE -0200]
349 */
350 LITE_TEST_CASE(ParameterReliTestSuite,
351 testObtainSysParaReli018,
352 Function | MediumTest | Level1) {
353 const char* value1 = GetBuildType();
354 AssertNotEmpty(value1);
355 for (int i = 0; i < QUERY_TIMES; i++) {
356 const char* value = GetBuildType();
357 }
358 const char* value2 = GetBuildType();
359 TEST_ASSERT_EQUAL_STRING(value1, value2);
360 };
361
362 /**
363 * @tc.number : SUB_UTILS_PARAMETER_7600
364 * @tc.name : Obtaining BuildUser for multiple times
365 * @tc.desc : [C- SOFTWARE -0200]
366 */
367 LITE_TEST_CASE(ParameterReliTestSuite,
368 testObtainSysParaReli019,
369 Function | MediumTest | Level1) {
370 const char* value1 = GetBuildUser();
371 AssertNotEmpty(value1);
372 for (int i = 0; i < QUERY_TIMES; i++) {
373 const char* value = GetBuildUser();
374 }
375 const char* value2 = GetBuildUser();
376 TEST_ASSERT_EQUAL_STRING(value1, value2);
377 };
378
379 /**
380 * @tc.number : SUB_UTILS_PARAMETER_7700
381 * @tc.name : Obtaining BuildHost for multiple times
382 * @tc.desc : [C- SOFTWARE -0200]
383 */
384 LITE_TEST_CASE(ParameterReliTestSuite,
385 testObtainSysParaReli020,
386 Function | MediumTest | Level1) {
387 const char* value1 = GetBuildHost();
388 AssertNotEmpty(value1);
389 for (int i = 0; i < QUERY_TIMES; i++) {
390 const char* value = GetBuildHost();
391 }
392 const char* value2 = GetBuildHost();
393 TEST_ASSERT_EQUAL_STRING(value1, value2);
394 };
395
396 /**
397 * @tc.number : SUB_UTILS_PARAMETER_7800
398 * @tc.name : Obtaining BuildTime for multiple times
399 * @tc.desc : [C- SOFTWARE -0200]
400 */
401 LITE_TEST_CASE(ParameterReliTestSuite,
402 testObtainSysParaReli021,
403 Function | MediumTest | Level1) {
404 const char* value1 = GetBuildTime();
405 AssertNotEmpty(value1);
406 for (int i = 0; i < QUERY_TIMES; i++) {
407 const char* value = GetBuildTime();
408 }
409 const char* value2 = GetBuildTime();
410 TEST_ASSERT_EQUAL_STRING(value1, value2);
411 };
412
413 /**
414 * @tc.number : SUB_UTILS_PARAMETER_7900
415 * @tc.name : Obtaining BuildRootHash for multiple times
416 * @tc.desc : [C- SOFTWARE -0200]
417 */
418 LITE_TEST_CASE(ParameterReliTestSuite,
419 testObtainSysParaReli022,
420 Function | MediumTest | Level1) {
421 const char* value1 = GetBuildRootHash();
422 TEST_ASSERT_NOT_NULL(value1);
423 for (int i = 0; i < QUERY_TIMES; i++) {
424 const char* value = GetBuildRootHash();
425 }
426 const char* value2 = GetBuildRootHash();
427 TEST_ASSERT_EQUAL_STRING(value1, value2);
428 };
429
430 /**
431 * @tc.number : SUB_UTILS_PARAMETER_8000
432 * @tc.name : Obtaining SoftwareModel for multiple times
433 * @tc.desc : [C- SOFTWARE -0200]
434 */
435 LITE_TEST_CASE(ParameterReliTestSuite,
436 testObtainSysParaReli023,
437 Function | MediumTest | Level1) {
438 const char* value1 = GetSoftwareModel();
439 AssertNotEmpty(value1);
440 for (int i = 0; i < QUERY_TIMES; i++) {
441 const char* value = GetSoftwareModel();
442 }
443 const char* value2 = GetSoftwareModel();
444 TEST_ASSERT_EQUAL_STRING(value1, value2);
445 };
446
447 /**
448 * @tc.number : SUB_UTILS_PARAMETER_8100
449 * @tc.name : Obtaining SdkApiLevel for multiple times
450 * @tc.desc : [C- SOFTWARE -0200]
451 */
452 LITE_TEST_CASE(ParameterReliTestSuite,
453 testObtainSysParaReli024,
454 Function | MediumTest | Level1) {
455 int value1 = GetSdkApiVersion();
456 TEST_ASSERT_NOT_NULL(&value1);
457 TEST_ASSERT_TRUE((int)value1 == value1);
458 for (int i = 0; i < QUERY_TIMES; i++) {
459 int value = GetSdkApiVersion();
460 }
461 int value2 = GetSdkApiVersion();
462 TEST_ASSERT_EQUAL_INT(value1, value2);
463 };
464
465 RUN_TEST_SUITE(ParameterReliTestSuite);
466