From 4008c1089c7adccb9b9e63656ec35bd4e58c30ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=87=AF=E6=98=8E?= Date: Tue, 6 Aug 2024 15:31:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E8=BE=93=E5=85=A5UT=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢凯明 --- test/unittest/config_policy_utils_test.cpp | 26 ++++++++++++++++++++++ test/unittest/config_policy_utils_test.h | 1 + 2 files changed, 27 insertions(+) diff --git a/test/unittest/config_policy_utils_test.cpp b/test/unittest/config_policy_utils_test.cpp index d7cba83..3ef853a 100644 --- a/test/unittest/config_policy_utils_test.cpp +++ b/test/unittest/config_policy_utils_test.cpp @@ -144,6 +144,7 @@ HWTEST_F(ConfigPolicyUtilsTest, CfgPolicyUtilsFuncTest005, TestSize.Level1) */ HWTEST_F(ConfigPolicyUtilsTest, CfgPolicyUtilsFuncTest006, TestSize.Level1) { + SystemSetParameter(CUST_OPKEY0, "-1"); const char *testPathSuffix = "etc/custxmltest/user.xml"; EXPECT_TRUE(TestGetCfgFile(testPathSuffix, FOLLOWX_MODE_SIM_DEFAULT, NULL)); } @@ -207,5 +208,30 @@ HWTEST_F(ConfigPolicyUtilsTest, CfgPolicyUtilsFuncTest010, TestSize.Level1) EXPECT_TRUE(TestGetCfgFile("etc/custxmltest/user.xml", FOLLOWX_MODE_USER_DEFINED, extraString.c_str())); EXPECT_TRUE(TestGetCfgFile("etc/custxmltest/both.xml", FOLLOWX_MODE_USER_DEFINED, extraString.c_str())); } + +/** + * @tc.name: CfgPolicyUtilsFuncTest011 + * @tc.desc: Test GetOneCfgFile & GetCfgFiles function, with nullptr input + * @tc.type: FUNC + * @tc.require: issueI5NYDH + */ +HWTEST_F(ConfigPolicyUtilsTest, CfgPolicyUtilsFuncTest011, TestSize.Level1) +{ + char buf[MAX_PATH_LEN] = {0}; + char *filePath = nullptr; + filePath = GetOneCfgFileEx(nullptr, buf, MAX_PATH_LEN, FOLLOWX_MODE_DEFAULT, nullptr); + EXPECT_TRUE(filePath == nullptr); + filePath = GetOneCfgFileEx("etc/custxmltest/user.xml", nullptr, MAX_PATH_LEN, FOLLOWX_MODE_DEFAULT, nullptr); + EXPECT_TRUE(filePath == nullptr); + filePath = GetOneCfgFileEx("etc/custxmltest/user.xml", buf, MAX_PATH_LEN - 1, FOLLOWX_MODE_DEFAULT, nullptr); + EXPECT_TRUE(filePath == nullptr); + CfgFiles *cfgFiles = GetCfgFilesEx(nullptr, FOLLOWX_MODE_DEFAULT, nullptr); + EXPECT_TRUE(cfgFiles == nullptr); + FreeCfgFiles(cfgFiles); + EXPECT_TRUE(cfgFiles == nullptr); + CfgDir *res = nullptr; + FreeCfgDirList(res); + EXPECT_TRUE(res == nullptr); +} #endif // __LITEOS__ } // namespace OHOS diff --git a/test/unittest/config_policy_utils_test.h b/test/unittest/config_policy_utils_test.h index 3c886aa..07a634a 100644 --- a/test/unittest/config_policy_utils_test.h +++ b/test/unittest/config_policy_utils_test.h @@ -28,6 +28,7 @@ int CfgPolicyUtilsFuncTest007(void); int CfgPolicyUtilsFuncTest008(void); int CfgPolicyUtilsFuncTest009(void); int CfgPolicyUtilsFuncTest010(void); +int CfgPolicyUtilsFuncTest011(void); #endif // __LITEOS__ #endif -- Gitee From 3b6d6af8c93bd8bf4b471d5f105f713ebe7d9bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=87=AF=E6=98=8E?= Date: Tue, 10 Sep 2024 06:18:45 +0000 Subject: [PATCH 2/2] add pac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢凯明 --- frameworks/config_policy/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frameworks/config_policy/BUILD.gn b/frameworks/config_policy/BUILD.gn index e167f3a..6ed18f2 100644 --- a/frameworks/config_policy/BUILD.gn +++ b/frameworks/config_policy/BUILD.gn @@ -35,12 +35,14 @@ if (defined(ohos_lite) && ohos_kernel_type == "liteos_m") { } } else if (defined(ohos_lite)) { shared_library("configpolicy_util") { + branch_protector_ret = "pac_ret" sources = config_policy_sources public_configs = [ ":config_policy_config" ] external_deps = [ "bounds_checking_function:libsec_shared" ] } } else { ohos_shared_library("configpolicy_util") { + branch_protector_ret = "pac_ret" sources = config_policy_sources public_configs = [ ":config_policy_config" ] deps = [ "etc:customization_etc" ] -- Gitee