1fb299fa2Sopenharmony_ci# Copyright (c) 2022 Huawei Device Co., Ltd. 2fb299fa2Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 3fb299fa2Sopenharmony_ci# you may not use this file except in compliance with the License. 4fb299fa2Sopenharmony_ci# You may obtain a copy of the License at 5fb299fa2Sopenharmony_ci# 6fb299fa2Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 7fb299fa2Sopenharmony_ci# 8fb299fa2Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 9fb299fa2Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 10fb299fa2Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11fb299fa2Sopenharmony_ci# See the License for the specific language governing permissions and 12fb299fa2Sopenharmony_ci# limitations under the License. 13fb299fa2Sopenharmony_ci 14fb299fa2Sopenharmony_ciimport("//base/update/updater/updater_default_cfg.gni") 15fb299fa2Sopenharmony_ciimport("//build/test.gni") 16fb299fa2Sopenharmony_ci 17fb299fa2Sopenharmony_cimodule_output_path = "updater/updater_test" 18fb299fa2Sopenharmony_ciupdater_path = rebase_path("${updater_absolutely_path}", ".") 19fb299fa2Sopenharmony_ci 20fb299fa2Sopenharmony_ciconfig("utest_config") { 21fb299fa2Sopenharmony_ci visibility = [ "./*" ] 22fb299fa2Sopenharmony_ci visibility += [ 23fb299fa2Sopenharmony_ci "//base/startup/appspawn/test/unittest/*", 24fb299fa2Sopenharmony_ci "//base/startup/init/test/unittest/*", 25fb299fa2Sopenharmony_ci "//base/update/sys_installer/test/unittest/*", 26fb299fa2Sopenharmony_ci ] 27fb299fa2Sopenharmony_ci 28fb299fa2Sopenharmony_ci cflags = [ 29fb299fa2Sopenharmony_ci "--coverage", 30fb299fa2Sopenharmony_ci "-fprofile-arcs", 31fb299fa2Sopenharmony_ci "-Wno-implicit-fallthrough", 32fb299fa2Sopenharmony_ci "-Wno-unused-function", 33fb299fa2Sopenharmony_ci ] 34fb299fa2Sopenharmony_ci cflags_cc = [ 35fb299fa2Sopenharmony_ci "-Wno-implicit-fallthrough", 36fb299fa2Sopenharmony_ci "-fexceptions", 37fb299fa2Sopenharmony_ci ] 38fb299fa2Sopenharmony_ci 39fb299fa2Sopenharmony_ci ldflags = [ "--coverage" ] 40fb299fa2Sopenharmony_ci 41fb299fa2Sopenharmony_ci defines = [ 42fb299fa2Sopenharmony_ci "UPDATER_UT", 43fb299fa2Sopenharmony_ci "BUILD_OHOS", 44fb299fa2Sopenharmony_ci "HDC_DEBUG", 45fb299fa2Sopenharmony_ci "HDC_SUPPORT_FLASHD", 46fb299fa2Sopenharmony_ci "HARMONY_PROJECT", 47fb299fa2Sopenharmony_ci ] 48fb299fa2Sopenharmony_ci} 49fb299fa2Sopenharmony_ci 50fb299fa2Sopenharmony_ciohos_unittest("updater_unittest") { 51fb299fa2Sopenharmony_ci testonly = true 52fb299fa2Sopenharmony_ci resource_config_file = "${updater_path}/test/unittest/test_data/ohos_test.xml" 53fb299fa2Sopenharmony_ci module_out_path = module_output_path 54fb299fa2Sopenharmony_ci sources = [ 55fb299fa2Sopenharmony_ci "diffpatch/bzip2_unittest.cpp", 56fb299fa2Sopenharmony_ci "diffpatch/diffpatch_unittest.cpp", 57fb299fa2Sopenharmony_ci "diffpatch/image_patch_unittest.cpp", 58fb299fa2Sopenharmony_ci "log_test/log_unittest.cpp", 59fb299fa2Sopenharmony_ci "misc_info_test/misc_info_unittest.cpp", 60fb299fa2Sopenharmony_ci "updater_test/hwfault_retry_unittest.cpp", 61fb299fa2Sopenharmony_ci "updater_test/record_install_time_unittest.cpp", 62fb299fa2Sopenharmony_ci "updaterkits_test/updaterkits_unittest.cpp", 63fb299fa2Sopenharmony_ci ] 64fb299fa2Sopenharmony_ci 65fb299fa2Sopenharmony_ci sources += [ 66fb299fa2Sopenharmony_ci "$root_out_dir/updater/updater/yacc/lexer.cpp", 67fb299fa2Sopenharmony_ci "$root_out_dir/updater/updater/yacc/parser.cpp", 68fb299fa2Sopenharmony_ci "${updater_path}/interfaces/kits/misc_info/misc_info.cpp", 69fb299fa2Sopenharmony_ci "${updater_path}/interfaces/kits/packages/package.cpp", 70fb299fa2Sopenharmony_ci "${updater_path}/interfaces/kits/updaterkits/updaterkits.cpp", 71fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/bzip2/bzip2_adapter.cpp", 72fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/bzip2/lz4_adapter.cpp", 73fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/bzip2/zip_adapter.cpp", 74fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/diff/blocks_diff.cpp", 75fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/diff/image_diff.cpp", 76fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/diff/update_diff.cpp", 77fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/diffpatch.cpp", 78fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/patch/blocks_patch.cpp", 79fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/patch/image_patch.cpp", 80fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/patch/update_patch.cpp", 81fb299fa2Sopenharmony_ci "${updater_path}/services/hwfault_retry/hwfault_retry.cpp", 82fb299fa2Sopenharmony_ci "${updater_path}/services/log/log.cpp", 83fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_algorithm/pkg_algo_deflate.cpp", 84fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_algorithm/pkg_algo_digest.cpp", 85fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_algorithm/pkg_algo_lz4.cpp", 86fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_algorithm/pkg_algo_sign.cpp", 87fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_algorithm/pkg_algorithm.cpp", 88fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_manager/pkg_managerImpl.cpp", 89fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_manager/pkg_stream.cpp", 90fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_manager/pkg_utils.cpp", 91fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_package/pkg_gzipfile.cpp", 92fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_package/pkg_lz4file.cpp", 93fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_package/pkg_pkgfile.cpp", 94fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_package/pkg_upgradefile.cpp", 95fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_package/pkg_zipfile.cpp", 96fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_instruction/script_basicinstruction.cpp", 97fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_instruction/script_instructionhelper.cpp", 98fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_instruction/script_loadscript.cpp", 99fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_instruction/script_registercmd.cpp", 100fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_instruction/script_updateprocesser.cpp", 101fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_interpreter/script_context.cpp", 102fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_interpreter/script_expression.cpp", 103fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_interpreter/script_function.cpp", 104fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_interpreter/script_interpreter.cpp", 105fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_interpreter/script_param.cpp", 106fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_interpreter/script_scanner.cpp", 107fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_interpreter/script_statement.cpp", 108fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_manager/script_managerImpl.cpp", 109fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_manager/script_utils.cpp", 110fb299fa2Sopenharmony_ci "${updater_path}/services/script/threadpool/threadpool.cpp", 111fb299fa2Sopenharmony_ci "${updater_path}/services/updater_utils.cpp", 112fb299fa2Sopenharmony_ci "${updater_path}/utils/utils.cpp", 113fb299fa2Sopenharmony_ci ] 114fb299fa2Sopenharmony_ci 115fb299fa2Sopenharmony_ci include_dirs = [ 116fb299fa2Sopenharmony_ci "${updater_path}/interfaces/kits/include/", 117fb299fa2Sopenharmony_ci "${updater_path}/interfaces/kits/include/package", 118fb299fa2Sopenharmony_ci "${updater_path}/services/include/", 119fb299fa2Sopenharmony_ci "${updater_path}/utils/include/", 120fb299fa2Sopenharmony_ci "${updater_path}/utils/json/", 121fb299fa2Sopenharmony_ci "${updater_path}/services/", 122fb299fa2Sopenharmony_ci "${updater_path}/services/include/package", 123fb299fa2Sopenharmony_ci "${updater_path}/services/include/script", 124fb299fa2Sopenharmony_ci "${updater_path}/services/include/log", 125fb299fa2Sopenharmony_ci "${updater_path}/services/include/patch", 126fb299fa2Sopenharmony_ci "${updater_path}/services/include/updater", 127fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_instruction", 128fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_interpreter", 129fb299fa2Sopenharmony_ci "${updater_path}/services/script/script_manager", 130fb299fa2Sopenharmony_ci "${updater_path}/services/script/threadpool", 131fb299fa2Sopenharmony_ci "$root_out_dir/updater/updater/yacc", 132fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_algorithm", 133fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_manager", 134fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_package", 135fb299fa2Sopenharmony_ci "${updater_path}/services/package/pkg_verify", 136fb299fa2Sopenharmony_ci "${updater_path}/services/include/fs_manager", 137fb299fa2Sopenharmony_ci "${updater_path}/services/fs_manager", 138fb299fa2Sopenharmony_ci "${updater_path}/services/applypatch", 139fb299fa2Sopenharmony_ci "${updater_path}/services/common", 140fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch", 141fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/diff", 142fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/patch", 143fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/bzip2", 144fb299fa2Sopenharmony_ci "${updater_path}/services/ui", 145fb299fa2Sopenharmony_ci "${updater_path}/test/unittest", 146fb299fa2Sopenharmony_ci ] 147fb299fa2Sopenharmony_ci deps = [ 148fb299fa2Sopenharmony_ci "${updater_path}/interfaces/kits/misc_info:libmiscinfo", 149fb299fa2Sopenharmony_ci "${updater_path}/services/applypatch:libapplypatch", 150fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/diff:libdiff", 151fb299fa2Sopenharmony_ci "${updater_path}/services/diffpatch/patch:libpatch", 152fb299fa2Sopenharmony_ci "${updater_path}/services/fs_manager:libfsmanager", 153fb299fa2Sopenharmony_ci "${updater_path}/services/log:libupdaterlog", 154fb299fa2Sopenharmony_ci "${updater_path}/services/package:libupdaterpackage", 155fb299fa2Sopenharmony_ci "${updater_path}/utils:libutils", 156fb299fa2Sopenharmony_ci ] 157fb299fa2Sopenharmony_ci 158fb299fa2Sopenharmony_ci deps += [ 159fb299fa2Sopenharmony_ci "${updater_path}/services/script:gen_yacc", 160fb299fa2Sopenharmony_ci "${updater_path}/test/unittest:test_update_binary", 161fb299fa2Sopenharmony_ci "${updater_path}/test/unittest:test_update_binary_abnormal", 162fb299fa2Sopenharmony_ci ] 163fb299fa2Sopenharmony_ci 164fb299fa2Sopenharmony_ci external_deps = [ 165fb299fa2Sopenharmony_ci "bounds_checking_function:libsec_static", 166fb299fa2Sopenharmony_ci "bzip2:libbz2", 167fb299fa2Sopenharmony_ci "cJSON:cjson", 168fb299fa2Sopenharmony_ci "googletest:gmock_main", 169fb299fa2Sopenharmony_ci "googletest:gtest_main", 170fb299fa2Sopenharmony_ci "hilog:libhilog_base", 171fb299fa2Sopenharmony_ci "init:libbegetutil_static", 172fb299fa2Sopenharmony_ci "libuv:uv", 173fb299fa2Sopenharmony_ci "lz4:liblz4_static", 174fb299fa2Sopenharmony_ci "openssl:libcrypto_shared", 175fb299fa2Sopenharmony_ci "openssl:libssl_shared", 176fb299fa2Sopenharmony_ci "zlib:libz", 177fb299fa2Sopenharmony_ci ] 178fb299fa2Sopenharmony_ci 179fb299fa2Sopenharmony_ci public_configs = [ ":utest_config" ] 180fb299fa2Sopenharmony_ci install_enable = true 181fb299fa2Sopenharmony_ci part_name = "updater" 182fb299fa2Sopenharmony_ci defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] 183fb299fa2Sopenharmony_ci} 184fb299fa2Sopenharmony_ci 185fb299fa2Sopenharmony_ciohos_executable("test_update_binary") { 186fb299fa2Sopenharmony_ci sources = [ "updater_test/test_update_binary.cpp" ] 187fb299fa2Sopenharmony_ci install_enable = true 188fb299fa2Sopenharmony_ci part_name = "updater" 189fb299fa2Sopenharmony_ci subsystem_name = "updater" 190fb299fa2Sopenharmony_ci} 191fb299fa2Sopenharmony_ci 192fb299fa2Sopenharmony_ciohos_executable("test_update_binary_abnormal") { 193fb299fa2Sopenharmony_ci sources = [ "updater_test/test_update_binary_abnormal.cpp" ] 194fb299fa2Sopenharmony_ci install_enable = true 195fb299fa2Sopenharmony_ci part_name = "updater" 196fb299fa2Sopenharmony_ci subsystem_name = "updater" 197fb299fa2Sopenharmony_ci} 198