diff --git a/services/modules/seccomp/seccomp_policy.c b/services/modules/seccomp/seccomp_policy.c index a89ba494d3d82f9efbfd2743fb63ac03fd2272ff..1bf3a331a645f23ebf317ac506e01cebe54b5276 100644 --- a/services/modules/seccomp/seccomp_policy.c +++ b/services/modules/seccomp/seccomp_policy.c @@ -216,11 +216,11 @@ bool SetSeccompPolicyWithName(const char *filterName) } else { PLUGIN_LOGE("GetSeccompPolicy failed return is %d", retCode); } - +#ifndef COVERAGE_TEST if (handler != NULL) { dlclose(handler); } - +#endif if (filterLibRealPath != NULL) { free(filterLibRealPath); } diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index a20672a62e5c07a6b9c231d44bb560ec3f6874b9..e140918b8f34c8a13aea7f81c614767f92095bb3 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -323,10 +323,20 @@ ohos_unittest("init_unittest") { } if (defined(build_seccomp) && build_seccomp) { - sources += [ "seccomp/seccomp_unittest.cpp" ] + sources += [ + "../../services/modules/seccomp/seccomp_policy.c", + "seccomp/seccomp_unittest.cpp", + ] include_dirs += [ "//base/startup/init/interfaces/innerkits/seccomp/include" ] - external_deps += [ "init:seccomp" ] + + if (build_variant == "root") { + defines += [ "WITH_SECCOMP_DEBUG" ] + } + + if (use_clang_coverage) { + defines += [ "COVERAGE_TEST" ] + } } if (defined(build_selinux) && build_selinux) {