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 17module_output_path = "updater/updater_test" 18updater_path = rebase_path("${updater_absolutely_path}", ".") 19 20config("utest_config") { 21 visibility = [ "./*" ] 22 visibility += [ 23 "//base/startup/appspawn/test/unittest/*", 24 "//base/startup/init/test/unittest/*", 25 "//base/update/sys_installer/test/unittest/*", 26 ] 27 28 cflags = [ 29 "--coverage", 30 "-fprofile-arcs", 31 "-Wno-implicit-fallthrough", 32 "-Wno-unused-function", 33 ] 34 cflags_cc = [ 35 "-Wno-implicit-fallthrough", 36 "-fexceptions", 37 ] 38 39 ldflags = [ "--coverage" ] 40 41 defines = [ 42 "UPDATER_UT", 43 "BUILD_OHOS", 44 "HDC_DEBUG", 45 "HDC_SUPPORT_FLASHD", 46 "HARMONY_PROJECT", 47 ] 48} 49 50ohos_unittest("updater_unittest") { 51 testonly = true 52 resource_config_file = "${updater_path}/test/unittest/test_data/ohos_test.xml" 53 module_out_path = module_output_path 54 sources = [ 55 "diffpatch/bzip2_unittest.cpp", 56 "diffpatch/diffpatch_unittest.cpp", 57 "log_test/log_unittest.cpp", 58 "misc_info_test/misc_info_unittest.cpp", 59 "updaterkits_test/updaterkits_unittest.cpp", 60 ] 61 62 sources += [ 63 "$root_out_dir/updater/updater/yacc/lexer.cpp", 64 "$root_out_dir/updater/updater/yacc/parser.cpp", 65 "${updater_path}/interfaces/kits/misc_info/misc_info.cpp", 66 "${updater_path}/interfaces/kits/packages/package.cpp", 67 "${updater_path}/interfaces/kits/updaterkits/updaterkits.cpp", 68 "${updater_path}/services/diffpatch/bzip2/bzip2_adapter.cpp", 69 "${updater_path}/services/diffpatch/bzip2/lz4_adapter.cpp", 70 "${updater_path}/services/diffpatch/bzip2/zip_adapter.cpp", 71 "${updater_path}/services/diffpatch/diff/blocks_diff.cpp", 72 "${updater_path}/services/diffpatch/diff/image_diff.cpp", 73 "${updater_path}/services/diffpatch/diff/update_diff.cpp", 74 "${updater_path}/services/diffpatch/diffpatch.cpp", 75 "${updater_path}/services/diffpatch/patch/blocks_patch.cpp", 76 "${updater_path}/services/diffpatch/patch/image_patch.cpp", 77 "${updater_path}/services/diffpatch/patch/update_patch.cpp", 78 "${updater_path}/services/log/log.cpp", 79 "${updater_path}/services/package/pkg_algorithm/pkg_algo_deflate.cpp", 80 "${updater_path}/services/package/pkg_algorithm/pkg_algo_digest.cpp", 81 "${updater_path}/services/package/pkg_algorithm/pkg_algo_lz4.cpp", 82 "${updater_path}/services/package/pkg_algorithm/pkg_algo_sign.cpp", 83 "${updater_path}/services/package/pkg_algorithm/pkg_algorithm.cpp", 84 "${updater_path}/services/package/pkg_manager/pkg_managerImpl.cpp", 85 "${updater_path}/services/package/pkg_manager/pkg_stream.cpp", 86 "${updater_path}/services/package/pkg_manager/pkg_utils.cpp", 87 "${updater_path}/services/package/pkg_package/pkg_gzipfile.cpp", 88 "${updater_path}/services/package/pkg_package/pkg_lz4file.cpp", 89 "${updater_path}/services/package/pkg_package/pkg_pkgfile.cpp", 90 "${updater_path}/services/package/pkg_package/pkg_upgradefile.cpp", 91 "${updater_path}/services/package/pkg_package/pkg_zipfile.cpp", 92 "${updater_path}/services/script/script_instruction/script_basicinstruction.cpp", 93 "${updater_path}/services/script/script_instruction/script_instructionhelper.cpp", 94 "${updater_path}/services/script/script_instruction/script_loadscript.cpp", 95 "${updater_path}/services/script/script_instruction/script_registercmd.cpp", 96 "${updater_path}/services/script/script_instruction/script_updateprocesser.cpp", 97 "${updater_path}/services/script/script_interpreter/script_context.cpp", 98 "${updater_path}/services/script/script_interpreter/script_expression.cpp", 99 "${updater_path}/services/script/script_interpreter/script_function.cpp", 100 "${updater_path}/services/script/script_interpreter/script_interpreter.cpp", 101 "${updater_path}/services/script/script_interpreter/script_param.cpp", 102 "${updater_path}/services/script/script_interpreter/script_scanner.cpp", 103 "${updater_path}/services/script/script_interpreter/script_statement.cpp", 104 "${updater_path}/services/script/script_manager/script_managerImpl.cpp", 105 "${updater_path}/services/script/script_manager/script_utils.cpp", 106 "${updater_path}/services/script/threadpool/threadpool.cpp", 107 "${updater_path}/services/updater_utils.cpp", 108 "${updater_path}/utils/utils.cpp", 109 ] 110 111 include_dirs = [ 112 "${updater_path}/interfaces/kits/include/", 113 "${updater_path}/interfaces/kits/include/package", 114 "${updater_path}/services/include/", 115 "${updater_path}/utils/include/", 116 "${updater_path}/utils/json/", 117 "${updater_path}/services/", 118 "${updater_path}/services/include/package", 119 "${updater_path}/services/include/script", 120 "${updater_path}/services/include/log", 121 "${updater_path}/services/include/patch", 122 "${updater_path}/services/include/updater", 123 "${updater_path}/services/script/script_instruction", 124 "${updater_path}/services/script/script_interpreter", 125 "${updater_path}/services/script/script_manager", 126 "${updater_path}/services/script/threadpool", 127 "$root_out_dir/updater/updater/yacc", 128 "${updater_path}/services/package/pkg_algorithm", 129 "${updater_path}/services/package/pkg_manager", 130 "${updater_path}/services/package/pkg_package", 131 "${updater_path}/services/package/pkg_verify", 132 "${updater_path}/services/include/fs_manager", 133 "${updater_path}/services/fs_manager", 134 "${updater_path}/services/applypatch", 135 "${updater_path}/services/common", 136 "${updater_path}/services/diffpatch", 137 "${updater_path}/services/diffpatch/diff", 138 "${updater_path}/services/diffpatch/patch", 139 "${updater_path}/services/diffpatch/bzip2", 140 "${updater_path}/services/ui", 141 "${updater_path}/test/unittest", 142 "//developtools/hdc/src/common", 143 "//developtools/hdc/src/host", 144 "//developtools/hdc/src/daemon", 145 "//third_party/zlib", 146 "//third_party/lz4/lib", 147 "//third_party/bounds_checking_function/include", 148 "//foundation/arkui/napi/interfaces/kits", 149 "//third_party/cJSON", 150 "//third_party/curl/include", 151 "//third_party/bzip2", 152 "//third_party/libdrm/include/drm", 153 "//third_party/libdrm", 154 "//third_party/googletest/googletest/include", 155 "//drivers/framework/ability/sbuf/include", 156 "//drivers/framework/include/platform", 157 "//drivers/framework/include/core", 158 "//drivers/framework/include/osal", 159 "//drivers/framework/include/utils", 160 "//drivers/framework/include/config", 161 "//drivers/framework/include", 162 "//drivers/peripheral/input/hal/include", 163 "//drivers/peripheral/input/interfaces/include", 164 "//drivers/peripheral/partitionslot/hal/include", 165 "//third_party/bounds_checking_function/include", 166 ] 167 deps = [ 168 "${updater_path}/interfaces/kits/misc_info:libmiscinfo", 169 "${updater_path}/services/applypatch:libapplypatch", 170 "${updater_path}/services/diffpatch/diff:libdiff", 171 "${updater_path}/services/diffpatch/patch:libpatch", 172 "${updater_path}/services/fs_manager:libfsmanager", 173 "${updater_path}/services/log:libupdaterlog", 174 "${updater_path}/services/package:libupdaterpackage", 175 "${updater_path}/utils:libutils", 176 "//third_party/bounds_checking_function:libsec_static", 177 "//third_party/bzip2:libbz2", 178 "//third_party/cJSON:cjson", 179 "//third_party/googletest:gmock_main", 180 "//third_party/googletest:gtest_main", 181 "//third_party/libuv:uv", 182 "//third_party/lz4:liblz4_static", 183 "//third_party/openssl:libcrypto_shared", 184 "//third_party/openssl:libssl_shared", 185 "//third_party/zlib:libz", 186 ] 187 188 deps += [ 189 "${updater_path}/services/script:gen_yacc", 190 "${updater_path}/test/unittest:test_update_binary", 191 "${updater_path}/test/unittest:test_update_binary_abnormal", 192 ] 193 194 external_deps = [ 195 "hilog:libhilog_base", 196 "init:libbegetutil", 197 ] 198 199 public_configs = [ ":utest_config" ] 200 install_enable = true 201 part_name = "updater" 202 defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] 203} 204 205ohos_executable("test_update_binary") { 206 sources = [ "updater_test/test_update_binary.cpp" ] 207 install_enable = true 208 part_name = "updater" 209 subsystem_name = "updater" 210} 211 212ohos_executable("test_update_binary_abnormal") { 213 sources = [ "updater_test/test_update_binary_abnormal.cpp" ] 214 install_enable = true 215 part_name = "updater" 216 subsystem_name = "updater" 217} 218