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 20ohos_unittest("script_unittest") { 21 testonly = true 22 resource_config_file = "${updater_path}/test/unittest/test_data/ohos_test.xml" 23 module_out_path = MODULE_OUTPUT_PATH 24 sources = [ 25 "script_instruction/basic_instruction_unittest.cpp", 26 "script_instruction/script_instructionhelper_unittest.cpp", 27 "script_instruction/script_loadscript_unittest.cpp", 28 "script_instruction/script_registercmd_unittest.cpp", 29 "script_instruction/script_updateprocesser_unittest.cpp", 30 "script_interpreter_unittest.cpp", 31 "script_unittest.cpp", 32 "threadpool_unittest.cpp", 33 ] 34 sources += [ 35 "$root_out_dir/updater/updater/yacc/lexer.cpp", 36 "$root_out_dir/updater/updater/yacc/parser.cpp", 37 "${updater_path}/services/script/script_instruction/script_basicinstruction.cpp", 38 "${updater_path}/services/script/script_instruction/script_instructionhelper.cpp", 39 "${updater_path}/services/script/script_instruction/script_loadscript.cpp", 40 "${updater_path}/services/script/script_instruction/script_registercmd.cpp", 41 "${updater_path}/services/script/script_instruction/script_updateprocesser.cpp", 42 "${updater_path}/services/script/script_interpreter/script_context.cpp", 43 "${updater_path}/services/script/script_interpreter/script_expression.cpp", 44 "${updater_path}/services/script/script_interpreter/script_function.cpp", 45 "${updater_path}/services/script/script_interpreter/script_interpreter.cpp", 46 "${updater_path}/services/script/script_interpreter/script_param.cpp", 47 "${updater_path}/services/script/script_interpreter/script_scanner.cpp", 48 "${updater_path}/services/script/script_interpreter/script_statement.cpp", 49 "${updater_path}/services/script/script_manager/script_managerImpl.cpp", 50 "${updater_path}/services/script/script_manager/script_utils.cpp", 51 "${updater_path}/services/script/threadpool/threadpool.cpp", 52 ] 53 include_dirs = [ 54 "${updater_path}/interfaces/kits/include", 55 "${updater_path}/services/common", 56 "${updater_path}/services/include/package", 57 "${updater_path}/services/include/script", 58 "${updater_path}/services/include/log", 59 "${updater_path}/services/include/updater", 60 "${updater_path}/services/package/pkg_algorithm", 61 "${updater_path}/services/package/pkg_manager", 62 "${updater_path}/services/script/script_instruction", 63 "${updater_path}/services/script/script_interpreter", 64 "${updater_path}/services/script/script_manager", 65 "${updater_path}/services/script/threadpool", 66 "$root_out_dir/updater/updater/yacc", 67 "${updater_path}/test/unittest", 68 "${updater_path}/utils/include", 69 ] 70 71 deps = [ 72 "${updater_path}/interfaces/kits/packages:libpackageExt", 73 "${updater_path}/services/log:libupdaterlog", 74 "${updater_path}/services/package:libupdaterpackage", 75 "${updater_path}/services/script:gen_yacc", 76 "${updater_path}/utils:libutils", 77 ] 78 if (updater_cfg_file != "") { 79 deps += [ 80 "${updater_path}/test/unittest/script:user_instruction", 81 "${updater_path}/test/unittest/script:user_instruction_invalid", 82 ] 83 } 84 configs = [ "${updater_path}/test/unittest:utest_config" ] 85 external_deps = [ 86 "bounds_checking_function:libsec_static", 87 "bzip2:libbz2", 88 "c_utils:utils", 89 "googletest:gmock_main", 90 "googletest:gtest_main", 91 "hilog:libhilog", 92 "lz4:liblz4_static", 93 "openssl:libcrypto_shared", 94 "openssl:libssl_static", 95 "zlib:libz", 96 ] 97 install_enable = true 98 part_name = "updater" 99} 100 101ohos_shared_library("user_instruction") { 102 sources = [ "script_instruction/user_instruction/user_instruction.cpp" ] 103 output_extension = "so" 104 ldflags = [ "-rdynamic" ] 105 include_dirs = [ 106 "${updater_path}/interfaces/kits/include/", 107 "${updater_path}/services/common", 108 "${updater_path}/services/include", 109 "${updater_path}/services/include/package", 110 "${updater_path}/services/include/script", 111 "${updater_path}/services/script/script_instruction", 112 "${updater_path}/utils/include", 113 ] 114 install_enable = true 115 subsystem_name = "updater" 116 part_name = "updater" 117} 118 119ohos_shared_library("user_instruction_invalid") { 120 sources = 121 [ "script_instruction/user_instruction/user_instruction_invalid.cpp" ] 122 output_extension = "so" 123 ldflags = [ "-rdynamic" ] 124 include_dirs = [ 125 "${updater_path}/interfaces/kits/include/", 126 "${updater_path}/services/common", 127 "${updater_path}/services/include", 128 "${updater_path}/services/include/package", 129 "${updater_path}/services/include/script", 130 "${updater_path}/services/script/script_instruction", 131 "${updater_path}/utils/include", 132 ] 133 install_enable = true 134 subsystem_name = "updater" 135 part_name = "updater" 136} 137