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("//base/update/updater/updater_default_cfg.gni") 15import("//build/test.gni") 16 17updater_path = rebase_path("${updater_absolutely_path}", ".") 18 19MODULE_OUTPUT_PATH = "updater/updater" 20HDC_PATH = "//developtools/hdc/src" 21 22ohos_unittest("flashd_unittest") { 23 testonly = true 24 resource_config_file = 25 "//base/update/updater/test/unittest/test_data/ohos_test.xml" 26 module_out_path = MODULE_OUTPUT_PATH 27 sources = [ 28 "${HDC_PATH}/common/async_cmd.cpp", 29 "${HDC_PATH}/common/auth.cpp", 30 "${HDC_PATH}/common/base.cpp", 31 "${HDC_PATH}/common/channel.cpp", 32 "${HDC_PATH}/common/circle_buffer.cpp", 33 "${HDC_PATH}/common/compress.cpp", 34 "${HDC_PATH}/common/debug.cpp", 35 "${HDC_PATH}/common/decompress.cpp", 36 "${HDC_PATH}/common/entry.cpp", 37 "${HDC_PATH}/common/file.cpp", 38 "${HDC_PATH}/common/file_descriptor.cpp", 39 "${HDC_PATH}/common/forward.cpp", 40 "${HDC_PATH}/common/header.cpp", 41 "${HDC_PATH}/common/heartbeat.cpp", 42 "${HDC_PATH}/common/session.cpp", 43 "${HDC_PATH}/common/task.cpp", 44 "${HDC_PATH}/common/tcp.cpp", 45 "${HDC_PATH}/common/transfer.cpp", 46 "${HDC_PATH}/common/usb.cpp", 47 "${HDC_PATH}/common/uv_status.cpp", 48 "${HDC_PATH}/daemon/daemon_app.cpp", 49 "${HDC_PATH}/daemon/daemon_forward.cpp", 50 "${HDC_PATH}/daemon/daemon_tcp.cpp", 51 "${HDC_PATH}/daemon/daemon_unity.cpp", 52 "${HDC_PATH}/daemon/daemon_usb.cpp", 53 "${HDC_PATH}/daemon/jdwp.cpp", 54 "${HDC_PATH}/daemon/shell.cpp", 55 "${updater_path}/services/flashd/daemon/commander.cpp", 56 "${updater_path}/services/flashd/daemon/commander_factory.cpp", 57 "${updater_path}/services/flashd/daemon/daemon_updater.cpp", 58 "${updater_path}/services/flashd/daemon/erase_commander.cpp", 59 "${updater_path}/services/flashd/daemon/flash_commander.cpp", 60 "${updater_path}/services/flashd/daemon/flashd_utils.cpp", 61 "${updater_path}/services/flashd/daemon/format_commander.cpp", 62 "${updater_path}/services/flashd/daemon/update_commander.cpp", 63 "${updater_path}/services/flashd/image_writer/image_writer.cpp", 64 "${updater_path}/services/flashd/partition.cpp", 65 "${updater_path}/services/hdi/client/update_hdi_client.cpp", 66 "${updater_path}/services/hdi/server/update_hdi_impl.cpp", 67 "${updater_path}/services/hardware_fault/hardware_fault_retry.cpp", 68 "${updater_path}/services/updater_utils.cpp", 69 "flashd_unittest.cpp", 70 ] 71 include_dirs = [ 72 "${updater_path}/services", 73 "${updater_path}/services/common", 74 "${updater_path}/services/flashd", 75 "${updater_path}/services/flashd/daemon", 76 "${updater_path}/services/flashd/common", 77 "${updater_path}/interfaces/kits/include", 78 "${updater_path}/services/include/package", 79 "${updater_path}/services/include/ptable_parse", 80 "${updater_path}/services/include/script", 81 "${updater_path}/services/ui", 82 "${updater_path}/services/include/log", 83 "${updater_path}/services/include", 84 "${updater_path}/services/ptable_parse", 85 "${updater_path}/utils/include", 86 "${updater_path}/utils/json", 87 ] 88 89 deps = [ 90 "${updater_path}/interfaces/kits/misc_info:libmiscinfo", 91 "${updater_path}/interfaces/kits/updaterkits:libupdaterkits", 92 "${updater_path}/services:updater", 93 "${updater_path}/services/applypatch:libapplypatch", 94 "${updater_path}/services/diffpatch/patch:libpatch", 95 "${updater_path}/services/flashd:hdc_hash_gen", 96 "${updater_path}/services/fs_manager:libfsmanager", 97 "${updater_path}/services/hdi/server:libupdate_hdi_impl", 98 "${updater_path}/services/log:libupdaterlog", 99 "${updater_path}/services/package:libupdaterpackage", 100 "${updater_path}/services/script:libupdaterscript", 101 "${updater_path}/utils:libutils", 102 ] 103 104 external_deps = [ 105 "bounds_checking_function:libsec_static", 106 "bzip2:libbz2", 107 "cJSON:cjson", 108 "c_utils:utils", 109 "googletest:gmock_main", 110 "googletest:gtest_main", 111 "hilog:libhilog", 112 "init:libbegetutil_static", 113 "libuv:uv", 114 "lz4:liblz4_static", 115 "openssl:libcrypto_shared", 116 ] 117 if (updater_zlib_enable) { 118 external_deps += [ "zlib:libz" ] 119 } 120 if (updater_hdc_depend) { 121 external_deps += [ "hdc:hdc_updater" ] 122 } 123 configs = [ "${updater_path}/test/unittest:utest_config" ] 124 install_enable = true 125 part_name = "updater" 126 defines = [ 127 "UPDATER_UT", 128 "OPENSSL_SUPPRESS_DEPRECATED", 129 ] 130} 131 132ohos_unittest("flashd_utils_unittest") { 133 testonly = true 134 resource_config_file = "${updater_path}/test/unittest/test_data/ohos_test.xml" 135 module_out_path = MODULE_OUTPUT_PATH 136 sources = [ 137 "${updater_path}/services/flashd/daemon/flashd_utils.cpp", 138 "flashd_utils_unittest.cpp", 139 ] 140 include_dirs = [ 141 "${updater_path}/services/include", 142 "${updater_path}/utils/include", 143 "${updater_path}/services/flashd", 144 "${updater_path}/interfaces/kits/include", 145 "${updater_path}/services/common", 146 "${updater_path}/services/flashd/common", 147 ] 148 149 external_deps = [ 150 "c_utils:utils", 151 "hilog:libhilog", 152 "init:libbegetutil_static", 153 "libuv:uv", 154 ] 155 deps = [] 156 configs = [ "${updater_path}/test/unittest:utest_config" ] 157 install_enable = true 158 part_name = "updater" 159 defines = [ 160 "OPENSSL_SUPPRESS_DEPRECATED", 161 "HDC_SUPPORT_FLASHD", 162 ] 163} 164