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 "diffpatch/image_patch_unittest.cpp", 58 "log_test/log_unittest.cpp", 59 "misc_info_test/misc_info_unittest.cpp", 60 "updater_test/hwfault_retry_unittest.cpp", 61 "updater_test/record_install_time_unittest.cpp", 62 "updaterkits_test/updaterkits_unittest.cpp", 63 ] 64 65 sources += [ 66 "$root_out_dir/updater/updater/yacc/lexer.cpp", 67 "$root_out_dir/updater/updater/yacc/parser.cpp", 68 "${updater_path}/interfaces/kits/misc_info/misc_info.cpp", 69 "${updater_path}/interfaces/kits/packages/package.cpp", 70 "${updater_path}/interfaces/kits/updaterkits/updaterkits.cpp", 71 "${updater_path}/services/diffpatch/bzip2/bzip2_adapter.cpp", 72 "${updater_path}/services/diffpatch/bzip2/lz4_adapter.cpp", 73 "${updater_path}/services/diffpatch/bzip2/zip_adapter.cpp", 74 "${updater_path}/services/diffpatch/diff/blocks_diff.cpp", 75 "${updater_path}/services/diffpatch/diff/image_diff.cpp", 76 "${updater_path}/services/diffpatch/diff/update_diff.cpp", 77 "${updater_path}/services/diffpatch/diffpatch.cpp", 78 "${updater_path}/services/diffpatch/patch/blocks_patch.cpp", 79 "${updater_path}/services/diffpatch/patch/image_patch.cpp", 80 "${updater_path}/services/diffpatch/patch/update_patch.cpp", 81 "${updater_path}/services/hwfault_retry/hwfault_retry.cpp", 82 "${updater_path}/services/log/log.cpp", 83 "${updater_path}/services/package/pkg_algorithm/pkg_algo_deflate.cpp", 84 "${updater_path}/services/package/pkg_algorithm/pkg_algo_digest.cpp", 85 "${updater_path}/services/package/pkg_algorithm/pkg_algo_lz4.cpp", 86 "${updater_path}/services/package/pkg_algorithm/pkg_algo_sign.cpp", 87 "${updater_path}/services/package/pkg_algorithm/pkg_algorithm.cpp", 88 "${updater_path}/services/package/pkg_manager/pkg_managerImpl.cpp", 89 "${updater_path}/services/package/pkg_manager/pkg_stream.cpp", 90 "${updater_path}/services/package/pkg_manager/pkg_utils.cpp", 91 "${updater_path}/services/package/pkg_package/pkg_gzipfile.cpp", 92 "${updater_path}/services/package/pkg_package/pkg_lz4file.cpp", 93 "${updater_path}/services/package/pkg_package/pkg_pkgfile.cpp", 94 "${updater_path}/services/package/pkg_package/pkg_upgradefile.cpp", 95 "${updater_path}/services/package/pkg_package/pkg_zipfile.cpp", 96 "${updater_path}/services/script/script_instruction/script_basicinstruction.cpp", 97 "${updater_path}/services/script/script_instruction/script_instructionhelper.cpp", 98 "${updater_path}/services/script/script_instruction/script_loadscript.cpp", 99 "${updater_path}/services/script/script_instruction/script_registercmd.cpp", 100 "${updater_path}/services/script/script_instruction/script_updateprocesser.cpp", 101 "${updater_path}/services/script/script_interpreter/script_context.cpp", 102 "${updater_path}/services/script/script_interpreter/script_expression.cpp", 103 "${updater_path}/services/script/script_interpreter/script_function.cpp", 104 "${updater_path}/services/script/script_interpreter/script_interpreter.cpp", 105 "${updater_path}/services/script/script_interpreter/script_param.cpp", 106 "${updater_path}/services/script/script_interpreter/script_scanner.cpp", 107 "${updater_path}/services/script/script_interpreter/script_statement.cpp", 108 "${updater_path}/services/script/script_manager/script_managerImpl.cpp", 109 "${updater_path}/services/script/script_manager/script_utils.cpp", 110 "${updater_path}/services/script/threadpool/threadpool.cpp", 111 "${updater_path}/services/updater_utils.cpp", 112 "${updater_path}/utils/utils.cpp", 113 ] 114 115 include_dirs = [ 116 "${updater_path}/interfaces/kits/include/", 117 "${updater_path}/interfaces/kits/include/package", 118 "${updater_path}/services/include/", 119 "${updater_path}/utils/include/", 120 "${updater_path}/utils/json/", 121 "${updater_path}/services/", 122 "${updater_path}/services/include/package", 123 "${updater_path}/services/include/script", 124 "${updater_path}/services/include/log", 125 "${updater_path}/services/include/patch", 126 "${updater_path}/services/include/updater", 127 "${updater_path}/services/script/script_instruction", 128 "${updater_path}/services/script/script_interpreter", 129 "${updater_path}/services/script/script_manager", 130 "${updater_path}/services/script/threadpool", 131 "$root_out_dir/updater/updater/yacc", 132 "${updater_path}/services/package/pkg_algorithm", 133 "${updater_path}/services/package/pkg_manager", 134 "${updater_path}/services/package/pkg_package", 135 "${updater_path}/services/package/pkg_verify", 136 "${updater_path}/services/include/fs_manager", 137 "${updater_path}/services/fs_manager", 138 "${updater_path}/services/applypatch", 139 "${updater_path}/services/common", 140 "${updater_path}/services/diffpatch", 141 "${updater_path}/services/diffpatch/diff", 142 "${updater_path}/services/diffpatch/patch", 143 "${updater_path}/services/diffpatch/bzip2", 144 "${updater_path}/services/ui", 145 "${updater_path}/test/unittest", 146 ] 147 deps = [ 148 "${updater_path}/interfaces/kits/misc_info:libmiscinfo", 149 "${updater_path}/services/applypatch:libapplypatch", 150 "${updater_path}/services/diffpatch/diff:libdiff", 151 "${updater_path}/services/diffpatch/patch:libpatch", 152 "${updater_path}/services/fs_manager:libfsmanager", 153 "${updater_path}/services/log:libupdaterlog", 154 "${updater_path}/services/package:libupdaterpackage", 155 "${updater_path}/utils:libutils", 156 ] 157 158 deps += [ 159 "${updater_path}/services/script:gen_yacc", 160 "${updater_path}/test/unittest:test_update_binary", 161 "${updater_path}/test/unittest:test_update_binary_abnormal", 162 ] 163 164 external_deps = [ 165 "bounds_checking_function:libsec_static", 166 "bzip2:libbz2", 167 "cJSON:cjson", 168 "googletest:gmock_main", 169 "googletest:gtest_main", 170 "hilog:libhilog_base", 171 "init:libbegetutil_static", 172 "libuv:uv", 173 "lz4:liblz4_static", 174 "openssl:libcrypto_shared", 175 "openssl:libssl_static", 176 "zlib:libz", 177 ] 178 179 public_configs = [ ":utest_config" ] 180 install_enable = true 181 part_name = "updater" 182 defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] 183} 184 185ohos_executable("test_update_binary") { 186 sources = [ "updater_test/test_update_binary.cpp" ] 187 install_enable = true 188 part_name = "updater" 189 subsystem_name = "updater" 190} 191 192ohos_executable("test_update_binary_abnormal") { 193 sources = [ "updater_test/test_update_binary_abnormal.cpp" ] 194 install_enable = true 195 part_name = "updater" 196 subsystem_name = "updater" 197} 198