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

!1111 seccomp模块tdd用例覆盖

Merge pull request !1111 from 夏不白/seccomp_add_tdd
......@@ -264,6 +264,13 @@ ohos_unittest("init_unittest") {
]
}
if (defined(build_seccomp) && build_seccomp) {
sources += [ "seccomp/seccomp_unittest.cpp" ]
include_dirs +=
[ "//base/startup/init/interfaces/innerkits/seccomp/include" ]
external_deps += [ "init:seccomp" ]
}
if (defined(build_selinux) && build_selinux) {
sources += [ "param/selinux_unittest.cpp" ]
include_dirs += [
......
......@@ -31,8 +31,6 @@
#include <asm/unistd.h>
#include <syscall.h>
#include <climits>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "seccomp_policy.h"
......@@ -138,10 +136,10 @@ public:
}
#if defined __aarch64__
static bool CheckShmget()
static bool CheckGetMempolicy()
{
int fd = shmget(1, 4096, 0666);
if (fd < 0) {
int ret = syscall(__NR_get_mempolicy, NULL, NULL, 0, NULL, 0);
if (ret < 0) {
return false;
}
......@@ -192,7 +190,7 @@ public:
void TestSystemSycall()
{
// system blocklist
int ret = CheckSyscall(SYSTEM, CheckShmget, false);
int ret = CheckSyscall(SYSTEM, CheckGetMempolicy, false);
EXPECT_EQ(ret, 0);
// system allowlist
......@@ -278,10 +276,4 @@ HWTEST_F(SeccompUnitTest, TestSystemSycall, TestSize.Level1)
SeccompUnitTest test;
test.TestSystemSycall();
}
HWTEST_F(SeccompUnitTest, TestSetUidGidFilter, TestSize.Level1)
{
SeccompUnitTest test;
test.TestSetUidGidFilter();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册