From 7a0942038dcf46d9f373475f85ca0cd408f6fa3f Mon Sep 17 00:00:00 2001 From: cat Date: Thu, 7 Aug 2025 21:13:03 +0800 Subject: [PATCH] add seccomp ut Signed-off-by: cat --- test/unittest/seccomp/seccomp_unittest.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/unittest/seccomp/seccomp_unittest.cpp b/test/unittest/seccomp/seccomp_unittest.cpp index b1e79fd77..33668bbb1 100644 --- a/test/unittest/seccomp/seccomp_unittest.cpp +++ b/test/unittest/seccomp/seccomp_unittest.cpp @@ -32,6 +32,8 @@ #include #include "seccomp_policy.h" +#include "parameter.h" +#include "param_utils.h" using SyscallFunc = bool (*)(void); constexpr int SLEEP_TIME_100MS = 100000; // 100ms @@ -1315,6 +1317,28 @@ public: } }; +/** + * @tc.name: IsEnableSeccomp + * @tc.desc: Verify the system seccomp policy. + * @tc.type: FUNC + * @tc.require: issueI5IUWJ + */ +HWTEST_F(SeccompUnitTest, Init_IsEnableSeccomp001, TestSize.Level1) +{ + bool res = true; +#ifdef WITH_SECCOMP_DEBUG + char value[PARAM_BUFFER_SIZE] = { 0 }; + u_int32_t len = sizeof(value); + if (SystemReadParam("persist.init.debug.seccomp.enabel", value, &len) == 0) { + if (strncmp(value, "0", len) == 0) { + res = false; + } + } +#endif + bool isEnable = IsEnableSeccomp(); + EXPECT_EQ(res, isEnable); +} + /** * @tc.name: TestSystemSycall * @tc.desc: Verify the system seccomp policy. -- Gitee