xref: /base/security/selinux_adapter/test/BUILD.gn (revision c1ed15f1)
1# Copyright (C) 2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/test.gni")
15import("../selinux.gni")
16
17config("selinux_unittest_config") {
18  visibility = [ ":*" ]
19  include_dirs = [
20    "../interfaces/policycoreutils/include",
21    "unittest/common",
22  ]
23  cflags = [
24    "-D_GNU_SOURCE",
25    "-w",
26  ]
27}
28
29ohos_unittest("hap_restorecon_unittest") {
30  subsystem_name = "security"
31  part_name = "selinux_adapter"
32  module_out_path = part_name + "/" + part_name
33  public_configs = [ ":selinux_unittest_config" ]
34  sources = [
35    "../framework/policycoreutils/src/hap_restorecon.cpp",
36    "../framework/policycoreutils/src/sehap_contexts_trie.cpp",
37    "unittest/common/test_common.cpp",
38    "unittest/hap_restorecon/unit_test.cpp",
39  ]
40  deps = [
41    "../:libselinux_error_static",
42    "../:libselinux_hilog_static",
43  ]
44  cflags = [ "-DSELINUX_TEST" ]
45  external_deps = [
46    "googletest:gtest",
47    "hilog:libhilog",
48    "selinux:libselinux",
49  ]
50}
51
52ohos_unittest("paraperm_checker_unittest") {
53  subsystem_name = "security"
54  part_name = "selinux_adapter"
55  module_out_path = part_name + "/" + part_name
56  public_configs = [ ":selinux_unittest_config" ]
57  sources = [
58    "unittest/common/test_common.cpp",
59    "unittest/paraperm_checker/unit_test.cpp",
60  ]
61  external_deps = [
62    "googletest:gtest",
63    "selinux:libselinux",
64    "selinux_adapter:libparaperm_checker",
65  ]
66}
67
68ohos_unittest("service_checker_unittest") {
69  subsystem_name = "security"
70  part_name = "selinux_adapter"
71  module_out_path = part_name + "/" + part_name
72  public_configs = [ ":selinux_unittest_config" ]
73  sources = [
74    "unittest/common/test_common.cpp",
75    "unittest/service_checker/unit_test.cpp",
76  ]
77  external_deps = [
78    "googletest:gtest",
79    "selinux_adapter:libservice_checker",
80  ]
81}
82
83ohos_unittest("parameter_static_unittest") {
84  subsystem_name = "security"
85  part_name = "selinux_adapter"
86  module_out_path = part_name + "/" + part_name
87  public_configs = [ ":selinux_unittest_config" ]
88  sources = [
89    "../framework/policycoreutils/src/selinux_map.c",
90    "../framework/policycoreutils/src/selinux_share_mem.c",
91    "unittest/common/test_common.cpp",
92    "unittest/parameter_static/unit_test.cpp",
93  ]
94  external_deps = [
95    "googletest:gtest",
96    "selinux:libselinux",
97  ]
98}
99
100ohos_unittest("selinux_common_unittest") {
101  subsystem_name = "security"
102  part_name = "selinux_adapter"
103  module_out_path = part_name + "/" + part_name
104  public_configs = [ ":selinux_unittest_config" ]
105  sources = [
106    "unittest/common/test_common.cpp",
107    "unittest/selinux_common_test/unit_test.cpp",
108  ]
109  deps = [
110    "../:libselinux_hilog_static",
111    "../:libselinux_klog_static",
112  ]
113  external_deps = [
114    "googletest:gtest",
115    "hilog:libhilog",
116    "selinux:libselinux",
117  ]
118}
119
120group("unittest") {
121  testonly = true
122  deps = [
123    ":hap_restorecon_unittest",
124    ":parameter_static_unittest",
125    ":paraperm_checker_unittest",
126    ":selinux_common_unittest",
127    ":service_checker_unittest",
128  ]
129}
130