提交 713a8059 编写于 作者: O openharmony_ci 提交者: Gitee

!181 修改init ut

Merge pull request !181 from 熊磊/init_ut1201
......@@ -95,7 +95,6 @@ ohos_unittest("init_ut") {
"init/service_socket_unittest.cpp",
"init/service_unittest.cpp",
"init/utils_unittest.cpp",
"innerkits/innerkits_unittest.cpp",
"param/client_unittest.cpp",
"param/dac_unittest.cpp",
"param/param_unittest.cpp",
......
......@@ -30,41 +30,13 @@ public:
static void SetUpTestCase(void)
{
InitParamService();
mkdir("/data/init_ut", S_IRWXU | S_IRWXG | S_IRWXO);
};
static void TearDownTestCase(void) {};
void SetUp() {};
void TearDown() {};
};
HWTEST_F(CmdsUnitTest, TestGetValueForCmd, TestSize.Level1)
{
// 1, test one param
SystemWriteParam("ro.test.1111.2222", "2.3.4.5.6.7.8");
char *tmpParamValue = (char *)malloc(PARAM_VALUE_LEN_MAX + 1);
if (tmpParamValue == nullptr) {
EXPECT_EQ(1, 0);
return;
}
tmpParamValue[0] = '\0';
const char *cmd1 = "init.${ro.test.1111.2222}.usb.cfg";
GetParamValue(cmd1, strlen(cmd1), tmpParamValue, PARAM_VALUE_LEN_MAX);
printf("Tmp value %s \n", tmpParamValue);
EXPECT_EQ(strcmp("init.2.3.4.5.6.7.8.usb.cfg", tmpParamValue), 0);
// 2, test two param
const char *cmd2 = "init.${ro.test.1111.2222}.usb.${ro.test.1111.2222}";
GetParamValue(cmd2, strlen(cmd2), tmpParamValue, PARAM_VALUE_LEN_MAX);
printf("Tmp value %s \n", tmpParamValue);
EXPECT_EQ(strcmp("init.2.3.4.5.6.7.8.usb.2.3.4.5.6.7.8", tmpParamValue), 0);
// 3, test two param
const char *cmd3 = "${ro.test.1111.2222}.init.${ro.test.1111.2222}.usb.${ro.test.1111.2222}";
GetParamValue(cmd3, strlen(cmd3), tmpParamValue, PARAM_VALUE_LEN_MAX);
printf("Tmp value %s \n", tmpParamValue);
EXPECT_EQ(strcmp("2.3.4.5.6.7.8.init.2.3.4.5.6.7.8.usb.2.3.4.5.6.7.8", tmpParamValue), 0);
free(tmpParamValue);
}
HWTEST_F(CmdsUnitTest, TestCmdExecByName, TestSize.Level1)
{
SetInitLogLevel(INIT_INFO);
......
......@@ -43,21 +43,6 @@ public:
void TearDown() {}
void TestBody() {}
int TestDacGetLabel()
{
int ret = RegisterSecurityDacOps(&initParamSercurityOps, LABEL_INIT_FOR_INIT);
EXPECT_EQ(ret, 0);
if (initParamSercurityOps.securityGetLabel == nullptr) {
EXPECT_EQ(1, 0);
return -1;
}
ret = initParamSercurityOps.securityGetLabel(SecurityLabelGet,
PARAM_DEFAULT_PATH "/system/etc/param", nullptr);
EXPECT_EQ(ret, 0);
return 0;
}
int TestDacInitLocalLabel()
{
int ret = RegisterSecurityDacOps(&initParamSercurityOps, LABEL_INIT_FOR_INIT);
......@@ -185,12 +170,6 @@ private:
ParamSecurityOps clientParamSercurityOps {};
};
HWTEST_F(DacUnitTest, TestDacGetLabel, TestSize.Level0)
{
DacUnitTest test;
test.TestDacGetLabel();
}
HWTEST_F(DacUnitTest, TestDacInitLocalLabel, TestSize.Level0)
{
DacUnitTest test;
......
......@@ -48,20 +48,6 @@ public:
void TearDown() {}
void TestBody() {}
int TestParamServiceInit()
{
InitParamService();
// parse parameters
LoadDefaultParams(PARAM_DEFAULT_PATH"/system/etc/param/ohos_const", LOAD_PARAM_NORMAL);
LoadDefaultParams(PARAM_DEFAULT_PATH"/vendor/etc/param", LOAD_PARAM_NORMAL);
LoadDefaultParams(PARAM_DEFAULT_PATH"/system/etc/param", LOAD_PARAM_ONLY_ADD);
CheckServerParamValue("const.actionable_compatible_property.enabled", "false");
CheckServerParamValue("build_version", "2.0");
CheckServerParamValue("ohos.boot.hardware", "Hi3516DV300");
LoadPersistParams();
return 0;
}
int TestSetParams(const char *params[][1 + 1], int num)
{
for (int i = 0; i < num; i++) {
......@@ -485,12 +471,6 @@ public:
}
};
HWTEST_F(ParamUnitTest, TestParamServiceInit, TestSize.Level0)
{
ParamUnitTest test;
test.TestParamServiceInit();
}
HWTEST_F(ParamUnitTest, TestPersistParam, TestSize.Level0)
{
ParamUnitTest test;
......
......@@ -44,21 +44,6 @@ public:
void TearDown() {}
void TestBody() {}
int TestSelinuxGetLabel()
{
int ret = RegisterSecuritySelinuxOps(&initParamSercurityOps, LABEL_INIT_FOR_INIT);
EXPECT_EQ(ret, 0);
if (initParamSercurityOps.securityGetLabel == nullptr) {
EXPECT_EQ(1, 0);
return -1;
}
ret = initParamSercurityOps.securityGetLabel(SecurityLabelGet,
PARAM_DEFAULT_PATH "/system/etc/param", nullptr);
EXPECT_EQ(ret, 0);
return 0;
}
int TestSelinuxInitLocalLabel()
{
int ret = RegisterSecuritySelinuxOps(&initParamSercurityOps, LABEL_INIT_FOR_INIT);
......@@ -240,12 +225,6 @@ private:
ParamSecurityOps clientParamSercurityOps {};
};
HWTEST_F(SelinuxUnitTest, TestSelinuxGetLabel, TestSize.Level0)
{
SelinuxUnitTest test;
test.TestSelinuxGetLabel();
}
HWTEST_F(SelinuxUnitTest, TestSelinuxInitLocalLabel, TestSize.Level0)
{
SelinuxUnitTest test;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册