From 89750a38c3d284b14912fc0905a805117eb1152f Mon Sep 17 00:00:00 2001 From: shilei Date: Thu, 24 Nov 2022 00:27:48 +0800 Subject: [PATCH] add Signed-off-by: shilei Change-Id: Idcf824e9ff08cd9baf033c684b67b91f7f5b4bcf --- appexecfwk_lite/appexecfwk_hal/BUILD.gn | 2 ++ .../appexecfwk_hal/src/bundle_mgr_test.c | 21 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/appexecfwk_lite/appexecfwk_hal/BUILD.gn b/appexecfwk_lite/appexecfwk_hal/BUILD.gn index 1beb35d63..9f3fbee93 100755 --- a/appexecfwk_lite/appexecfwk_hal/BUILD.gn +++ b/appexecfwk_lite/appexecfwk_hal/BUILD.gn @@ -20,6 +20,8 @@ hctest_suite("ActsBundleMgrTest") { "${aafwk_lite_path}/interfaces/kits/want_lite", "${appexecfwk_lite_path}/interfaces/kits/bundle_lite/slite", "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", + "${appexecfwk_lite_path}/utils/bundle_lite", + "//commonlibrary/utils_lite/memory/include", ] cflags = [ "-Wno-error" ] } diff --git a/appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c b/appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c index 02a86ea7e..01c289d27 100755 --- a/appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c +++ b/appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c @@ -16,12 +16,15 @@ #include #include +#include "adapter.h" #include "hctest.h" #include "securec.h" #include "bundle_info.h" #include "bundle_manager.h" #include "want.h" +#define nullptr NULL + /** * @brief register a test suit named BundleMgrTestSuite * @param subsystem name is appexecfwk @@ -55,7 +58,7 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoLegal, Function | MediumT TEST_ASSERT_TRUE(result == 0); char *name = "com.openharmony.testjsdemo"; size_t len = strlen(name); - abilityInfo.bundleName = (char *)malloc(len + 1); + abilityInfo.bundleName = (char *)(AdapterMalloc(len + 1)); TEST_ASSERT_NOT_NULL(abilityInfo.bundleName); errno_t err = strncpy_s(abilityInfo.bundleName, len + 1, name, len); TEST_ASSERT_EQUAL(err, EOK); @@ -78,13 +81,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoIllegal, Function | Mediu TEST_ASSERT_TRUE(result == 0); char *name = "com.openharmony.testjsdemo"; size_t len = strlen(name); - abilityInfo.bundleName = (char *)malloc(len + 1); + abilityInfo.bundleName = (char *)(AdapterMalloc(len + 1)); TEST_ASSERT_NOT_NULL(abilityInfo.bundleName); errno_t err = strncpy_s(abilityInfo.bundleName, len + 1, name, len); TEST_ASSERT_EQUAL(err, EOK); ClearAbilityInfo(NULL); TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, name); - free(abilityInfo.bundleName); + AdapterFree(abilityInfo.bundleName); printf("------end testClearAbilityInfoIllegal------\n"); } @@ -101,7 +104,7 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoLegal, Function | MediumTe TEST_ASSERT_TRUE(result == 0); char *name = "com.openharmony.testjsdemo"; size_t len = strlen(name); - bundleInfo.bundleName = (char *)malloc(len + 1); + bundleInfo.bundleName = (char *)(AdapterMalloc(len + 1)); TEST_ASSERT_NOT_NULL(bundleInfo.bundleName); errno_t err = strncpy_s(bundleInfo.bundleName, len + 1, name, len); TEST_ASSERT_EQUAL(err, EOK); @@ -124,13 +127,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoIllegal, Function | Medium TEST_ASSERT_TRUE(result == 0); char *name = "com.openharmony.testjsdemo"; size_t len = strlen(name); - bundleInfo.bundleName = (char *)malloc(len + 1); + bundleInfo.bundleName = (char *)(AdapterMalloc(len + 1)); TEST_ASSERT_NOT_NULL(bundleInfo.bundleName); errno_t err = strncpy_s(bundleInfo.bundleName, len + 1, name, len); TEST_ASSERT_EQUAL(err, EOK); ClearBundleInfo(NULL); TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, name); - free(bundleInfo.bundleName); + AdapterFree(bundleInfo.bundleName); printf("------end testClearBundleInfoIllegal------\n"); } @@ -147,7 +150,7 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoLegal, Function | MediumTe TEST_ASSERT_TRUE(result == 0); char *name = "test"; size_t len = strlen(name); - moduleInfo.moduleName = (char *)malloc(len + 1); + moduleInfo.moduleName = (char *)(AdapterMalloc(len + 1)); TEST_ASSERT_NOT_NULL(moduleInfo.moduleName); errno_t err = strncpy_s(moduleInfo.moduleName, len + 1, name, len); TEST_ASSERT_EQUAL(err, EOK); @@ -170,13 +173,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoIllegal, Function | Medium TEST_ASSERT_TRUE(result == 0); char *name = "test"; size_t len = strlen(name); - moduleInfo.moduleName = (char *)malloc(len + 1); + moduleInfo.moduleName = (char *)(AdapterMalloc(len + 1)); TEST_ASSERT_NOT_NULL(moduleInfo.moduleName); errno_t err = strncpy_s(moduleInfo.moduleName, len + 1, name, len); TEST_ASSERT_EQUAL(err, EOK); ClearModuleInfo(NULL); TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, name); - free(moduleInfo.moduleName); + AdapterFree(moduleInfo.moduleName); printf("------end testClearModuleInfoIllegal------\n"); } -- GitLab