未验证 提交 302d07e4 编写于 作者: O openharmony_ci 提交者: Gitee

!1083 fix init ut问题

Merge pull request !1083 from cheng_jinsong/initut
......@@ -106,17 +106,17 @@ static void TestPermission()
const char *testName = "persist.111.ffff.bbbb.cccc.dddd.eeee.55555";
char tmp[PARAM_BUFFER_SIZE] = {0};
int ret;
// 允许本地校验
ParamSecurityOps *paramSecurityOps = GetParamSecurityOps(0);
paramSecurityOps->securityCheckParamPermission = TestCheckParamPermission;
SetTestPermissionResult(DAC_RESULT_FORBIDED);
if ((GetParamSecurityLabel() != nullptr)) {
GetParamSecurityLabel()->flags[0] = LABEL_CHECK_IN_ALL_PROCESS;
ret = SystemSetParameter(testName, "22202");
#ifdef PARAM_SUPPORT_SELINUX
EXPECT_EQ(ret, 0);
#else
#ifdef __LITEOS_A__
EXPECT_EQ(ret, DAC_RESULT_FORBIDED);
#else
EXPECT_EQ(ret, 0); // 本地不在校验
#endif
}
paramSecurityOps->securityFreeLabel = TestFreeLocalSecurityLabel;
......@@ -129,11 +129,12 @@ static void TestPermission()
const int testResult = 201;
SetTestPermissionResult(testResult);
ret = SystemSetParameter(testName, "3333");
#ifdef PARAM_SUPPORT_SELINUX
EXPECT_EQ(ret, 0);
#else
#ifdef __LITEOS_A__
EXPECT_EQ(ret, testResult);
#else
EXPECT_EQ(ret, 0); // 本地不在校验
#endif
u_int32_t len = sizeof(tmp);
SetTestPermissionResult(DAC_RESULT_FORBIDED);
ret = SystemGetParameter(testName, tmp, &len);
......
......@@ -529,9 +529,11 @@ HWTEST_F(ParamServiceUnitTest, TestServiceCtrl, TestSize.Level0)
ParamServiceUnitTest test;
int ret = test.TestServiceCtrl("server1", 0770);
EXPECT_NE(ret, 0);
#ifdef PARAM_SUPPORT_SELINUX
// selinux forbid
ret = test.TestServiceCtrl("server2", 0772);
EXPECT_NE(ret, 0);
#endif
}
HWTEST_F(ParamServiceUnitTest, TestPowerCtrl, TestSize.Level0)
......@@ -539,23 +541,31 @@ HWTEST_F(ParamServiceUnitTest, TestPowerCtrl, TestSize.Level0)
ParamServiceUnitTest test;
int ret = test.TestPowerCtrl("reboot,shutdown", 0770);
EXPECT_NE(ret, 0);
#ifdef PARAM_SUPPORT_SELINUX
ret = test.TestPowerCtrl("reboot,shutdown", 0772);
// selinux forbid
EXPECT_NE(ret, 0);
#endif
ret = test.TestPowerCtrl("reboot,updater", 0770);
EXPECT_NE(ret, 0);
#ifdef PARAM_SUPPORT_SELINUX
ret = test.TestPowerCtrl("reboot,updater", 0772);
// selinux forbid
EXPECT_NE(ret, 0);
#endif
ret = test.TestPowerCtrl("reboot,flash", 0770);
EXPECT_NE(ret, 0);
#ifdef PARAM_SUPPORT_SELINUX
ret = test.TestPowerCtrl("reboot,flash", 0772);
// selinux forbid
EXPECT_NE(ret, 0);
#endif
ret = test.TestPowerCtrl("reboot", 0770);
EXPECT_NE(ret, 0);
#ifdef PARAM_SUPPORT_SELINUX
ret = test.TestPowerCtrl("reboot", 0772);
// selinux forbid
EXPECT_NE(ret, 0);
#endif
}
} // namespace init_ut
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册