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

!1111 seccomp模块tdd用例覆盖

Merge pull request !1111 from 夏不白/seccomp_add_tdd
...@@ -264,6 +264,13 @@ ohos_unittest("init_unittest") { ...@@ -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) { if (defined(build_selinux) && build_selinux) {
sources += [ "param/selinux_unittest.cpp" ] sources += [ "param/selinux_unittest.cpp" ]
include_dirs += [ include_dirs += [
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#include <asm/unistd.h> #include <asm/unistd.h>
#include <syscall.h> #include <syscall.h>
#include <climits> #include <climits>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "seccomp_policy.h" #include "seccomp_policy.h"
...@@ -138,10 +136,10 @@ public: ...@@ -138,10 +136,10 @@ public:
} }
#if defined __aarch64__ #if defined __aarch64__
static bool CheckShmget() static bool CheckGetMempolicy()
{ {
int fd = shmget(1, 4096, 0666); int ret = syscall(__NR_get_mempolicy, NULL, NULL, 0, NULL, 0);
if (fd < 0) { if (ret < 0) {
return false; return false;
} }
...@@ -192,7 +190,7 @@ public: ...@@ -192,7 +190,7 @@ public:
void TestSystemSycall() void TestSystemSycall()
{ {
// system blocklist // system blocklist
int ret = CheckSyscall(SYSTEM, CheckShmget, false); int ret = CheckSyscall(SYSTEM, CheckGetMempolicy, false);
EXPECT_EQ(ret, 0); EXPECT_EQ(ret, 0);
// system allowlist // system allowlist
...@@ -278,10 +276,4 @@ HWTEST_F(SeccompUnitTest, TestSystemSycall, TestSize.Level1) ...@@ -278,10 +276,4 @@ HWTEST_F(SeccompUnitTest, TestSystemSycall, TestSize.Level1)
SeccompUnitTest test; SeccompUnitTest test;
test.TestSystemSycall(); 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.
先完成此消息的编辑!
想要评论请 注册