提交 2e55950c 编写于 作者: C cheng_jinsong

修改ut

Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
上级 b749cdc2
......@@ -77,45 +77,4 @@ HWTEST_F(UtilsUnitTest, TestUtilsApi, TestSize.Level0)
char testStr[] = ".trim";
EXPECT_STREQ(TrimHead(testStr, '.'), "trim");
}
void TestOpenConsole(void)
{
// Save current stdin, stdout, stderr
int fd0 = dup(STDIN_FILENO);
EXPECT_GT(fd0, 0);
int fd1 = dup(STDOUT_FILENO);
EXPECT_GT(fd1, 0);
int fd2 = dup(STDERR_FILENO);
EXPECT_GT(fd2, 0);
// test start
OpenConsole();
char buffer[MAX_BUFFER_FOR_TEST];
ssize_t ret = readlink("/proc/self/fd/0", buffer, MAX_BUFFER_FOR_TEST - 1);
EXPECT_NE(ret, -1);
auto n = strcmp(buffer, "/dev/console");
EXPECT_EQ(n, 0);
(void)memset_s(buffer, sizeof(buffer), 0, MAX_BUFFER_FOR_TEST);
ret = readlink("/proc/self/fd/1", buffer, MAX_BUFFER_FOR_TEST - 1);
EXPECT_NE(ret, -1);
n = strcmp(buffer, "/dev/console");
EXPECT_EQ(n, 0);
(void)memset_s(buffer, sizeof(buffer), 0, MAX_BUFFER_FOR_TEST);
ret = readlink("/proc/self/fd/2", buffer, MAX_BUFFER_FOR_TEST - 1);
EXPECT_NE(ret, -1);
n = strcmp(buffer, "/dev/console");
EXPECT_EQ(n, 0);
// test done
// restore stdin, stdout, stderr
dup2(fd0, 0);
dup2(fd1, 1);
dup2(fd2, 2); // 2 stderr
close(fd0);
close(fd1);
close(fd2);
}
HWTEST_F(UtilsUnitTest, TestUtilsOpenConsole, TestSize.Level0)
{
TestOpenConsole();
}
} // namespace init_ut
......@@ -224,15 +224,6 @@ public:
// system allowlist
ret = CheckSyscall(SYSTEM_SA, SYSTEM_NAME, CheckGetpid, true);
EXPECT_EQ(ret, 0);
// failed
ret = CheckSyscall(SYSTEM_SA, nullptr, CheckGetMempolicy, false);
EXPECT_EQ(ret, 0);
ret = SystemWriteParam("persist.init.debug.seccomp.enable", "-1");
EXPECT_EQ(ret, 0);
ret = CheckSyscall(SYSTEM_SA, SYSTEM_NAME, CheckGetMempolicy, false);
EXPECT_EQ(ret, 0);
}
void TestSetUidGidFilter()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册