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}/daemon/daemon_app.cpp", 48 "${HDC_PATH}/daemon/daemon_forward.cpp", 49 "${HDC_PATH}/daemon/daemon_tcp.cpp", 50 "${HDC_PATH}/daemon/daemon_unity.cpp", 51 "${HDC_PATH}/daemon/daemon_usb.cpp", 52 "${HDC_PATH}/daemon/jdwp.cpp", 53 "${HDC_PATH}/daemon/shell.cpp", 54 "${updater_path}/services/flashd/daemon/commander.cpp", 55 "${updater_path}/services/flashd/daemon/commander_factory.cpp", 56 "${updater_path}/services/flashd/daemon/daemon_updater.cpp", 57 "${updater_path}/services/flashd/daemon/erase_commander.cpp", 58 "${updater_path}/services/flashd/daemon/flash_commander.cpp", 59 "${updater_path}/services/flashd/daemon/flashd_utils.cpp", 60 "${updater_path}/services/flashd/daemon/format_commander.cpp", 61 "${updater_path}/services/flashd/daemon/update_commander.cpp", 62 "${updater_path}/services/flashd/image_writer/image_writer.cpp", 63 "${updater_path}/services/flashd/partition.cpp", 64 "${updater_path}/services/hdi/client/update_hdi_client.cpp", 65 "${updater_path}/services/hdi/server/update_hdi_impl.cpp", 66 "${updater_path}/services/hwfault_retry/hwfault_retry.cpp", 67 "${updater_path}/services/updater_utils.cpp", 68 "flashd_unittest.cpp", 69 ] 70 include_dirs = [ 71 "${HDC_PATH}/daemon", 72 "${HDC_PATH}/common", 73 "${updater_path}/services", 74 "${updater_path}/services/common", 75 "${updater_path}/services/flashd", 76 "${updater_path}/services/flashd/daemon", 77 "${updater_path}/services/flashd/common", 78 "${updater_path}/interfaces/kits/include", 79 "${updater_path}/services/include/package", 80 "${updater_path}/services/include/ptable_parse", 81 "${updater_path}/services/include/script", 82 "${updater_path}/services/ui", 83 "${updater_path}/services/include/log", 84 "${updater_path}/services/include", 85 "${updater_path}/services/ptable_parse", 86 "${updater_path}/utils/include", 87 "${updater_path}/utils/json", 88 ] 89 90 deps = [ 91 "${updater_path}/interfaces/kits/misc_info:libmiscinfo", 92 "${updater_path}/interfaces/kits/updaterkits:libupdaterkits", 93 "${updater_path}/services:updater", 94 "${updater_path}/services/applypatch:libapplypatch", 95 "${updater_path}/services/diffpatch/patch:libpatch", 96 "${updater_path}/services/flashd:hdc_hash_gen", 97 "${updater_path}/services/fs_manager:libfsmanager", 98 "${updater_path}/services/hdi/server:libupdate_hdi_impl", 99 "${updater_path}/services/log:libupdaterlog", 100 "${updater_path}/services/package:libupdaterpackage", 101 "${updater_path}/services/script:libupdaterscript", 102 "${updater_path}/utils:libutils", 103 ] 104 105 external_deps = [ 106 "bounds_checking_function:libsec_static", 107 "bzip2:libbz2", 108 "cJSON:cjson", 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 configs = [ "${updater_path}/test/unittest:utest_config" ] 121 install_enable = true 122 part_name = "updater" 123 defines = [ 124 "UPDATER_UT", 125 "OPENSSL_SUPPRESS_DEPRECATED", 126 ] 127} 128 129ohos_unittest("flashd_utils_unittest") { 130 testonly = true 131 resource_config_file = "${updater_path}/test/unittest/test_data/ohos_test.xml" 132 module_out_path = MODULE_OUTPUT_PATH 133 sources = [ 134 "${updater_path}/services/flashd/daemon/flashd_utils.cpp", 135 "flashd_utils_unittest.cpp", 136 ] 137 include_dirs = [ 138 "${updater_path}/services/include", 139 "${updater_path}/utils/include", 140 "${updater_path}/services/flashd", 141 "${updater_path}/interfaces/kits/include", 142 "${updater_path}/services/common", 143 "${updater_path}/services/flashd/common", 144 ] 145 146 external_deps = [ 147 "c_utils:utils", 148 "hilog:libhilog", 149 "init:libbegetutil_static", 150 "libuv:uv", 151 ] 152 deps = [] 153 configs = [ "${updater_path}/test/unittest:utest_config" ] 154 install_enable = true 155 part_name = "updater" 156 defines = [ 157 "OPENSSL_SUPPRESS_DEPRECATED", 158 "HDC_SUPPORT_FLASHD", 159 ] 160} 161