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 "$THIRD_PARTY_DIR/selinux/libselinux/include", 23 "$THIRD_PARTY_DIR/googletest/include", 24 ] 25 cflags = [ 26 "-D_GNU_SOURCE", 27 "-w", 28 ] 29} 30 31ohos_unittest("hap_restorecon_unittest") { 32 subsystem_name = "security" 33 part_name = "selinux_adapter" 34 module_out_path = part_name + "/" + part_name 35 public_configs = [ ":selinux_unittest_config" ] 36 sources = [ 37 "../interfaces/policycoreutils/src/hap_restorecon.cpp", 38 "../interfaces/policycoreutils/src/sehap_contexts_trie.cpp", 39 "unittest/common/test_common.cpp", 40 "unittest/hap_restorecon/unit_test.cpp", 41 ] 42 deps = [ 43 "$THIRD_PARTY_DIR/selinux:libselinux", 44 "../:libselinux_error_static", 45 "../:libselinux_hilog_static", 46 ] 47 cflags = [ "-DSELINUX_TEST" ] 48 external_deps = [ "c_utils:utils" ] 49} 50 51ohos_unittest("paraperm_checker_unittest") { 52 subsystem_name = "security" 53 part_name = "selinux_adapter" 54 module_out_path = part_name + "/" + part_name 55 public_configs = [ ":selinux_unittest_config" ] 56 sources = [ 57 "unittest/common/test_common.cpp", 58 "unittest/paraperm_checker/unit_test.cpp", 59 ] 60 deps = [ "$THIRD_PARTY_DIR/selinux:libselinux" ] 61 external_deps = [ 62 "c_utils:utils", 63 "selinux_adapter:libparaperm_checker", 64 ] 65} 66 67ohos_unittest("service_checker_unittest") { 68 subsystem_name = "security" 69 part_name = "selinux_adapter" 70 module_out_path = part_name + "/" + part_name 71 public_configs = [ ":selinux_unittest_config" ] 72 sources = [ 73 "unittest/common/test_common.cpp", 74 "unittest/service_checker/unit_test.cpp", 75 ] 76 external_deps = [ 77 "c_utils:utils", 78 "selinux_adapter:libservice_checker", 79 ] 80} 81 82ohos_unittest("parameter_static_unittest") { 83 subsystem_name = "security" 84 part_name = "selinux_adapter" 85 module_out_path = part_name + "/" + part_name 86 public_configs = [ ":selinux_unittest_config" ] 87 sources = [ 88 "../interfaces/policycoreutils/src/selinux_map.c", 89 "../interfaces/policycoreutils/src/selinux_share_mem.c", 90 "unittest/common/test_common.cpp", 91 "unittest/parameter_static/unit_test.cpp", 92 ] 93 deps = [ "$THIRD_PARTY_DIR/selinux:libselinux" ] 94 external_deps = [ "c_utils:utils" ] 95} 96 97ohos_unittest("selinux_common_unittest") { 98 subsystem_name = "security" 99 part_name = "selinux_adapter" 100 module_out_path = part_name + "/" + part_name 101 public_configs = [ ":selinux_unittest_config" ] 102 sources = [ 103 "unittest/common/test_common.cpp", 104 "unittest/selinux_common_test/unit_test.cpp", 105 ] 106 deps = [ 107 "../:libselinux_hilog_static", 108 "../:libselinux_klog_static", 109 "//third_party/selinux:libselinux", 110 ] 111} 112 113group("unittest") { 114 testonly = true 115 deps = [ 116 ":hap_restorecon_unittest", 117 ":parameter_static_unittest", 118 ":paraperm_checker_unittest", 119 ":selinux_common_unittest", 120 ":service_checker_unittest", 121 ] 122} 123