• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <log.h>
17 #include <semaphore.h>
18 #include <string>
19 
20 #include "gtest/gtest.h"
21 #include "securec.h"
22 #include "bundle_info.h"
23 #include "bundle_manager.h"
24 #include "want.h"
25 
26 using namespace std;
27 using namespace testing::ext;
28 using namespace OHOS;
29 static bool g_installState = false;
30 static int g_errorCode = -1;
31 static sem_t g_sem;
32 static const int32_t WAIT_TIMEOUT = 60;
33 static string g_testPath;
34 
35 extern "C" {
HOS_SystemInit(void)36 void __attribute__((weak)) HOS_SystemInit(void){};
37 }
38 
39 /* callback */
TestBundleStateCallback(const uint8_t resultCode,const void * resultMessage)40 static void TestBundleStateCallback(const uint8_t resultCode, const void *resultMessage)
41 {
42     HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleStateCallback resultCode: %d", resultCode);
43     HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleStateCallback resultMessage: %s", (char *) resultMessage);
44     g_installState = (resultCode == 0);
45     g_errorCode = resultCode;
46     sem_post(&g_sem);
47 }
48 
49 /* *
50  * get current dir
51  * @return  string current file path of the test suits
52  */
GetCurDir()53 static string GetCurDir()
54 {
55     string filePath = "";
56     char *buffer;
57     if ((buffer = getcwd(NULL, 0)) == NULL) {
58         perror("get file path error");
59     } else {
60         printf("Current Dir: %s\r\n", buffer);
61         filePath = buffer;
62         free(buffer);
63     }
64     return filePath + "/";
65 }
66 
67 class BundleMgrTest : public testing::Test {
68 protected:
SetUpTestCase(void)69     static void SetUpTestCase(void)
70     {
71         printf("----------test case with BundleMgrTest start-------------\n");
72         HOS_SystemInit();
73         sem_init(&g_sem, 0, 0);
74         InstallParam installParam = { .installLocation = 1, .keepData = false };
75         g_testPath = GetCurDir();
76         string hapPath = g_testPath + "testjsdemo.hap";
77         Install(hapPath.c_str(), &installParam, TestBundleStateCallback);
78         sem_wait(&g_sem);
79         printf("callback installresult is %d \n", g_errorCode);
80         EXPECT_EQ(g_errorCode, 0);
81     }
TearDownTestCase(void)82     static void TearDownTestCase(void)
83     {
84         sem_init(&g_sem, 0, 0);
85         InstallParam installParam = { .installLocation = 1, .keepData = false };
86         Uninstall("com.openharmony.testjsdemo", &installParam, TestBundleStateCallback);
87         sem_wait(&g_sem);
88         printf("callback uninstallresult is %d \n", g_errorCode);
89         EXPECT_EQ(g_errorCode, 0);
90         printf("----------test case with BundleMgrTest end-------------\n");
91     }
92 };
93 
94 
95 /**
96  * @tc.number    : SUB_APPEXECFWK_BMS_API_0044
97  * @tc.name      : ClearAbilityInfo parameter illegal test
98  * @tc.desc      : [C- SOFTWARE -0200]
99  */
100 HWTEST_F(BundleMgrTest, testClearAbilityInfoIllegal, Function | MediumTest | Level2)
101 {
102     printf("------start testClearAbilityInfoIllegal------\n");
103     // abilityInfo is nullptr
104     AbilityInfo abilityInfo;
105     int32_t result = memset_s(&abilityInfo, sizeof(abilityInfo), 0, sizeof(abilityInfo));
106     EXPECT_EQ(result, 0);
107     abilityInfo.bundleName = (char*)"com.openharmony.testjsdemo";
108     printf("abilityInfo.bundleName is %s \n", abilityInfo.bundleName);
109     ClearAbilityInfo(nullptr);
110     EXPECT_STREQ(abilityInfo.bundleName, "com.openharmony.testjsdemo");
111     printf("------end testClearAbilityInfoIllegal------\n");
112 }
113 
114 /**
115  * @tc.number    : SUB_APPEXECFWK_BMS_API_0045
116  * @tc.name      : ClearAbilityInfo parameter legal test with bundle name
117  * @tc.desc      : [C- SOFTWARE -0200]
118  */
119 HWTEST_F(BundleMgrTest, testClearBundleInfoIllegal, Function | MediumTest | Level2)
120 {
121     printf("------start testClearBundleInfoIllegal------\n");
122     BundleInfo bundleInfo;
123     int32_t result = memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo));
124     EXPECT_EQ(result, 0);
125     bundleInfo.bundleName = (char*)"com.openharmony.testjsdemo";
126     printf("abilityInfo.bundleName is %s \n", bundleInfo.bundleName);
127     ClearBundleInfo(nullptr);
128     printf("abilityInfo.bundleName afterclear is %s \n", bundleInfo.bundleName);
129     EXPECT_STREQ(bundleInfo.bundleName, "com.openharmony.testjsdemo");
130     printf("------end testClearBundleInfoIllegal------\n");
131 }
132 
133 /**
134  * @tc.number    : SUB_APPEXECFWK_BMS_API_0046
135  * @tc.name      : ClearAbilityInfo parameter legal test with module info
136  * @tc.desc      : [C- SOFTWARE -0200]
137  */
138 HWTEST_F(BundleMgrTest, testClearModuleInfoIllegal, Function | MediumTest | Level1)
139 {
140     printf("------start testClearModuleInfoIllegal------\n");
141     ModuleInfo moduleInfo;
142     int32_t result = memset_s(&moduleInfo, sizeof(moduleInfo), 0, sizeof(moduleInfo));
143     EXPECT_EQ(result, 0);
144     moduleInfo.description = (char*)"test app";
145     moduleInfo.moduleType = (char*)"entry";
146     ClearModuleInfo(nullptr);
147     EXPECT_STREQ(moduleInfo.description, "test app");
148     EXPECT_STREQ(moduleInfo.moduleType, "entry");
149     printf("------end testClearModuleInfoIllegal------\n");
150 }
151 
152 /**
153  * @tc.number    : SUB_APPEXECFWK_AMS_API_0009
154  * @tc.name      : testAbilityMgrSetWantElement parameter legal test
155  * @tc.desc      : [C- SOFTWARE -0100]
156  */
157 HWTEST_F(BundleMgrTest, testSetElementAbilityName, Function | MediumTest | Level0)
158 {
159     printf("------start testSetElementAbilityName------\n");
160     Want want = { nullptr };
161     ElementName element = { nullptr };
162     SetElementAbilityName(&element, "SecondAbility");
163     SetWantElement(&want, element);
164     printf("element is %s \n", want.element->abilityName);
165     char aName[] = "SecondAbility";
166     printf("aName is %s \n", aName);
167     EXPECT_STREQ(want.element->abilityName, aName);
168     ClearElement(&element);
169     ClearWant(&want);
170     printf("------end testSetElementAbilityName------\n");
171 }
172 
173 /**
174  * @tc.number    : SUB_APPEXECFWK_AMS_API_0010
175  * @tc.name      : testSetElementAbilityName parameter illegal test
176  * @tc.desc      : [C- SOFTWARE -0100]
177  */
178 HWTEST_F(BundleMgrTest, testSetElementAbilityNameIllegal, Function | MediumTest | Level2)
179 {
180     printf("------start testSetElementAbilityNameIllegal------\n");
181     Want want = { nullptr };
182     ElementName element = { nullptr };
183     SetElementAbilityName(&element, nullptr);
184     SetWantElement(&want, element);
185     printf("AbilityName1 is %s \n", want.element->abilityName);
186     EXPECT_STREQ(want.element->abilityName, nullptr);
187     char aName[] = "";
188     SetElementAbilityName(&element, aName);
189     SetWantElement(&want, element);
190     printf("AbilityName2 is %s \n", want.element->abilityName);
191     EXPECT_STREQ(want.element->abilityName, "");
192     ClearElement(&element);
193     ClearWant(&want);
194     printf("------end testSetElementAbilityNameIllegal------\n");
195 }
196 
197 /**
198  * @tc.number    : SUB_APPEXECFWK_AMS_API_0007
199  * @tc.name      : testSetElementBundleName parameter legal test
200  * @tc.desc      : [C- SOFTWARE -0100]
201  */
202 HWTEST_F(BundleMgrTest, testSetElementBundleName, Function | MediumTest | Level0)
203 {
204     printf("------start testSetElementBundleName------\n");
205     Want want = { nullptr };
206     ElementName element = { nullptr };
207     SetElementBundleName(&element, "com.openharmony.testjsdemo");
208     SetWantElement(&want, element);
209     printf("element is %s \n", want.element->bundleName);
210     char bName[] = "com.openharmony.testjsdemo";
211     EXPECT_STREQ(want.element->bundleName, bName);
212     ClearElement(&element);
213     ClearWant(&want);
214     printf("------end testSetElementBundleName------\n");
215 }
216 
217 /**
218  * @tc.number    : SUB_APPEXECFWK_AMS_API_0008
219  * @tc.name      : testAbilityMgrSetWantElement parameter illegal test
220  * @tc.desc      : [C- SOFTWARE -0100]
221  */
222 HWTEST_F(BundleMgrTest, testSetElementBundleNameIllegal, Function | MediumTest | Level2)
223 {
224     printf("------start testSetElementBundleNameIllegal------\n");
225     Want want = { nullptr };
226     ElementName element = { nullptr };
227     SetElementBundleName(&element, "");
228     SetWantElement(&want, element);
229     printf("BundleName1 is %s \n", want.element->bundleName);
230     char bName[] = "";
231     EXPECT_STREQ(want.element->bundleName, bName);
232     SetElementBundleName(&element, nullptr);
233     SetWantElement(&want, element);
234     printf("BundleName2 is %s \n", want.element->bundleName);
235     EXPECT_STREQ(want.element->bundleName, nullptr);
236     ClearElement(&element);
237     ClearWant(&want);
238     printf("------end testSetElementBundleNameIllegal------\n");
239 }
240 
241 /**
242  * @tc.number    : SUB_APPEXECFWK_AMS_API_0005
243  * @tc.name      : testSetElementDeviceID parameter legal test
244  * @tc.desc      : [C- SOFTWARE -0100]
245  */
246 HWTEST_F(BundleMgrTest, testSetElementDeviceID, Function | MediumTest | Level0)
247 {
248     printf("------start testSetElementDeviceID------\n");
249     Want want = { nullptr };
250     ElementName element = { nullptr };
251     SetElementDeviceID(&element, "0001000");
252     SetWantElement(&want, element);
253     char dID[] = "0001000";
254     EXPECT_STREQ(want.element->deviceId, dID);
255     ClearElement(&element);
256     ClearWant(&want);
257     printf("------end testSetElementDeviceID------\n");
258 }
259 
260 /**
261  * @tc.number    : SUB_APPEXECFWK_AMS_API_0006
262  * @tc.name      : testSetElementDeviceID parameter illegal test
263  * @tc.desc      : [C- SOFTWARE -0100]
264  */
265 HWTEST_F(BundleMgrTest, testSetElementDeviceIDIllegal, Function | MediumTest | Level2)
266 {
267     printf("------start testSetElementDeviceIDIllegal------\n");
268     Want want = { nullptr };
269     ElementName element = { nullptr };
270     SetElementDeviceID(&element, "");
271     SetWantElement(&want, element);
272     char dID[] = "";
273     EXPECT_STREQ(want.element->deviceId, dID);
274     SetElementDeviceID(&element, nullptr);
275     SetWantElement(&want, element);
276     EXPECT_STREQ(want.element->deviceId, nullptr);
277     ClearElement(&element);
278     ClearWant(&want);
279     printf("------end testSetElementDeviceIDIllegal------\n");
280 }
281 
282 /**
283  * @tc.number    : SUB_APPEXECFWK_BMS_API_0007
284  * @tc.name      : Install parameter illegal test that callback is null
285  * @tc.desc      : [C- SOFTWARE -0200]
286  */
287 HWTEST_F(BundleMgrTest, testInstallWithNullptr, Function | MediumTest | Level2)
288 {
289     printf("------start testInstallWithNullptr------\n");
290     string hapPath = g_testPath + "testnative.hap";
291     InstallParam installParam = { .installLocation = 1, .keepData = false };
292     bool isInstallSuccess = Install(hapPath.c_str(), &installParam, nullptr);
293     EXPECT_FALSE(isInstallSuccess);
294     printf("install result is %d \n", isInstallSuccess);
295     printf("------end testInstallWithNullptr------\n");
296 }
297 
298 /**
299  * @tc.number    : SUB_APPEXECFWK_BMS_API_0004
300  * @tc.name      : Install parameter illegal test that path is null
301  * @tc.desc      : [C- SOFTWARE -0200]
302  */
303 HWTEST_F(BundleMgrTest, testInstallWithNullPath, Function | MediumTest | Level2)
304 {
305     printf("------start testInstallWithNullPath------\n");
306     InstallParam installParam = { .installLocation = 1, .keepData = false };
307     bool isInstallSuccess = Install(nullptr, &installParam, TestBundleStateCallback);
308     EXPECT_FALSE(isInstallSuccess);
309     printf("install result is %d \n", isInstallSuccess);
310     printf("------end testInstallWithNullPath------\n");
311 }
312 
313 /**
314  * @tc.number    : SUB_APPEXECFWK_BMS_API_0002
315  * @tc.name      : Install parameter illegal test that ErrorPath is wrong
316  * @tc.desc      : [C- SOFTWARE -0200]
317  */
318 HWTEST_F(BundleMgrTest, testInstallWithErrorPath, Function | MediumTest | Level2)
319 {
320     printf("------start testBundleMgrInstallWithErrorPath------\n");
321     string hapPath = "appexecfwk/nothishap.hap";
322     bool isInstallSuccess = false;
323     sem_init(&g_sem, 0, 0);
324     InstallParam installParam = { .installLocation = 1, .keepData = false };
325     bool installResult = Install(hapPath.c_str(), &installParam, TestBundleStateCallback);
326     sem_wait(&g_sem);
327     if (g_errorCode == 0) {
328         isInstallSuccess = true;
329     }else if (g_errorCode > 0) {
330         isInstallSuccess = false;
331         HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleMgrInstall failed,g_errorCode is: %d", g_errorCode);
332     }
333     EXPECT_FALSE(isInstallSuccess);
334     printf("install result is %d", installResult);
335     printf("------end testBundleMgrInstallWithErrorPath------\n");
336 }
337 
338 /**
339  * @tc.number    : SUB_APPEXECFWK_BMS_API_0001
340  * @tc.name      : Install parameter legal test
341  * @tc.desc      : [C- SOFTWARE -0200]
342  */
343 HWTEST_F(BundleMgrTest, testBundleMgrInstallright, Function | MediumTest | Level0)
344 {
345     printf("------start testBundleMgrInstallright------\n");
346     string hapPath = g_testPath + "testnative.hap";
347     bool isInstallSuccess = false;
348     sem_init(&g_sem, 0, 0);
349     InstallParam installParam = { .installLocation = 1, .keepData = false };
350     bool installResult = Install(hapPath.c_str(), &installParam, TestBundleStateCallback);
351     sem_wait(&g_sem);
352     if (g_errorCode == 0) {
353         isInstallSuccess = true;
354     }else if (g_errorCode > 0) {
355         isInstallSuccess = false;
356         HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleMgrInstall failed,g_errorCode is: %d", g_errorCode);
357     }
358     EXPECT_TRUE(isInstallSuccess);
359     printf("install result is %d \n", installResult);
360     printf("------end testBundleMgrInstallright------\n");
361 }
362 /**
363  * @tc.number    : SUB_APPEXECFWK_BMS_API_0003
364  * @tc.name      : Install parameter illegal test that Path is empty
365  * @tc.desc      : [C- SOFTWARE -0200]
366  */
367 HWTEST_F(BundleMgrTest, testBundleMgrInstallEmpty, Function | MediumTest | Level2)
368 {
369     printf("------start testBundleMgrInstallEmpty------\n");
370     string hapPath = "";
371     bool isInstallSuccess = false;
372     sem_init(&g_sem, 0, 0);
373     InstallParam installParam = { .installLocation = 1, .keepData = false };
374     bool installResult = Install(hapPath.c_str(), &installParam, TestBundleStateCallback);
375     sem_wait(&g_sem);
376     if (g_errorCode == 0) {
377         isInstallSuccess = true;
378     }else if (g_errorCode > 0) {
379         isInstallSuccess = false;
380         HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleMgrInstall failed,g_errorCode is: %d", g_errorCode);
381     }
382     EXPECT_FALSE(isInstallSuccess);
383     printf("install result is %d", installResult);
384     printf("------end testBundleMgrInstallEmpty------\n");
385 }
386 
387 /**
388  * @tc.number    : SUB_APPEXECFWK_BMS_API_0009
389  * @tc.name      : Install parameter illegal test that file is bin
390  * @tc.desc      : [C- SOFTWARE -0200]
391  */
392 HWTEST_F(BundleMgrTest, testBundleMgrInstallBin, Function | MediumTest | Level1)
393 {
394     printf("------start testBundleMgrInstallBin------\n");
395     string hapPath = g_testPath + "testdemo.bin";
396     bool isInstallSuccess = false;
397     sem_init(&g_sem, 0, 0);
398     InstallParam installParam = { .installLocation = 1, .keepData = false };
399     bool installResult = Install(hapPath.c_str(), &installParam, TestBundleStateCallback);
400     sem_wait(&g_sem);
401     if (g_errorCode == 0) {
402         isInstallSuccess = true;
403     }else if (g_errorCode > 0) {
404         isInstallSuccess = false;
405         HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleMgrInstall failed,g_errorCode is: %d", g_errorCode);
406     }
407     EXPECT_FALSE(isInstallSuccess);
408     printf("install result is %d", installResult);
409     printf("------end testBundleMgrInstallBin------\n");
410 }
411 
412 /**
413  * @tc.number    : SUB_APPEXECFWK_BMS_API_0008
414  * @tc.name      : Install parameter illegal test that hap is destroyed
415  * @tc.desc      : [C- SOFTWARE -0200]
416  */
417 HWTEST_F(BundleMgrTest, testBundleMgrInstallBadfile, Function | MediumTest | Level2)
418 {
419     printf("------start testBundleMgrInstallBadfile------\n");
420     string hapPath = g_testPath + "errpinjie.hap";
421     bool isInstallSuccess = false;
422     sem_init(&g_sem, 0, 0);
423     InstallParam installParam = { .installLocation = 1, .keepData = false };
424     bool installResult = Install(hapPath.c_str(), &installParam, TestBundleStateCallback);
425     sem_wait(&g_sem);
426     if (g_errorCode == 0) {
427         isInstallSuccess = true;
428     }else if (g_errorCode > 0) {
429         isInstallSuccess = false;
430         HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleMgrInstall failed,g_errorCode is: %d", g_errorCode);
431     }
432     EXPECT_FALSE(isInstallSuccess);
433     printf("install result is %d", installResult);
434     printf("------start testBundleMgrInstallBadfile------\n");
435 }
436 
437 /**
438  * @tc.number    : SUB_APPEXECFWK_BMS_API_0014
439  * @tc.name      : Uninstall parameter illegal test that callback is null
440  * @tc.desc      : [C- SOFTWARE -0200]
441  */
442 HWTEST_F(BundleMgrTest, testUninstallNullCallback, Function | MediumTest | Level2)
443 {
444     printf("------start testUninstallNullCallback------\n");
445     const char *bundleName = (char*)"com.openharmony.testdemo";
446     InstallParam installParam = { .installLocation = 1, .keepData = false };
447     bool isUninstallSuccess = Uninstall(bundleName, &installParam, nullptr);
448     EXPECT_FALSE(isUninstallSuccess);
449     printf("uninstall result is %d", isUninstallSuccess);
450     printf("------end testUninstallNullCallback------\n");
451 }
452 
453 /**
454  * @tc.number    : SUB_APPEXECFWK_BMS_API_0013
455  * @tc.name      : Uninstall parameter illegal test that bundleName is null
456  * @tc.desc      : [C- SOFTWARE -0200]
457  */
458 HWTEST_F(BundleMgrTest, testUninstallnullBundleName, Function | MediumTest | Level2)
459 {
460     printf("------start testUninstallnullBundleName------\n");
461     InstallParam installParam = { .installLocation = 1, .keepData = false };
462     bool isUninstallSuccess = Uninstall(nullptr, &installParam, TestBundleStateCallback);
463     EXPECT_FALSE(isUninstallSuccess);
464     printf("uninstall result is %d", isUninstallSuccess);
465     printf("------end testUninstallnullBundleName------\n");
466 }
467 
468 /**
469  * @tc.number    : SUB_APPEXECFWK_BMS_API_0010
470  * @tc.name      : Uninstall parameter legal test
471  * @tc.desc      : [C- SOFTWARE -0200]
472  */
473 HWTEST_F(BundleMgrTest, testUninstallright, Function | MediumTest | Level0)
474 {
475     printf("------start testUninstallright------\n");
476     string hapPath = g_testPath + "testnative.hap";
477     sem_init(&g_sem, 0, 0);
478     InstallParam installParam = { .installLocation = 1, .keepData = false };
479     bool installResult = Install(hapPath.c_str(), &installParam, TestBundleStateCallback);
480     sem_wait(&g_sem);
481     EXPECT_TRUE(installResult);
482     sleep(1);
483     const char *bundleName = (char*)"com.openharmony.testnative";
484     bool isUninstallSuccess = false;
485     sem_init(&g_sem, 0, 0);
486     bool uninstallState = Uninstall(bundleName, &installParam, TestBundleStateCallback);
487     sem_wait(&g_sem);
488     printf("uninstall result is %d", uninstallState);
489     if (g_installState) {
490         isUninstallSuccess = true;
491     }else if (g_errorCode > 0) {
492         isUninstallSuccess = false;
493         HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleMgrUninstall failed,g_errorCode is: %d", g_errorCode);
494     }
495     EXPECT_TRUE(uninstallState);
496     printf("uninstall result is %d", isUninstallSuccess);
497     printf("------end testUninstallright------\n");
498 }
499 
500 /**
501  * @tc.number    : SUB_APPEXECFWK_BMS_API_0011
502  * @tc.name      : Uninstall parameter illegal test that bundleName is wrong
503  * @tc.desc      : [C- SOFTWARE -0200]
504  */
505 HWTEST_F(BundleMgrTest, testUninstallErrorName, Function | MediumTest | Level2)
506 {
507     printf("------start testUninstallErrorName------\n");
508     const char *bundleName = (char*)"com.openharmony.nothisBundleName";
509     bool isUninstallSuccess = false;
510     sem_init(&g_sem, 0, 0);
511     InstallParam installParam = { .installLocation = 1, .keepData = false };
512     bool uninstallState = Uninstall(bundleName, &installParam, TestBundleStateCallback);
513     sem_wait(&g_sem);
514     printf("uninstall result is %d", uninstallState);
515     if (g_installState) {
516         isUninstallSuccess = true;
517     }else if (g_errorCode > 0) {
518         isUninstallSuccess = false;
519         HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleMgrUninstall failed,g_errorCode is: %d", g_errorCode);
520     }
521     EXPECT_FALSE(isUninstallSuccess);
522     printf("uninstall result is %d", isUninstallSuccess);
523     printf("------end testUninstallErrorName------\n");
524 }
525 
526 /**
527  * @tc.number    : SUB_APPEXECFWK_BMS_API_0012
528  * @tc.name      : Uninstall parameter illegal test that bundleName is empty
529  * @tc.desc      : [C- SOFTWARE -0200]
530  */
531 HWTEST_F(BundleMgrTest, testUninstallEmptyName, Function | MediumTest | Level2)
532 {
533     printf("------start testUninstallEmptyName------\n");
534     const char *bundleName = (char*)"";
535     bool isUninstallSuccess = false;
536     sem_init(&g_sem, 0, 0);
537     InstallParam installParam = { .installLocation = 1, .keepData = false };
538     bool uninstallState = Uninstall(bundleName, &installParam, TestBundleStateCallback);
539     sem_wait(&g_sem);
540     printf("uninstall resute is %d", uninstallState);
541     if (g_installState) {
542         isUninstallSuccess = true;
543     }else if (g_errorCode > 0) {
544         isUninstallSuccess = false;
545         HILOG_DEBUG(HILOG_MODULE_APP, "TestBundleMgrUninstall failed,g_errorCode is: %d", g_errorCode);
546     }
547     EXPECT_FALSE(isUninstallSuccess);
548     printf("uninstall result is %d", isUninstallSuccess);
549     printf("------end testUninstallEmptyName------\n");
550 }
551 
552 
553 /**
554  * @tc.number    : SUB_APPEXECFWK_BMS_API_0040
555  * @tc.name      : QueryAbilityInfo parameter legal test
556  * @tc.desc      : [C- SOFTWARE -0200]
557  */
558 HWTEST_F(BundleMgrTest, testQueryAbilityInfoRight, Function | MediumTest | Level1)
559 {
560     printf("------start testQueryAbilityInfoRight------\n");
561     Want want;
562     int32_t resultWant = memset_s(&want, sizeof(Want), 0, sizeof(Want));
563     EXPECT_EQ(resultWant, 0);
564     ElementName element;
565     int32_t resultElementName = memset_s(&element, sizeof(ElementName), 0, sizeof(ElementName));
566     EXPECT_EQ(resultElementName, 0);
567     SetElementAbilityName(&element, "MainAbility");
568     SetElementBundleName(&element, "com.openharmony.testjsdemo");
569     SetWantElement(&want, element);
570     SetWantData(&want, "test", 4);
571     AbilityInfo abilityInfo;
572     int32_t result = memset_s(&abilityInfo, sizeof(abilityInfo), 0, sizeof(abilityInfo));
573     EXPECT_EQ(result, 0);
574     printf("element.elementname is %s \n",  want.element->bundleName);
575     printf("AbilityName2 is %s \n", want.element->abilityName);
576     g_errorCode = QueryAbilityInfo(&want, &abilityInfo);
577     printf("abilityInfo.bundleName is %s \n", abilityInfo.bundleName);
578     printf("abilityInfo.label is %s \n", abilityInfo.label);
579     printf("abilityInfo.iconPath is %s \n", abilityInfo.iconPath);
580     printf("ret is %d \n", g_errorCode);
581     EXPECT_TRUE(g_errorCode == 0);
582     printf("------end testQueryAbilityInfoRight------\n");
583 }
584 /**
585  * @tc.number    : SUB_APPEXECFWK_BMS_API_0041
586  * @tc.name      : QueryAbilityInfo parameter illegal test
587  * @tc.desc      : [C- SOFTWARE -0200]
588  */
589 HWTEST_F(BundleMgrTest, testQueryAbilityInfoIllegal, Function | MediumTest | Level2)
590 {
591     printf("------start testQueryAbilityInfoIllegal------\n");
592     AbilityInfo abilityInfo;
593     int32_t result = memset_s(&abilityInfo, sizeof(AbilityInfo), 0, sizeof(AbilityInfo));
594     EXPECT_EQ(result, 0);
595     // want is nullptr
596     g_errorCode = QueryAbilityInfo(nullptr, &abilityInfo);
597     printf("ret is %d \n", g_errorCode);
598     EXPECT_TRUE(g_errorCode == 4);
599     // abilityInfo is nullptr
600     Want want;
601     int32_t resultWant = memset_s(&want, sizeof(Want), 0, sizeof(Want));
602     EXPECT_EQ(resultWant, 0);
603     ElementName element;
604     int32_t resultElementName = memset_s(&element, sizeof(ElementName), 0, sizeof(ElementName));
605     EXPECT_EQ(resultElementName, 0);
606     SetElementAbilityName(&element, "MainAbility");
607     SetElementBundleName(&element, "com.openharmony.testjsdemo");
608     SetWantElement(&want, element);
609     SetWantData(&want, "test", 4);
610     g_errorCode = QueryAbilityInfo(&want, nullptr);
611     printf("ret is %d \n", g_errorCode);
612     EXPECT_TRUE(g_errorCode == 4);
613     // content of want is ""
614     Want want1 = { nullptr };
615     ElementName element1 = { nullptr };
616     SetElementBundleName(&element1, "");
617     SetElementAbilityName(&element1, "");
618     SetWantElement(&want1, element1);
619     AbilityInfo abilityInfo1;
620     g_errorCode = QueryAbilityInfo(&want1, &abilityInfo1);
621     printf("abilityInfo is null \n");
622     printf("ret is %d \n", g_errorCode);
623     EXPECT_TRUE(g_errorCode == 2);
624     printf("------end testQueryAbilityInfoIllegal------\n");
625 }
626 
627 /**
628  * @tc.number    : SUB_APPEXECFWK_BMS_API_0029
629  * @tc.name      : GetBundleInfo parameter legal test.
630  * @tc.desc      : [C- SOFTWARE -0200]
631  */
632 HWTEST_F(BundleMgrTest, testGetBundleInfoRight, Function | MediumTest | Level1)
633 {
634     printf("------start testGetBundleInfoRight------\n");
635     BundleInfo bundleInfo;
636     int32_t result = memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo));
637     EXPECT_EQ(result, 0);
638     const char *bundleName = (char*)"com.openharmony.testjsdemo";
639     int32_t flags = 0;
640     printf("bundleName is %s \n", bundleName);
641     sleep(2);
642     g_errorCode = GetBundleInfo(bundleName, flags, &bundleInfo);
643     printf("getBundleInfo result is %d \n", g_errorCode);
644     EXPECT_STREQ(bundleInfo.bundleName, bundleName);
645     EXPECT_EQ(bundleInfo.numOfAbility, 0);
646     EXPECT_EQ(g_errorCode, 0);
647     flags = 1;
648     printf("bundleName is %s \n", bundleName);
649     g_errorCode = GetBundleInfo(bundleName, flags, &bundleInfo);
650     sleep(2);
651     printf("getBundleInfo result is %d \n", g_errorCode);
652     EXPECT_EQ(g_errorCode, 0);
653     EXPECT_STREQ(bundleInfo.bundleName, bundleName);
654     EXPECT_EQ(bundleInfo.numOfAbility, 3);
655     ClearBundleInfo(&bundleInfo);
656     printf("------end testGetBundleInfoRight------\n");
657 }
658 
659 /**
660  * @tc.number    : SUB_APPEXECFWK_BMS_API_0030
661  * @tc.name      : GetBundleInfo parameter illegal test.
662  * @tc.desc      : [C- SOFTWARE -0200]
663  */
664 HWTEST_F(BundleMgrTest, testGetBundleInfoIllegal, Function | MediumTest | Level2)
665 {
666     printf("------start testGetBundleInfoIllegal------\n");
667     BundleInfo bundleInfo;
668     int32_t result = memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo));
669     EXPECT_EQ(result, 0);
670     const char *bundleName = (char*)"com.openharmony.nothishap";
671     int32_t flags = 0;
672     // error bundleName
673     g_errorCode = GetBundleInfo(bundleName, flags, &bundleInfo);
674     printf("bundleInfo1.bundleName is %s \n", bundleInfo.bundleName);
675     printf("bundleInfo1.versionCode is %d \n", bundleInfo.versionCode);
676     printf("bundleInfo1.codePath is %s \n", bundleInfo.codePath);
677     EXPECT_EQ(g_errorCode, 2);
678     // bundleName = nullptr
679     g_errorCode = GetBundleInfo(nullptr, flags, &bundleInfo);
680     printf("abilityInfo2 is %d \n", g_errorCode);
681     EXPECT_TRUE(g_errorCode == 4);
682     printf("bundleInfo2.bundleName is %s \n", bundleInfo.bundleName);
683     printf("bundleInfo2.versionCode is %d \n", bundleInfo.versionCode);
684     printf("bundleInfo2.codePath is %s \n", bundleInfo.codePath);
685     // bunldeName = ""
686     g_errorCode = GetBundleInfo("", flags, &bundleInfo);
687     printf("bundleInfo3.bundleName is %s \n", bundleInfo.bundleName);
688     printf("bundleInfo3.versionCode is %d \n", bundleInfo.versionCode);
689     printf("bundleInfo3.codePath is %s \n", bundleInfo.codePath);
690     EXPECT_TRUE(g_errorCode == 2);
691     // flags not exit
692     g_errorCode = GetBundleInfo("com.openharmony.testjsdemo", 2, &bundleInfo);
693     sleep(2);
694     printf("bundleInfo3.bundleName is %s \n", bundleInfo.bundleName);
695     printf("bundleInfo3.versionCode is %d \n", bundleInfo.versionCode);
696     printf("bundleInfo3.codePath is %s \n", bundleInfo.codePath);
697     EXPECT_EQ(g_errorCode, 1);
698     printf("------end testGetBundleInfoIllegal------\n");
699 }
700 
701 /**
702  * @tc.number    : SUB_APPEXECFWK_BMS_API_0042
703  * @tc.name      : GetBundleInfos parameter legal test
704  * @tc.desc      : [C- SOFTWARE -0200]
705  */
706 HWTEST_F(BundleMgrTest, testGetBundleInfosRight, Function | MediumTest | Level1)
707 {
708     printf("------start testGetBundleInfosRight------\n");
709     BundleInfo *bundleInfos = nullptr;
710     int32_t flags = 0;
711     int32_t length = 0;
712     g_errorCode = GetBundleInfos(flags, &bundleInfos, &length);
713     sleep(2);
714     printf("getBundleInfo result is %d \n", g_errorCode);
715     EXPECT_EQ(g_errorCode, 0);
716     if (g_errorCode == 0){
717         printf("bundleInfos.codePath is %s \n", bundleInfos[0].codePath);
718         printf("bundleInfos.bundleName is %s \n", bundleInfos[0].bundleName);
719         printf("bundleInfos.versionCode is %d \n", bundleInfos[0].versionCode);
720     }
721     flags = 1;
722     g_errorCode = GetBundleInfos(flags, &bundleInfos, &length);
723     printf("getBundleInfo result is %d \n", g_errorCode);
724     sleep(2);
725     EXPECT_EQ(g_errorCode, 0);
726         if (g_errorCode == 0){
727         printf("bundleInfos.codePath is %s \n", bundleInfos[0].codePath);
728         printf("bundleInfos.bundleName is %s \n", bundleInfos[0].bundleName);
729         printf("bundleInfos.versionCode is %d \n", bundleInfos[0].versionCode);
730     }
731     free(bundleInfos);
732     printf("------end testGetBundleInfosRight------\n");
733 }
734 
735 /**
736  * @tc.number    : SUB_APPEXECFWK_BMS_API_0043
737  * @tc.name      : GetBundleInfos parameter illegal test
738  * @tc.desc      : [C- SOFTWARE -0200]
739  */
740 HWTEST_F(BundleMgrTest, testGetBundleInfosIllegal, Function | MediumTest | Level2)
741 {
742     printf("------start testGetBundleInfosIllegal------\n");
743     BundleInfo *bundleInfos = {nullptr};
744     int32_t *length = nullptr;
745     int32_t flags = 0;
746     g_errorCode = GetBundleInfos(flags, nullptr, length);
747     EXPECT_EQ(g_errorCode, 4);
748     g_errorCode = GetBundleInfos(flags, &bundleInfos, nullptr);
749     printf("g_errorCode is %d \n", g_errorCode);
750     EXPECT_TRUE(g_errorCode == 4);
751     g_errorCode = GetBundleInfos(2, &bundleInfos, length);
752     printf("g_errorCode is %d \n", g_errorCode);
753     EXPECT_EQ(g_errorCode, 4);
754     printf("------end testGetBundleInfosIllegal------\n");
755 }
756 
757 /**
758  * @tc.number    : SUB_APPEXECFWK_BMS_API_0039
759  * @tc.name      : GetBundleInfosByMetaData parameter illegal test
760  * @tc.desc      : [C- SOFTWARE -0200]
761  */
762 HWTEST_F(BundleMgrTest, testGetBundleInfosByMetaDataIllegal, Function | MediumTest | Level2)
763 {
764     printf("------start testGetBundleInfosByMetaDataIllegal------\n");
765     BundleInfo *bundleInfos = {nullptr};
766     int32_t length = 0;
767     const char *metaDataKey = "appId";
768     g_errorCode = GetBundleInfosByMetaData(nullptr, &bundleInfos, &length);
769     EXPECT_EQ(g_errorCode, 4);
770     g_errorCode = GetBundleInfosByMetaData(metaDataKey, &bundleInfos, nullptr);
771     printf("g_errorCode is %d \n", g_errorCode);
772     EXPECT_TRUE(g_errorCode == 4);
773     g_errorCode = GetBundleInfosByMetaData(metaDataKey, nullptr, &length);
774     printf("g_errorCode is %d \n", g_errorCode);
775     EXPECT_TRUE(g_errorCode == 4);
776     const char *metaDataKey1 = "noThisKey";
777     printf("metaDataKey is %s \n", metaDataKey1);
778     g_errorCode = GetBundleInfosByMetaData(metaDataKey1, &bundleInfos, &length);
779     printf("GetBundleInfosByMetaData result is %d \n", g_errorCode);
780     EXPECT_EQ(g_errorCode, 2);
781     const char *metaDataKey2 = "";
782     g_errorCode = GetBundleInfosByMetaData(metaDataKey2, &bundleInfos, &length);
783     printf("GetBundleInfosByMetaData result is %d \n", g_errorCode);
784     EXPECT_EQ(g_errorCode, 2);
785     printf("------end testGetBundleInfosByMetaDataIllegal------\n");
786 }
787 
788 /**
789  * @tc.number    : SUB_APPEXECFWK_BMS_API_0038
790  * @tc.name      : GetBundleInfosByMetaData parameter legal test
791  * @tc.desc      : [C- SOFTWARE -0200]
792  */
793 HWTEST_F(BundleMgrTest, testGetBundleInfosByMetaDataRight, Function | MediumTest | Level1)
794 {
795     printf("------start testGetBundleInfosByMetaDataRight------\n");
796     BundleInfo *bundleInfos = nullptr;
797     const char *metaDataKey = "appId";
798     int32_t length = 0;
799     printf("metaDataKey is %s \n", metaDataKey);
800     g_errorCode = GetBundleInfosByMetaData(metaDataKey, &bundleInfos, &length);
801     sleep(2);
802     printf("GetBundleInfosByMetaData result is %d \n", g_errorCode);
803     EXPECT_EQ(g_errorCode, 0);
804     if (g_errorCode == 0){
805         printf("bundleInfos.bundleName is %s \n", bundleInfos[0].bundleName);
806     }
807     printf("------end testGetBundleInfosByMetaDataRight------\n");
808 }
809 
810 /**
811  * @tc.number    : SUB_APPEXECFWK_BMS_API_0037
812  * @tc.name      : QueryKeepAliveBundleInfos parameter illegal test
813  * @tc.desc      : [C- SOFTWARE -0200]
814  */
815 HWTEST_F(BundleMgrTest, testQueryKeepAliveBundleInfosIllegal, Function | MediumTest | Level2)
816 {
817     printf("------start testQueryKeepAliveBundleInfosIllegal------\n");
818     BundleInfo *bundleInfos = {nullptr};
819     int32_t length = 0;
820     g_errorCode = QueryKeepAliveBundleInfos(nullptr, &length);
821     printf("g_errorCode1 is %d \n", g_errorCode);
822     EXPECT_EQ(g_errorCode, 4);
823     g_errorCode = QueryKeepAliveBundleInfos(&bundleInfos, nullptr);
824     printf("g_errorCode2 is %d \n", g_errorCode);
825     EXPECT_TRUE(g_errorCode == 4);
826     printf("------end testQueryKeepAliveBundleInfosIllegal------\n");
827 }
828 
829 /**
830  * @tc.number    : SUB_APPEXECFWK_BMS_API_0034
831  * @tc.name      : GetBundleNameForUid parameter nullptr test
832  * @tc.desc      : [C- SOFTWARE -0200]
833  */
834 HWTEST_F(BundleMgrTest, testGetBundleNameForUidWithNullptr, Function | MediumTest | Level2)
835 {
836     printf("------start testGetBundleNameForUidWithNullptr------\n");
837     int32_t resultCode = GetBundleNameForUid(0, nullptr);
838     EXPECT_EQ(resultCode, 4);
839     printf("GetBundleNameForUid result is %d \n", resultCode);
840     printf("------end testGetBundleNameForUidWithNullptr------\n");
841 }
842 
843 /**
844  * @tc.number    : SUB_APPEXECFWK_BMS_API_0035
845  * @tc.name      : GetBundleNameForUid parameter illegal test
846  * @tc.desc      : [C- SOFTWARE -0200]
847  */
848 HWTEST_F(BundleMgrTest, testGetBundleNameForUidWithIllegal, Function | MediumTest | Level2)
849 {
850     printf("------start testGetBundleNameForUidWithIllegal------\n");
851     char *bundleName = nullptr;
852     int32_t resultCode = GetBundleNameForUid(0, &bundleName);
853     EXPECT_EQ(resultCode, 114);
854     printf("GetBundleNameForUid result is %d \n", resultCode);
855     if (bundleName != nullptr) {
856         free(bundleName);
857     }
858     printf("------end testGetBundleNameForUidWithIllegal------\n");
859 }
860 
861 /**
862  * @tc.number    : SUB_APPEXECFWK_BMS_SIZE_0001
863  * @tc.name      : Test the GetBundleSize of the thirld hap can be obtained normally
864  * @tc.desc      : [C- SOFTWARE -0200]
865  */
866 HWTEST_F(BundleMgrTest, testGetBundleSizeWithLegal_0001, Function | MediumTest | Level1)
867 {
868     printf("------start testGetBundleSizeWithLegal_0001------\n");
869     char *bundleName = (char*)"com.openharmony.testjsdemo";
870     uint32_t resultCode = GetBundleSize(bundleName);
871     EXPECT_GT(resultCode, 0);
872     printf("------end testGetBundleSizeWithLegal_0001------\n");
873 }
874 
875 /**
876  * @tc.number    : SUB_APPEXECFWK_BMS_SIZE_0002
877  * @tc.name      : GetBundleSize parameter legal and bundleName length equal to 127 test
878  * @tc.desc      : [C- SOFTWARE -0200]
879  */
880 HWTEST_F(BundleMgrTest, testGetBundleSizeWithLegal_0002, Function | MediumTest | Level1)
881 {
882     printf("------start testGetBundleSizeWithLegal_0002------\n");
883     char *bundleName = (char*)"com.openharmony.testjsdemoBundleNameleng" \
884 "thequalto127testjsdemoBundleNamelengthequalto127testjsdemoBundleNamelengthequalto127tes";
885     sem_init(&g_sem, 0, 0);
886     InstallParam installParam = {.installLocation = 1,.keepData = false };
887     string hapPath = g_testPath + "testGetBundleNameWithLegal127.hap";
888     Install(hapPath.c_str(), &installParam, TestBundleStateCallback);
889     sem_wait(&g_sem);
890     uint32_t resultCode = GetBundleSize(bundleName);
891     EXPECT_EQ(strlen(bundleName), 127);
892     EXPECT_GT(resultCode, 0);
893     // uninstall
894     sem_init(&g_sem, 0, 0);
895     Uninstall(bundleName, &installParam, TestBundleStateCallback);
896     sem_wait(&g_sem);
897     printf("------end testGetBundleSizeWithLegal_0002------\n");
898 }
899 
900 /**
901  * @tc.number    : SUB_APPEXECFWK_BMS_SIZE_0003
902  * @tc.name      : GetBundleSize parameter illegal and bundleName length equal to 128 test
903  * @tc.desc      : [C- SOFTWARE -0200]
904  */
905 HWTEST_F(BundleMgrTest, testGetBundleSizeWithIllegal_0001, Function | MediumTest | Level2)
906 {
907     printf("------start testGetBundleSizeWithIllegal_0001------\n");
908     char *bundleName = (char*)"com.openharmony.testjsdemoBundleNameLength128test" \
909 "jsdemoBundleNameLength128testjsdemoBundleNameLength128testjsdemoBundleNameLengt";
910     EXPECT_EQ(strlen(bundleName), 128);
911     uint32_t resultCode = GetBundleSize(bundleName);
912     EXPECT_EQ(resultCode, 0);
913     printf("------end testGetBundleSizeWithIllegal_0001------\n");
914 }
915 
916 /**
917  * @tc.number    : SUB_APPEXECFWK_BMS_SIZE_0004
918  * @tc.name      : GetBundleSize parameter illegal and bundleName nullptr test
919  * @tc.desc      : [C- SOFTWARE -0200]
920  */
921 HWTEST_F(BundleMgrTest, testGetBundleSizeWithIllegal_0002, Function | MediumTest | Level2)
922 {
923     printf("------start testGetBundleSizeWithIllegal_0002------\n");
924     char *bundleName = nullptr;
925     // bundleName nullptr
926     uint32_t resultCode = GetBundleSize(bundleName);
927     EXPECT_EQ(resultCode, 0);
928     printf("------end testGetBundleSizeWithIllegal_0002------\n");
929 }
930 
931 /**
932  * @tc.number    : SUB_APPEXECFWK_BMS_SIZE_0005
933  * @tc.name      : GetBundleSize parameter illegal and bundleName error test
934  * @tc.desc      : [C- SOFTWARE -0200]
935  */
936 HWTEST_F(BundleMgrTest, testGetBundleSizeWithIllegal_0003, Function | MediumTest | Level2)
937 {
938     printf("------start testGetBundleSizeWithIllegal_0003------\n");
939     char *bundleName = (char*)"com.openharmony.nothishap";
940     // error bundleName
941     uint32_t resultCode = GetBundleSize(bundleName);
942     EXPECT_EQ(resultCode, 0);
943     printf("------end testGetBundleSizeWithIllegal_0003------\n");
944 }
945 
946 /**
947  * @tc.number    : SUB_APPEXECFWK_BMS_SIZE_0006
948  * @tc.name      : GetBundleSize parameter illegal and bundleName " " test
949  * @tc.desc      : [C- SOFTWARE -0200]
950  */
951 HWTEST_F(BundleMgrTest, testGetBundleSizeWithIllegal_0004, Function | MediumTest | Level2)
952 {
953     printf("------start testGetBundleSizeWithIllegal_0004------\n");
954     char *bundleName = (char*)" ";
955     // bundleName " "
956     uint32_t resultCode = GetBundleSize(bundleName);
957     EXPECT_EQ(resultCode, 0);
958     printf("------end testGetBundleSizeWithIllegal_0004------\n");
959 }
960 
961 /**
962  * @tc.number    : SUB_APPEXECFWK_BMS_SIZE_0007
963  * @tc.name      : stress test of the same application
964  * @tc.desc      : [C- SOFTWARE -0200]
965  */
966 HWTEST_F(BundleMgrTest, testStressConfig_0001, Function | MediumTest | Level2)
967 {
968     printf("------start testStressConfig_0001------\n");
969     char *bundleName = (char*)"com.openharmony.testjsdemo";
970     for (int i = 1; i <= 100; i++) {
971         uint32_t resultCode = GetBundleSize(bundleName);
972         EXPECT_GT(resultCode, 0);
973     }
974     printf("------end testStressConfig_0001------\n");
975 }
976 
977 /**
978  * @tc.number    : SUB_APPEXECFWK_BMS_SIZE_0008
979  * @tc.name      : stress test of the difference application
980  * @tc.desc      : [C- SOFTWARE -0200]
981  */
982 HWTEST_F(BundleMgrTest, testStressConfig_0002, Function | MediumTest | Level2)
983 {
984     printf("------start testStressConfig_0002------\n");
985     char *bundleName = (char*)"com.openharmony.testjsdemo";
986     char *bundleName2 = (char*)"com.openharmony.testjsdemoBtestjsdemoB";
987     sem_init(&g_sem, 0, 0);
988     InstallParam installParam = {.installLocation = 1,.keepData = false };
989     string hapPath = g_testPath + "frequentlyStress.hap";
990     Install(hapPath.c_str(), &installParam, TestBundleStateCallback);
991     sem_wait(&g_sem);
992     for (int i = 1; i <= 100; i++) {
993         uint32_t resultCode = GetBundleSize(bundleName);
994         EXPECT_GT(resultCode, 0);
995         resultCode = GetBundleSize(bundleName2);
996         EXPECT_GT(resultCode, 0);
997     }
998     // uninstall
999     sem_init(&g_sem, 0, 0);
1000     Uninstall(bundleName2, &installParam, TestBundleStateCallback);
1001     sem_wait(&g_sem);
1002     printf("------end testStressConfig_0002------\n");
1003 }