diff --git a/.github/workflows/build_linux_ubuntu2204.yml b/.github/workflows/build_linux_ubuntu2204.yml index f82e4cd98f..2adbd14f65 100644 --- a/.github/workflows/build_linux_ubuntu2204.yml +++ b/.github/workflows/build_linux_ubuntu2204.yml @@ -38,6 +38,19 @@ jobs: python3 tools/version/update_version_in_ten_framework.py python3 tools/version/check_version_in_ten_framework.py + - name: Set ulimit and sysctl + run: | + # Because there are concurrent test cases which involves many + # concurrent socket connections, we need to enlarge the maximum number + # of the opened file descriptor. + ulimit -n 102400 + + # Because there are concurrent test cases (in 'smoke' and + # 'integration') which will create many concurrent connections + # simutaneously, we increase the TCP listening backlog value to 8192. + sysctl -w net.core.somaxconn=8192 + shell: bash + - name: Build run: | export PATH=$(pwd)/core/ten_gn:$PATH @@ -45,7 +58,7 @@ jobs: go env -w GOFLAGS="-buildvcs=false" go1.20.12 download rustup default nightly - tgn gen linux x64 ${{ matrix.build_type }} -- is_clang=${{ matrix.compiler == 'gcc' && 'false' || 'true' }} log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true + tgn gen linux x64 ${{ matrix.build_type }} -- is_clang=${{ matrix.compiler == 'gcc' && 'false' || 'true' }} log_level=1 enable_serialized_actions=true ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true tgn build linux x64 ${{ matrix.build_type }} tree -I 'gen|obj' out @@ -126,6 +139,17 @@ jobs: cd out/linux/x64/ pytest -s tests/ten_manager/ + - name: Run tests (ten_runtime integration tests) + env: + ASAN_OPTIONS: detect_leaks=1:detect_stack_use_after_return=1:color=always:unmap_shadow_on_exit=1:abort_on_error=1 + MALLOC_CHECK_: 3 + TEN_ENABLE_MEMORY_TRACKING: "true" + TEN_ENABLE_BACKTRACE_DUMP: "true" + run: | + export PATH=$(pwd)/core/ten_gn:$PATH + cd out/linux/x64/ + pytest -s tests/ten_runtime/integration/ || { echo "ten_runtime integration test failed"; exit 1; } + - name: Update supports before upload or publish run: | UPDATE_SUPPORTS_SCRIPT=$(pwd)/tools/supports/update_supports_in_manifest_json.py diff --git a/.github/workflows/build_mac.yml b/.github/workflows/build_mac.yml index 83e206ce69..b4cf64a63f 100644 --- a/.github/workflows/build_mac.yml +++ b/.github/workflows/build_mac.yml @@ -76,7 +76,7 @@ jobs: fi export PATH=$(pwd)/core/ten_gn:$PATH echo $PATH - tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true + tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true tgn build mac arm64 ${{ matrix.build_type }} tree -I 'gen|obj' out @@ -220,7 +220,7 @@ jobs: fi export PATH=$(pwd)/core/ten_gn:$PATH echo $PATH - tgn gen mac x64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true + tgn gen mac x64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true tgn build mac x64 ${{ matrix.build_type }} tree -I 'gen|obj' out @@ -301,6 +301,17 @@ jobs: cd out/mac/x64/ pytest -s tests/ten_manager/ + - name: Run tests (ten_runtime integration tests) + env: + ASAN_OPTIONS: detect_stack_use_after_return=1:color=always:unmap_shadow_on_exit=1:abort_on_error=1 + MALLOC_CHECK_: 3 + TEN_ENABLE_MEMORY_TRACKING: "true" + TEN_ENABLE_BACKTRACE_DUMP: "true" + run: | + export PATH=$(pwd)/core/ten_gn:$PATH + cd out/mac/x64/ + pytest -s tests/ten_runtime/integration/ || { echo "ten_runtime integration test failed"; exit 1; } + # Building ten_runtime without the ten_rust library (i.e., ten_enable_ten_rust_apis=false). build-mac-arm64-without-ten-rust: concurrency: @@ -365,7 +376,7 @@ jobs: fi export PATH=$(pwd)/core/ten_gn:$PATH echo $PATH - tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_ten_rust_apis=false + tgn gen mac arm64 ${{ matrix.build_type }} -- log_level=1 enable_serialized_actions=true ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_ten_rust_apis=false tgn build mac arm64 ${{ matrix.build_type }} tree -I 'gen|obj' out diff --git a/.github/workflows/build_win.yml b/.github/workflows/build_win.yml index 4ff424926a..8c79ec52bd 100644 --- a/.github/workflows/build_win.yml +++ b/.github/workflows/build_win.yml @@ -49,7 +49,7 @@ jobs: - name: Build run: | $ENV:PATH += ";$PWD/core/ten_gn" - tgn gen win x64 ${{ matrix.build_type }} -- vs_version=2022 log_level=1 enable_serialized_actions=true ten_enable_integration_tests=false ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true + tgn gen win x64 ${{ matrix.build_type }} -- vs_version=2022 log_level=1 enable_serialized_actions=true ten_enable_private_tests=false ten_rust_enable_gen_cargo_config=false ten_enable_cargo_clean=true tgn build win x64 ${{ matrix.build_type }} - name: Run Tests (ten_utils_unit_test) diff --git a/.vscode/settings.json b/.vscode/settings.json index 79f0ccfd1c..c291b5d577 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -55,7 +55,8 @@ ], "python.analysis.completeFunctionParens": true, "python.analysis.extraPaths": [ - "./core/src/ten_runtime/binding/python/interface" + "./core/src/ten_runtime/binding/python/interface", + "./tests/ten_runtime/integration" ], "python.analysis.typeCheckingMode": "basic", "rust-analyzer.check.command": "clippy", diff --git a/build/options.gni b/build/options.gni index 5cff51ce64..8f110c9b51 100644 --- a/build/options.gni +++ b/build/options.gni @@ -18,4 +18,6 @@ declare_args() { ten_enable_package_manager = true ten_enable_cargo_clean = false + + ten_enable_integration_tests_prebuilt = false } diff --git a/build/ten_runtime/feature/build_pkg.py b/build/ten_runtime/feature/build_pkg.py index 8696abecfb..7b4e8bb351 100644 --- a/build/ten_runtime/feature/build_pkg.py +++ b/build/ten_runtime/feature/build_pkg.py @@ -178,30 +178,7 @@ def build_extension(args: ArgumentInfo) -> int: return returncode -if __name__ == "__main__": - parser = argparse.ArgumentParser() - - parser.add_argument("--pkg-src-root-dir", type=str, required=True) - parser.add_argument("--pkg-run-root-dir", type=str, required=False) - parser.add_argument("--tg-timestamp-proxy-file", type=str, required=True) - parser.add_argument("--pkg-name", type=str, required=True) - parser.add_argument("--pkg-language", type=str, required=True) - parser.add_argument("--os", type=str, required=True) - parser.add_argument("--cpu", type=str, required=True) - parser.add_argument("--build", type=str, required=True) - parser.add_argument("--tgn-path", type=str, required=False) - parser.add_argument("--is-clang", action=argparse.BooleanOptionalAction) - parser.add_argument( - "--enable-sanitizer", action=argparse.BooleanOptionalAction - ) - parser.add_argument("--vs-version", type=str, required=False) - parser.add_argument( - "--log-level", type=int, required=True, help="specify log level" - ) - - arg_info = ArgumentInfo() - args = parser.parse_args(namespace=arg_info) - +def build(args: ArgumentInfo) -> int: if args.log_level > 0: msg = ( f"> Start to build package({args.pkg_name})" @@ -227,18 +204,51 @@ def build_extension(args: ArgumentInfo) -> int: # Success to build the app, update the stamp file to represent this # fact. - timestamp_proxy.touch_timestamp_proxy_file(args.tg_timestamp_proxy_file) + if args.tg_timestamp_proxy_file: + timestamp_proxy.touch_timestamp_proxy_file( + args.tg_timestamp_proxy_file + ) if args.log_level > 0: print(f"Build {pkg_type}({args.pkg_name}) success") except Exception as e: returncode = 1 - timestamp_proxy.remove_timestamp_proxy_file( - args.tg_timestamp_proxy_file - ) + if args.tg_timestamp_proxy_file: + timestamp_proxy.remove_timestamp_proxy_file( + args.tg_timestamp_proxy_file + ) print(f"Build package({args.pkg_name}) failed: {repr(e)}") finally: os.chdir(origin_wd) - sys.exit(returncode) + + return returncode + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument("--pkg-src-root-dir", type=str, required=True) + parser.add_argument("--pkg-run-root-dir", type=str, required=False) + parser.add_argument("--tg-timestamp-proxy-file", type=str, required=False) + parser.add_argument("--pkg-name", type=str, required=True) + parser.add_argument("--pkg-language", type=str, required=True) + parser.add_argument("--os", type=str, required=True) + parser.add_argument("--cpu", type=str, required=True) + parser.add_argument("--build", type=str, required=True) + parser.add_argument("--tgn-path", type=str, required=False) + parser.add_argument("--is-clang", action=argparse.BooleanOptionalAction) + parser.add_argument( + "--enable-sanitizer", action=argparse.BooleanOptionalAction + ) + parser.add_argument("--vs-version", type=str, required=False) + parser.add_argument( + "--log-level", type=int, required=True, help="specify log level" + ) + + arg_info = ArgumentInfo() + args = parser.parse_args(namespace=arg_info) + + return_code = build(arg_info) + sys.exit(return_code) diff --git a/build/ten_runtime/feature/prepare_integration_test_resources.py b/build/ten_runtime/feature/prepare_integration_test_resources.py new file mode 100644 index 0000000000..f206709e2e --- /dev/null +++ b/build/ten_runtime/feature/prepare_integration_test_resources.py @@ -0,0 +1,145 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import argparse +import json +import sys +import os +from build.scripts import fs_utils + +assemble_info_dir = ".assemble_info" + + +class ArgumentInfo(argparse.Namespace): + def __init__(self): + self.test_case_out_dir: str + self.test_case_src_dir: str + self.src_app: str + self.src_app_language: str + self.generated_app_src_root_dir_name: str + self.replace_files_after_install_app: list[str] + self.replace_files_after_install_all: list[str] + + +def dump_integration_test_preparation_info_json(args: ArgumentInfo): + info = { + "test_case_src_dir": args.test_case_src_dir, + "src_app": args.src_app, + "src_app_language": args.src_app_language, + "generated_app_src_root_dir_name": args.generated_app_src_root_dir_name, + "replace_files_after_install_app": args.replace_files_after_install_app, + "replace_files_after_install_all": args.replace_files_after_install_all, + } + + resource_dir = os.path.join( + args.test_case_out_dir, + assemble_info_dir, + args.generated_app_src_root_dir_name, + ) + info_file = os.path.join(resource_dir, "info.json") + if not os.path.exists(resource_dir): + os.makedirs(resource_dir, exist_ok=True) + + with open(info_file, "w", encoding="utf-8") as f: + json.dump(info, f, ensure_ascii=False, indent=2) + + +def copy_replacement_files( + args: ArgumentInfo, replaced_files: list[str], dest_dir: str +): + if replaced_files is None: + return + + out_dir = os.path.join( + args.test_case_out_dir, + assemble_info_dir, + args.generated_app_src_root_dir_name, + dest_dir, + ) + + for file in replaced_files: + src_file = os.path.join(args.test_case_src_dir, file) + dst_file = os.path.join(out_dir, file) + if not os.path.exists(src_file): + print(f"File {src_file} does not exist") + continue + + if not os.path.exists(os.path.dirname(dst_file)): + os.makedirs(os.path.dirname(dst_file), exist_ok=True) + + fs_utils.copy(src_file, dst_file) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--test-case-out-dir", + type=str, + required=True, + help="Path to the test case output directory", + ) + + parser.add_argument( + "--test-case-src-dir", + type=str, + required=True, + help="Path to the test case source directory", + ) + + parser.add_argument( + "--src-app", + type=str, + required=True, + help="Path to the app source code", + ) + + parser.add_argument( + "--src-app-language", + type=str, + required=True, + help="Language of the app source code", + ) + + parser.add_argument( + "--generated-app-src-root-dir-name", + type=str, + required=True, + help="Name of the generated app source root directory", + ) + + parser.add_argument( + "--replace-files-after-install-app", + type=str, + action="append", + help="List of files to replace after installing app", + ) + + parser.add_argument( + "--replace-files-after-install-all", + type=str, + action="append", + help="List of files to replace after installing all", + ) + + arg_info = ArgumentInfo() + args = parser.parse_args(namespace=arg_info) + + dump_integration_test_preparation_info_json(args) + + copy_replacement_files( + args, + args.replace_files_after_install_app, + "files_to_be_replaced_after_install_app", + ) + + copy_replacement_files( + args, + args.replace_files_after_install_all, + "files_to_be_replaced_after_install_all", + ) + + sys.exit(0) diff --git a/build/ten_runtime/feature/test.gni b/build/ten_runtime/feature/test.gni index ecc0665a5a..a01deb05a5 100644 --- a/build/ten_runtime/feature/test.gni +++ b/build/ten_runtime/feature/test.gni @@ -5,6 +5,7 @@ # Refer to the "LICENSE" file in the root directory for more information. # import("//.gnfiles/build/feature/base_options.gni") +import("//build/options.gni") import("//core/src/ten_runtime/output_libs.gni") template("ten_package_test_prepare_app") { @@ -16,378 +17,441 @@ template("ten_package_test_prepare_app") { _target_name = target_name - test_case_root_dir_relative_path = + test_case_out_dir_rel_path_str = get_path_info(get_path_info(target_name, "abspath"), "dir") - test_case_root_dir = "${root_out_dir}/${test_case_root_dir_relative_path}" + test_case_out_dir_rel_path = + "${root_out_dir}/${test_case_out_dir_rel_path_str}" test_case_unique_target_name = - string_replace(test_case_root_dir_relative_path, "/", "_") + string_replace(test_case_out_dir_rel_path_str, "/", "_") - app_src_root_dir = - "${test_case_root_dir}/${invoker.generated_app_src_root_dir_name}" - app_run_root_dir = "${test_case_root_dir}/${_target_name}" + all_deps = [] - install_app_dummy_output_file = - "${target_gen_dir}/${_target_name}/install_app_dummy_output_file" - install_app_depfile = "${target_gen_dir}/install_app_depfile" + if (ten_enable_integration_tests_prebuilt) { + app_src_root_dir = "${test_case_out_dir_rel_path}/${invoker.generated_app_src_root_dir_name}" + app_run_root_dir = "${test_case_out_dir_rel_path}/${_target_name}" + install_app_dummy_output_file = + "${target_gen_dir}/${_target_name}/install_app_dummy_output_file" + install_app_depfile = "${target_gen_dir}/install_app_depfile" - action("${test_case_unique_target_name}_${_target_name}_install_app") { - script = "//build/ten_runtime/feature/install_pkg.py" + action("${test_case_unique_target_name}_${_target_name}_install_app") { + script = "//build/ten_runtime/feature/install_pkg.py" - args = [ "--tman-path" ] - if (is_win) { - args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman.exe") ] - } else { - args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman") ] - } + args = [ "--tman-path" ] + if (is_win) { + args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman.exe") ] + } else { + args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman") ] + } - args += [ - "--pkg-type", - "app", - "--pkg-src-root-dir", - rebase_path(app_src_root_dir), - "--src-pkg", - invoker.src_app, - "--tg-timestamp-proxy-file", - rebase_path(install_app_dummy_output_file), - ] + args += [ + "--pkg-type", + "app", + "--pkg-src-root-dir", + rebase_path(app_src_root_dir), + "--src-pkg", + invoker.src_app, + "--tg-timestamp-proxy-file", + rebase_path(install_app_dummy_output_file), + ] - args += [ "--build-type" ] - if (is_debug) { - args += [ "debug" ] - } else { - args += [ "release" ] - } + args += [ "--build-type" ] + if (is_debug) { + args += [ "debug" ] + } else { + args += [ "release" ] + } - args += [ - "--config-file", - rebase_path("${root_out_dir}/tests/local_registry/config.json"), - ] + args += [ + "--config-file", + rebase_path("${root_out_dir}/tests/local_registry/config.json"), + ] - args += [ - "--log-level", - "${log_level}", - ] + args += [ + "--log-level", + "${log_level}", + ] - args += [ - "--local-registry-path", - rebase_path("${root_out_dir}/tests/local_registry"), - ] + args += [ + "--local-registry-path", + rebase_path("${root_out_dir}/tests/local_registry"), + ] - if (invoker.deps != []) { - foreach(dep, invoker.deps) { + if (invoker.deps != []) { + foreach(dep, invoker.deps) { + args += [ + "--possible-published-results", + rebase_path(get_label_info(dep, "target_gen_dir")), + ] + } args += [ - "--possible-published-results", - rebase_path(get_label_info(dep, "target_gen_dir")), + "--depfile", + rebase_path(install_app_depfile), + "--depfile-target", + rebase_path(install_app_dummy_output_file, root_build_dir), ] } - args += [ - "--depfile", - rebase_path(install_app_depfile), - "--depfile-target", - rebase_path(install_app_dummy_output_file, root_build_dir), - ] - } - - sources = [] - outputs = [ install_app_dummy_output_file ] - depfile = install_app_depfile - - forward_variables_from(invoker, - [ - "deps", - "public_deps", - "data_deps", - ]) - if (!defined(deps)) { - deps = [] - } - deps += [ - "//build/ten_runtime/feature:create_tman_config", - "//core/src/ten_manager", - ] - } - - # replace_files_after_install_app - replace_files_after_install_app_deps = [] - replace_files_after_install_app_dests = [] + sources = [] + outputs = [ install_app_dummy_output_file ] + depfile = install_app_depfile - if (defined(invoker.replace_files_after_install_app) && - invoker.replace_files_after_install_app != []) { - replace_file_index = 0 + forward_variables_from(invoker, + [ + "deps", + "public_deps", + "data_deps", + ]) - foreach(replace_file, invoker.replace_files_after_install_app) { - replace_file_info = { + if (!defined(deps)) { + deps = [] } - replace_file_info = - exec_script("//.gnfiles/build/scripts/get_src_and_dest_file.py", - [ - "--input-string", - replace_file, - "--delimiter", - "=>", - "--delimiter", - "|", - ], - "json") - - replace_file_src_paths = [] - replace_file_src_paths = replace_file_info.sources - replace_file_src_path = replace_file_src_paths[0] - replace_file_dest_path = - "${test_case_root_dir}/${replace_file_info.destination}" - - replace_file_src_abs_path = rebase_path(replace_file_src_path) - replace_file_dest_abs_path = rebase_path(replace_file_dest_path) - - action( - "${test_case_unique_target_name}_${_target_name}_after_install_app_replace_file_${replace_file_index}") { - script = "//build/ten_runtime/feature/replace_normal_files_or_merge_json_files.py" - - args = [ - "--replaced-files", - "${replace_file_src_abs_path}=>${replace_file_dest_abs_path}", - ] - - # Wait for the completion of 'install_app'. - inputs = [] - sources = [ replace_file_src_path ] - outputs = [ replace_file_dest_path ] + deps += [ + "//build/ten_runtime/feature:create_tman_config", + "//core/src/ten_manager", + ] + } - # Need to wait the completion of the app construction phase. - deps = - [ ":${test_case_unique_target_name}_${_target_name}_install_app" ] + all_deps += + [ ":${test_case_unique_target_name}_${_target_name}_install_app" ] + + # replace_files_after_install_app + replace_files_after_install_app_deps = [] + replace_files_after_install_app_dests = [] + + if (defined(invoker.replace_files_after_install_app) && + invoker.replace_files_after_install_app != []) { + replace_file_index = 0 + + foreach(replace_file, invoker.replace_files_after_install_app) { + replace_file_info = { + } + replace_file_info = + exec_script("//.gnfiles/build/scripts/get_src_and_dest_file.py", + [ + "--input-string", + replace_file, + "--delimiter", + "=>", + "--delimiter", + "|", + ], + "json") + + replace_file_src_paths = [] + replace_file_src_paths = replace_file_info.sources + replace_file_src_path = replace_file_src_paths[0] + replace_file_dest_path = + "${test_case_out_dir_rel_path}/${replace_file_info.destination}" + + replace_file_src_abs_path = rebase_path(replace_file_src_path) + replace_file_dest_abs_path = rebase_path(replace_file_dest_path) + + action( + "${test_case_unique_target_name}_${_target_name}_after_install_app_replace_file_${replace_file_index}") { + script = "//build/ten_runtime/feature/replace_normal_files_or_merge_json_files.py" + + args = [ + "--replaced-files", + "${replace_file_src_abs_path}=>${replace_file_dest_abs_path}", + ] + + # Wait for the completion of 'install_app'. + inputs = [] + sources = [ replace_file_src_path ] + outputs = [ replace_file_dest_path ] + + # Need to wait the completion of the app construction phase. + deps = + [ ":${test_case_unique_target_name}_${_target_name}_install_app" ] + } + + replace_files_after_install_app_deps += [ ":${test_case_unique_target_name}_${_target_name}_after_install_app_replace_file_${replace_file_index}" ] + replace_files_after_install_app_dests += [ replace_file_dest_path ] + + replace_file_index += 1 } - - replace_files_after_install_app_deps += [ ":${test_case_unique_target_name}_${_target_name}_after_install_app_replace_file_${replace_file_index}" ] - replace_files_after_install_app_dests += [ replace_file_dest_path ] - - replace_file_index += 1 } - } - install_all_dummy_output_file = - "${target_gen_dir}/${_target_name}/install_all_dummy_output_file" + install_all_dummy_output_file = + "${target_gen_dir}/${_target_name}/install_all_dummy_output_file" - action("${test_case_unique_target_name}_${_target_name}_install_all") { - script = "//build/ten_runtime/feature/install_all.py" + action("${test_case_unique_target_name}_${_target_name}_install_all") { + script = "//build/ten_runtime/feature/install_all.py" - args = [ "--tman-path" ] - if (is_win) { - args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman.exe") ] - } else { - args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman") ] - } + args = [ "--tman-path" ] + if (is_win) { + args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman.exe") ] + } else { + args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman") ] + } - args += [ - "--pkg-src-root-dir", - rebase_path(app_src_root_dir), - ] + args += [ + "--pkg-src-root-dir", + rebase_path(app_src_root_dir), + ] - args += [ - "--tg-timestamp-proxy-file", - rebase_path(install_all_dummy_output_file), - ] + args += [ + "--tg-timestamp-proxy-file", + rebase_path(install_all_dummy_output_file), + ] - args += [ "--build-type" ] - if (is_debug) { - args += [ "debug" ] - } else { - args += [ "release" ] - } + args += [ "--build-type" ] + if (is_debug) { + args += [ "debug" ] + } else { + args += [ "release" ] + } - args += [ - "--assume-yes", - "True", - ] + args += [ + "--assume-yes", + "True", + ] - args += [ - "--config-file", - rebase_path("${root_out_dir}/tests/local_registry/config.json"), - ] + args += [ + "--config-file", + rebase_path("${root_out_dir}/tests/local_registry/config.json"), + ] - args += [ - "--log-level", - "${log_level}", - ] + args += [ + "--log-level", + "${log_level}", + ] - sources = replace_files_after_install_app_dests - outputs = [ install_all_dummy_output_file ] + sources = replace_files_after_install_app_dests + outputs = [ install_all_dummy_output_file ] - forward_variables_from(invoker, - [ - "deps", - "public_deps", - "data_deps", - ]) + forward_variables_from(invoker, + [ + "deps", + "public_deps", + "data_deps", + ]) - if (!defined(deps)) { - deps = [] + if (!defined(deps)) { + deps = [] + } + deps += [ + ":${test_case_unique_target_name}_${_target_name}_install_app", + "//build/ten_runtime/feature:create_tman_config", + "//core/src/ten_manager", + ] + replace_files_after_install_app_deps + } + + all_deps += + [ ":${test_case_unique_target_name}_${_target_name}_install_all" ] + + # =============================== + # replace_files_after_install_all + replace_files_after_install_all_deps = [] + replace_files_after_install_all_dests = [] + + if (defined(invoker.replace_files_after_install_all) && + invoker.replace_files_after_install_all != []) { + replace_file_index = 0 + + foreach(replace_file, invoker.replace_files_after_install_all) { + replace_file_info = { + } + replace_file_info = + exec_script("//.gnfiles/build/scripts/get_src_and_dest_file.py", + [ + "--input-string", + replace_file, + "--delimiter", + "=>", + "--delimiter", + "|", + ], + "json") + + replace_file_src_paths = [] + replace_file_src_paths = replace_file_info.sources + replace_file_src_path = replace_file_src_paths[0] + replace_file_dest_path = + "${test_case_out_dir_rel_path}/${replace_file_info.destination}" + + replace_file_src_abs_path = rebase_path(replace_file_src_path) + replace_file_dest_abs_path = rebase_path(replace_file_dest_path) + + action( + "${test_case_unique_target_name}_${_target_name}_after_install_all_replace_file_${replace_file_index}") { + script = "//build/ten_runtime/feature/replace_normal_files_or_merge_json_files.py" + args = [ + "--replaced-files", + "${replace_file_src_abs_path}=>${replace_file_dest_abs_path}", + ] + + sources = [ replace_file_src_path ] + outputs = [ replace_file_dest_path ] + + deps = [ + ":${test_case_unique_target_name}_${_target_name}_install_all", + ":${test_case_unique_target_name}_${_target_name}_install_app", + ] + } + + replace_files_after_install_all_deps += [ ":${test_case_unique_target_name}_${_target_name}_after_install_all_replace_file_${replace_file_index}" ] + replace_files_after_install_all_dests += [ replace_file_dest_path ] + + replace_file_index += 1 + } } - deps += [ - ":${test_case_unique_target_name}_${_target_name}_install_app", - "//build/ten_runtime/feature:create_tman_config", - "//core/src/ten_manager", - ] + replace_files_after_install_app_deps - } - # =============================== - # replace_files_after_install_all - replace_files_after_install_all_deps = [] - replace_files_after_install_all_dests = [] - - if (defined(invoker.replace_files_after_install_all) && - invoker.replace_files_after_install_all != []) { - replace_file_index = 0 + # App building phase. + build_app_dummy_output_file = + "${target_gen_dir}/${_target_name}/build_app_dummy_output_file" + + action("${test_case_unique_target_name}_${_target_name}_build") { + script = "//build/ten_runtime/feature/build_pkg.py" + + print("Building app: ${invoker.generated_app_src_root_dir_name}") + + args = [ + "--pkg-src-root-dir", + rebase_path(app_src_root_dir), + "--pkg-run-root-dir", + rebase_path(app_run_root_dir), + "--tg-timestamp-proxy-file", + rebase_path(build_app_dummy_output_file), + "--log-level", + "${log_level}", + "--pkg-name", + invoker.generated_app_src_root_dir_name, + "--pkg-language", + invoker.src_app_language, + "--os", + target_os, + "--cpu", + target_cpu, + "--build", + ] - foreach(replace_file, invoker.replace_files_after_install_all) { - replace_file_info = { + if (is_debug) { + args += [ "debug" ] + } else { + args += [ "release" ] } - replace_file_info = - exec_script("//.gnfiles/build/scripts/get_src_and_dest_file.py", - [ - "--input-string", - replace_file, - "--delimiter", - "=>", - "--delimiter", - "|", - ], - "json") - - replace_file_src_paths = [] - replace_file_src_paths = replace_file_info.sources - replace_file_src_path = replace_file_src_paths[0] - replace_file_dest_path = - "${test_case_root_dir}/${replace_file_info.destination}" - - replace_file_src_abs_path = rebase_path(replace_file_src_path) - replace_file_dest_abs_path = rebase_path(replace_file_dest_path) - - action( - "${test_case_unique_target_name}_${_target_name}_after_install_all_replace_file_${replace_file_index}") { - script = "//build/ten_runtime/feature/replace_normal_files_or_merge_json_files.py" - args = [ - "--replaced-files", - "${replace_file_src_abs_path}=>${replace_file_dest_abs_path}", - ] - sources = [ replace_file_src_path ] - outputs = [ replace_file_dest_path ] - - deps = [ - ":${test_case_unique_target_name}_${_target_name}_install_all", - ":${test_case_unique_target_name}_${_target_name}_install_app", + if (is_win) { + args += [ + "--vs-version", + "$vs_version", ] } - replace_files_after_install_all_deps += [ ":${test_case_unique_target_name}_${_target_name}_after_install_all_replace_file_${replace_file_index}" ] - replace_files_after_install_all_dests += [ replace_file_dest_path ] + if (is_clang) { + args += [ "--is-clang" ] + } else { + args += [ "--no-is-clang" ] + } - replace_file_index += 1 - } - } + if (enable_sanitizer) { + args += [ "--enable-sanitizer" ] + } else { + args += [ "--no-enable-sanitizer" ] + } - # App building phase. - build_app_dummy_output_file = - "${target_gen_dir}/${_target_name}/build_app_dummy_output_file" + if (invoker.src_app_language == "cpp") { + args += [ "--tgn-path" ] - action("${test_case_unique_target_name}_${_target_name}_build") { - script = "//build/ten_runtime/feature/build_pkg.py" + if (is_win) { + args += [ rebase_path("//core/ten_gn/tgn.bat") ] + } else { + args += [ rebase_path("//core/ten_gn/tgn") ] + } + } - args = [ - "--pkg-src-root-dir", - rebase_path(app_src_root_dir), - "--pkg-run-root-dir", - rebase_path(app_run_root_dir), - "--tg-timestamp-proxy-file", - rebase_path(build_app_dummy_output_file), - "--log-level", - "${log_level}", - "--pkg-name", - invoker.generated_app_src_root_dir_name, - "--pkg-language", - invoker.src_app_language, - "--os", - target_os, - "--cpu", - target_cpu, - "--build", - ] + sources = replace_files_after_install_app_dests + + replace_files_after_install_all_dests + outputs = [ build_app_dummy_output_file ] - if (is_debug) { - args += [ "debug" ] - } else { - args += [ "release" ] - } + forward_variables_from(invoker, + [ + "deps", + "public_deps", + "data_deps", + ]) - if (is_win) { - args += [ - "--vs-version", - "$vs_version", + if (!defined(deps)) { + deps = [] + } + deps += [ + ":${test_case_unique_target_name}_${_target_name}_install_all", + ":${test_case_unique_target_name}_${_target_name}_install_app", + ] + replace_files_after_install_app_deps + + replace_files_after_install_all_deps + } + + all_deps += [ ":${test_case_unique_target_name}_${_target_name}_build" ] + } else { + action( + "${test_case_unique_target_name}_${_target_name}_prepare_integration_test_resources") { + script = + "//build/ten_runtime/feature/prepare_integration_test_resources.py" + + test_case_out_dir_abs_path = + rebase_path("${root_out_dir}/${test_case_out_dir_rel_path_str}") + + args = [ + "--test-case-src-dir", + rebase_path("."), + "--test-case-out-dir", + test_case_out_dir_abs_path, + "--src-app", + invoker.src_app, + "--src-app-language", + invoker.src_app_language, + "--generated-app-src-root-dir-name", + invoker.generated_app_src_root_dir_name, ] - } - - if (is_clang) { - args += [ "--is-clang" ] - } else { - args += [ "--no-is-clang" ] - } - if (enable_sanitizer) { - args += [ "--enable-sanitizer" ] - } else { - args += [ "--no-enable-sanitizer" ] - } - - if (invoker.src_app_language == "cpp") { - args += [ "--tgn-path" ] - - if (is_win) { - args += [ rebase_path("//core/ten_gn/tgn.bat") ] - } else { - args += [ rebase_path("//core/ten_gn/tgn") ] + if (defined(invoker.replace_files_after_install_app) && + invoker.replace_files_after_install_app != []) { + foreach(replace_file, invoker.replace_files_after_install_app) { + args += [ + "--replace-files-after-install-app", + replace_file, + ] + } } - } - sources = replace_files_after_install_app_dests + - replace_files_after_install_all_dests - outputs = [ build_app_dummy_output_file ] + if (defined(invoker.replace_files_after_install_all) && + invoker.replace_files_after_install_all != []) { + foreach(replace_file, invoker.replace_files_after_install_all) { + args += [ + "--replace-files-after-install-all", + replace_file, + ] + } + } - forward_variables_from(invoker, - [ - "deps", - "public_deps", - "data_deps", - ]) + sources = [] + outputs = [ "${test_case_out_dir_rel_path}/.assemble_info/${invoker.generated_app_src_root_dir_name}" ] - if (!defined(deps)) { - deps = [] + deps = invoker.deps } - deps += [ - ":${test_case_unique_target_name}_${_target_name}_install_all", - ":${test_case_unique_target_name}_${_target_name}_install_app", - ] + replace_files_after_install_app_deps + - replace_files_after_install_all_deps + + all_deps += [ ":${test_case_unique_target_name}_${_target_name}_prepare_integration_test_resources" ] } group("${_target_name}") { - deps = [ ":${test_case_unique_target_name}_${_target_name}_build" ] + deps = all_deps } } template("ten_package_test_prepare_client") { _target_name = target_name - test_case_root_dir_relative_path = + test_case_out_dir_rel_path_str = get_path_info(get_path_info(target_name, "abspath"), "dir") test_case_unique_target_name = - string_replace(test_case_root_dir_relative_path, "/", "_") - test_case_root_dir = "${root_out_dir}/${test_case_root_dir_relative_path}" + string_replace(test_case_out_dir_rel_path_str, "/", "_") + test_case_out_dir_rel_path = + "${root_out_dir}/${test_case_out_dir_rel_path_str}" executable("${test_case_unique_target_name}_client_${target_name}") { - output_dir = "${test_case_root_dir}" + output_dir = "${test_case_out_dir_rel_path}" output_name = _target_name forward_variables_from(invoker, @@ -458,11 +522,12 @@ template("ten_package_test_prepare_client") { } template("ten_package_test_prepare_auxiliary_resources") { - test_case_root_dir_relative_path = + test_case_out_dir_rel_path_str = get_path_info(get_path_info(target_name, "abspath"), "dir") - test_case_root_dir = "${root_out_dir}/${test_case_root_dir_relative_path}" + test_case_out_dir_rel_path = + "${root_out_dir}/${test_case_out_dir_rel_path_str}" test_case_unique_target_name = - string_replace(test_case_root_dir_relative_path, "/", "_") + string_replace(test_case_out_dir_rel_path_str, "/", "_") # The collection of all the deps related to the specified resources. res_deps = [] @@ -489,7 +554,8 @@ template("ten_package_test_prepare_auxiliary_resources") { resource_src_paths = [] resource_src_paths = resource_info.sources resource_src_path = resource_src_paths[0] - resource_dest_path = "${test_case_root_dir}/${resource_info.destination}" + resource_dest_path = + "${test_case_out_dir_rel_path}/${resource_info.destination}" action( "${test_case_unique_target_name}_${target_name}_resource_${resource_index}") { @@ -534,14 +600,15 @@ template("ten_package_standalone_pkg") { _target_name = target_name - test_case_root_dir_relative_path = + test_case_out_dir_rel_path_str = get_path_info(get_path_info(target_name, "abspath"), "dir") - test_case_root_dir = "${root_out_dir}/${test_case_root_dir_relative_path}" + test_case_out_dir_rel_path = + "${root_out_dir}/${test_case_out_dir_rel_path_str}" test_case_unique_target_name = - string_replace(test_case_root_dir_relative_path, "/", "_") + string_replace(test_case_out_dir_rel_path_str, "/", "_") - pkg_root_dir = "${test_case_root_dir}/${_target_name}" + pkg_root_dir = "${test_case_out_dir_rel_path}/${_target_name}" install_standalone_dummy_output_file = "${target_gen_dir}/${_target_name}/install_standalone_dummy_output_file" diff --git a/core/include_internal/ten_runtime/binding/python/common/common.h b/core/include_internal/ten_runtime/binding/python/common/common.h index 59647682f7..8eed4fcee3 100644 --- a/core/include_internal/ten_runtime/binding/python/common/common.h +++ b/core/include_internal/ten_runtime/binding/python/common/common.h @@ -16,10 +16,6 @@ TEN_RUNTIME_PRIVATE_API void ten_py_initialize_with_config( const char *program, ten_list_t *module_search_path); -TEN_RUNTIME_PRIVATE_API void ten_py_set_program_name(const char *program_name); - -TEN_RUNTIME_PRIVATE_API void ten_py_set_argv(int argc, char **argv); - TEN_RUNTIME_PRIVATE_API void ten_py_run_file(const char *file_path); // This function is meant to ensure that the current thread is ready to call diff --git a/core/src/ten_runtime/binding/go/interface/ten/msg_property.go b/core/src/ten_runtime/binding/go/interface/ten/msg_property.go index 930694f4fa..dfb964edf5 100644 --- a/core/src/ten_runtime/binding/go/interface/ten/msg_property.go +++ b/core/src/ten_runtime/binding/go/interface/ten/msg_property.go @@ -171,14 +171,16 @@ func (p *msg) GetPropertyInt8(path string) (int8, error) { ) } - return getPropInt8(func(v *C.int8_t) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_int8( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[int8](func() (int8, error) { + return getPropInt8(func(v *C.int8_t) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_int8( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) } @@ -190,14 +192,16 @@ func (p *msg) GetPropertyInt16(path string) (int16, error) { ) } - return getPropInt16(func(v *C.int16_t) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_int16( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[int16](func() (int16, error) { + return getPropInt16(func(v *C.int16_t) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_int16( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) } @@ -209,14 +213,16 @@ func (p *msg) GetPropertyInt32(path string) (int32, error) { ) } - return getPropInt32(func(v *C.int32_t) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_int32( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[int32](func() (int32, error) { + return getPropInt32(func(v *C.int32_t) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_int32( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) } @@ -228,14 +234,16 @@ func (p *msg) GetPropertyInt64(path string) (int64, error) { ) } - return getPropInt64(func(v *C.int64_t) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_int64( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[int64](func() (int64, error) { + return getPropInt64(func(v *C.int64_t) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_int64( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) } @@ -247,15 +255,18 @@ func (p *msg) GetPropertyUint8(path string) (uint8, error) { ) } - return getPropUint8(func(v *C.uint8_t) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_uint8( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[uint8](func() (uint8, error) { + return getPropUint8(func(v *C.uint8_t) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_uint8( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) + } func (p *msg) GetPropertyUint16(path string) (uint16, error) { @@ -266,14 +277,16 @@ func (p *msg) GetPropertyUint16(path string) (uint16, error) { ) } - return getPropUint16(func(v *C.uint16_t) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_uint16( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[uint16](func() (uint16, error) { + return getPropUint16(func(v *C.uint16_t) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_uint16( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) } @@ -285,14 +298,16 @@ func (p *msg) GetPropertyUint32(path string) (uint32, error) { ) } - return getPropUint32(func(v *C.uint32_t) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_uint32( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[uint32](func() (uint32, error) { + return getPropUint32(func(v *C.uint32_t) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_uint32( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) } @@ -304,15 +319,18 @@ func (p *msg) GetPropertyUint64(path string) (uint64, error) { ) } - return getPropUint64(func(v *C.uint64_t) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_uint64( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[uint64](func() (uint64, error) { + return getPropUint64(func(v *C.uint64_t) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_uint64( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) + } func (p *msg) GetPropertyFloat32(path string) (float32, error) { @@ -323,14 +341,16 @@ func (p *msg) GetPropertyFloat32(path string) (float32, error) { ) } - return getPropFloat32(func(v *C.float) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_float32( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[float32](func() (float32, error) { + return getPropFloat32(func(v *C.float) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_float32( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) } @@ -342,14 +362,16 @@ func (p *msg) GetPropertyFloat64(path string) (float64, error) { ) } - return getPropFloat64(func(v *C.double) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_float64( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[float64](func() (float64, error) { + return getPropFloat64(func(v *C.double) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_float64( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) } @@ -361,14 +383,16 @@ func (p *msg) GetPropertyBool(path string) (bool, error) { ) } - return getPropBool(func(v *C.bool) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_bool( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[bool](func() (bool, error) { + return getPropBool(func(v *C.bool) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_bool( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) } @@ -380,15 +404,18 @@ func (p *msg) GetPropertyPtr(path string) (any, error) { ) } - return getPropPtr(func(v *cHandle) C.ten_go_error_t { - defer p.keepAlive() - return C.ten_go_msg_property_get_ptr( - p.cPtr, - unsafe.Pointer(unsafe.StringData(path)), - C.int(len(path)), - v, - ) + return withCGOLimiterHasReturnValue[any](func() (any, error) { + return getPropPtr(func(v *cHandle) C.ten_go_error_t { + defer p.keepAlive() + return C.ten_go_msg_property_get_ptr( + p.cPtr, + unsafe.Pointer(unsafe.StringData(path)), + C.int(len(path)), + v, + ) + }) }) + } func (p *msg) setPropertyString(path string, value string) error { diff --git a/core/src/ten_runtime/binding/python/native/common/common.c b/core/src/ten_runtime/binding/python/native/common/common.c index d4fd16343a..0d0331bba7 100644 --- a/core/src/ten_runtime/binding/python/native/common/common.c +++ b/core/src/ten_runtime/binding/python/native/common/common.c @@ -74,24 +74,6 @@ void ten_py_initialize_with_config(const char *program, int ten_py_finalize(void) { return Py_FinalizeEx(); } -void ten_py_set_program_name(const char *program_name) { - Py_SetProgramName(Py_DecodeLocale(program_name, NULL)); -} - -void ten_py_set_argv(int argc, char **argv) { - // Convert char** to wchar_t** - wchar_t **argv_wide = PyMem_Malloc(sizeof(wchar_t *) * argc); - for (int i = 0; i < argc; i++) { - argv_wide[i] = Py_DecodeLocale(argv[i], NULL); - } - - PySys_SetArgv(argc, argv_wide); - - for (int i = 0; i < argc; i++) { - PyMem_Free(argv_wide[i]); - } -} - void ten_py_add_paths_to_sys(ten_list_t *paths) { PyObject *sys_module = PyImport_ImportModule("sys"); if (sys_module == NULL) { diff --git a/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_audio_frame.c b/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_audio_frame.c index 82f4365bc4..a9aa18b8dc 100644 --- a/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_audio_frame.c +++ b/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_audio_frame.c @@ -140,6 +140,7 @@ static void ten_env_proxy_notify_send_audio_frame(ten_env_t *ten_env, TEN_ASSERT(!err_occurred, "Should not happen."); Py_XDECREF(arglist); + Py_XDECREF(notify_info->py_cb_func); ten_py_error_invalidate(py_err); @@ -186,6 +187,10 @@ PyObject *ten_py_ten_env_send_audio_frame(PyObject *self, PyObject *args) { if (!ten_env_proxy_notify(py_ten_env->c_ten_env_proxy, ten_env_proxy_notify_send_audio_frame, notify_info, false, &err)) { + if (cb_func) { + Py_XDECREF(cb_func); + } + ten_env_notify_send_audio_frame_info_destroy(notify_info); success = false; ten_py_raise_py_runtime_error_exception("Failed to send audio_frame."); diff --git a/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_cmd.c b/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_cmd.c index c395078989..40c9f6ad5c 100644 --- a/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_cmd.c +++ b/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_cmd.c @@ -44,6 +44,20 @@ static ten_env_notify_send_cmd_info_t *ten_env_notify_send_cmd_info_create( return info; } +static void ten_env_notify_send_cmd_info_destroy( + ten_env_notify_send_cmd_info_t *info) { + TEN_ASSERT(info, "Invalid argument."); + + if (info->c_cmd) { + ten_shared_ptr_destroy(info->c_cmd); + info->c_cmd = NULL; + } + + info->py_cb_func = NULL; + + TEN_FREE(info); +} + static void proxy_send_xxx_callback(ten_env_t *ten_env, ten_shared_ptr_t *cmd_result, void *callback_info, ten_error_t *err) { @@ -102,20 +116,6 @@ static void proxy_send_xxx_callback(ten_env_t *ten_env, ten_py_gil_state_release(prev_state); } -static void ten_env_notify_send_cmd_info_destroy( - ten_env_notify_send_cmd_info_t *info) { - TEN_ASSERT(info, "Invalid argument."); - - if (info->c_cmd) { - ten_shared_ptr_destroy(info->c_cmd); - info->c_cmd = NULL; - } - - info->py_cb_func = NULL; - - TEN_FREE(info); -} - static void ten_env_proxy_notify_send_cmd(ten_env_t *ten_env, void *user_data) { TEN_ASSERT(user_data, "Invalid argument."); TEN_ASSERT(ten_env && ten_env_check_integrity(ten_env, true), @@ -165,6 +165,7 @@ static void ten_env_proxy_notify_send_cmd(ten_env_t *ten_env, void *user_data) { TEN_ASSERT(!err_occurred, "Should not happen."); Py_XDECREF(arglist); + Py_XDECREF(notify_info->py_cb_func); ten_py_error_invalidate(py_err); @@ -216,6 +217,10 @@ PyObject *ten_py_ten_env_send_cmd(PyObject *self, PyObject *args) { if (!ten_env_proxy_notify(py_ten_env->c_ten_env_proxy, ten_env_proxy_notify_send_cmd, notify_info, false, &err)) { + if (cb_func) { + Py_XDECREF(cb_func); + } + ten_env_notify_send_cmd_info_destroy(notify_info); success = false; ten_py_raise_py_runtime_error_exception("Failed to send cmd."); diff --git a/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_data.c b/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_data.c index efa7cfc79d..bddd30ef52 100644 --- a/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_data.c +++ b/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_data.c @@ -138,6 +138,7 @@ static void ten_env_proxy_notify_send_data(ten_env_t *ten_env, TEN_ASSERT(!err_occurred, "Should not happen."); Py_XDECREF(arglist); + Py_XDECREF(notify_info->py_cb_func); ten_py_error_invalidate(py_err); @@ -183,6 +184,10 @@ PyObject *ten_py_ten_env_send_data(PyObject *self, PyObject *args) { if (!ten_env_proxy_notify(py_ten_env->c_ten_env_proxy, ten_env_proxy_notify_send_data, notify_info, false, &err)) { + if (cb_func) { + Py_XDECREF(cb_func); + } + ten_env_notify_send_data_info_destroy(notify_info); success = false; ten_py_raise_py_runtime_error_exception("Failed to send data."); diff --git a/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_video_frame.c b/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_video_frame.c index 97d6764079..1268e7f3b8 100644 --- a/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_video_frame.c +++ b/core/src/ten_runtime/binding/python/native/ten_env/ten_env_send_video_frame.c @@ -140,6 +140,7 @@ static void ten_env_proxy_notify_send_video_frame(ten_env_t *ten_env, TEN_ASSERT(!err_occurred, "Should not happen."); Py_XDECREF(arglist); + Py_XDECREF(notify_info->py_cb_func); ten_py_error_invalidate(py_err); @@ -186,6 +187,10 @@ PyObject *ten_py_ten_env_send_video_frame(PyObject *self, PyObject *args) { if (!ten_env_proxy_notify(py_ten_env->c_ten_env_proxy, ten_env_proxy_notify_send_video_frame, notify_info, false, &err)) { + if (cb_func) { + Py_XDECREF(cb_func); + } + ten_env_notify_send_video_frame_info_destroy(notify_info); success = false; ten_py_raise_py_runtime_error_exception("Failed to send video_frame."); diff --git a/core/ten_gn b/core/ten_gn index 6ea227cc10..e30f065acf 160000 --- a/core/ten_gn +++ b/core/ten_gn @@ -1 +1 @@ -Subproject commit 6ea227cc1048433ecdcc5f642fbac14335cefaf3 +Subproject commit e30f065acf731becc56c0e90e1fb1838d2849214 diff --git a/tests/ten_runtime/integration/common/build_config.py b/tests/ten_runtime/integration/common/build_config.py index 16c92cf256..9360ecedef 100644 --- a/tests/ten_runtime/integration/common/build_config.py +++ b/tests/ten_runtime/integration/common/build_config.py @@ -5,16 +5,35 @@ # Refer to the "LICENSE" file in the root directory for more information. # class BuildConfig: - def __init__(self, target_os, target_cpu, target_build): + def __init__( + self, + target_os, + target_cpu, + target_build, + is_clang, + enable_sanitizer, + vs_version, + ten_enable_integration_tests_prebuilt, + ): self.target_os = target_os self.target_cpu = target_cpu self.target_build = target_build + self.is_clang = is_clang + self.enable_sanitizer = enable_sanitizer + self.vs_version = vs_version + self.ten_enable_integration_tests_prebuilt = ( + ten_enable_integration_tests_prebuilt + ) -def parse_build_config(file_path: str): +def parse_build_config(file_path: str) -> BuildConfig: target_os = None target_cpu = None is_debug = None + is_clang = None + enable_sanitizer = None + vs_version = None + ten_enable_integration_tests_prebuilt = None with open(file_path, "r") as file: for line in file: @@ -25,7 +44,25 @@ def parse_build_config(file_path: str): target_cpu = line.split("=")[1].strip().strip('"') elif line.startswith("is_debug"): is_debug = line.split("=")[1].strip().lower() == "true" + elif line.startswith("is_clang"): + is_clang = line.split("=")[1].strip().lower() == "true" + elif line.startswith("enable_sanitizer"): + enable_sanitizer = line.split("=")[1].strip().lower() == "true" + elif line.startswith("vs_version"): + vs_version = line.split("=")[1].strip().strip('"') + elif line.startswith("ten_enable_integration_tests_prebuilt"): + ten_enable_integration_tests_prebuilt = ( + line.split("=")[1].strip().lower() == "true" + ) target_build = "debug" if is_debug else "release" - return BuildConfig(target_os, target_cpu, target_build) + return BuildConfig( + target_os, + target_cpu, + target_build, + is_clang, + enable_sanitizer, + vs_version, + ten_enable_integration_tests_prebuilt, + ) diff --git a/tests/ten_runtime/integration/common/build_pkg.py b/tests/ten_runtime/integration/common/build_pkg.py new file mode 100644 index 0000000000..bea39d1fa1 --- /dev/null +++ b/tests/ten_runtime/integration/common/build_pkg.py @@ -0,0 +1,462 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import json +import os +from datetime import datetime +from . import ( + cmd_exec, + fs_utils, + build_config, + install_pkg, + install_all, + replace, +) + + +class ArgumentInfo: + def __init__(self): + self.pkg_src_root_dir: str + self.pkg_run_root_dir: str + self.pkg_name: str + self.pkg_language: str + self.os: str + self.cpu: str + self.build: str + self.tgn_path: str + self.is_clang: bool + self.enable_sanitizer: bool + self.vs_version: str + self.log_level: int + + +def _construct_cpp_additional_args(args: ArgumentInfo) -> list[str]: + cmd = ["--"] + + cmd.append(f"is_clang={'true' if args.is_clang else 'false'}") + cmd.append( + f"enable_sanitizer={'true' if args.enable_sanitizer else 'false'}" + ) + + if args.vs_version: + cmd += [f"vs_version={args.vs_version}"] + + return cmd + + +def _build_cpp_app(args: ArgumentInfo) -> int: + # tgn gen ... + cmd = [f"{args.tgn_path}", "gen", args.os, args.cpu, args.build] + cmd += _construct_cpp_additional_args(args) + + returncode, output = cmd_exec.run_cmd(cmd, args.log_level) + + if returncode: + if args.log_level > 0: + print(output) + raise Exception("Failed to build c++ app") + + # tgn build ... + cmd = [f"{args.tgn_path}", "build", args.os, args.cpu, args.build] + + t1 = datetime.now() + returncode, output = cmd_exec.run_cmd(cmd, args.log_level) + t2 = datetime.now() + + duration = (t2 - t1).seconds + + if args.log_level > 0: + print(f"Build c++ app({args.pkg_name}) costs {duration} seconds.") + + if returncode: + if args.log_level > 0: + print(output) + raise Exception("Failed to build c++ app") + + # Copy the build result to the specified run folder. + fs_utils.copy( + f"{args.pkg_src_root_dir}/out/{args.os}/{args.cpu}/app/{args.pkg_name}", + args.pkg_run_root_dir, + True, + ) + + return returncode + + +def _build_cpp_extension(args: ArgumentInfo) -> int: + # tgn gen ... + cmd = [f"{args.tgn_path}", "gen", args.os, args.cpu, args.build] + cmd += _construct_cpp_additional_args(args) + + returncode, output = cmd_exec.run_cmd(cmd, args.log_level) + + if returncode: + if args.log_level > 0: + print(output) + raise Exception("Failed to build c++ extension.") + + # tgn build ... + cmd = [f"{args.tgn_path}", "build", args.os, args.cpu, args.build] + + returncode, output = cmd_exec.run_cmd(cmd, args.log_level) + + if returncode: + if args.log_level > 0: + print(output) + raise Exception("Failed to build c++ extension.") + + return returncode + + +def _build_go_app(args: ArgumentInfo) -> int: + # Determine the path to the main.go script. Some cases require a customized + # Go build script, but in most situations, the build script provided by the + # TEN runtime Go binding can be used directly. + main_go_path = "scripts/build/main.go" + if not os.path.exists(main_go_path): + main_go_path = "ten_packages/system/ten_runtime_go/tools/build/main.go" + + cmd = ["go", "run", main_go_path] + if args.log_level > 0: + cmd += ["--verbose"] + + if args.enable_sanitizer: + cmd += ["-asan"] + + envs = os.environ.copy() + if args.is_clang: + envs["CC"] = "clang" + envs["CXX"] = "clang++" + else: + envs["CC"] = "gcc" + envs["CXX"] = "g++" + + t1 = datetime.now() + returncode, output = cmd_exec.run_cmd_realtime( + cmd, None, envs, args.log_level + ) + t2 = datetime.now() + + duration = (t2 - t1).seconds + + if args.log_level > 0: + print(f"Build go app({args.pkg_name}) costs {duration} seconds.") + + if returncode: + if args.log_level > 0: + print(output) + raise Exception("Failed to build go app.") + + return returncode + + +def _get_pkg_type(pkg_root: str) -> str: + manifest_path = os.path.join(pkg_root, "manifest.json") + with open(manifest_path, "r") as f: + manifest_json = json.load(f) + return manifest_json["type"] + + +def _build_app(args: ArgumentInfo) -> int: + returncode = 0 + + if args.pkg_language == "cpp": + returncode = _build_cpp_app(args) + elif args.pkg_language == "go": + returncode = _build_go_app(args) + elif args.pkg_language == "python": + returncode = 0 + else: + raise Exception(f"Unknown app language: {args.pkg_language}") + + return returncode + + +def _build_extension(args: ArgumentInfo) -> int: + returncode = 0 + + if args.pkg_language == "cpp": + returncode = _build_cpp_extension(args) + else: + returncode = 0 + + return returncode + + +def prepare_app( + build_config: build_config.BuildConfig, + root_dir: str, + test_case_base_dir: str, + source_pkg_name: str, + log_level: int, +) -> int: + tman_path = os.path.join(root_dir, "ten_manager/bin/tman") + tman_config_file = os.path.join( + root_dir, "tests/local_registry/config.json" + ) + local_registry_path = os.path.join( + root_dir, "tests/local_registry/registry" + ) + + # Read the assembly info from + # /.assemble_info//info.json + assemble_info_dir = os.path.join( + test_case_base_dir, ".assemble_info", source_pkg_name + ) + info_file = os.path.join(assemble_info_dir, "info.json") + with open(info_file, "r") as f: + info = json.load(f) + pkg_name = info["src_app"] + generated_app_src_root_dir_name = info[ + "generated_app_src_root_dir_name" + ] + + app_src_root_dir = os.path.join( + test_case_base_dir, generated_app_src_root_dir_name + ) + + # ======== + # Step 1: Install app. + if log_level and log_level > 0: + print(f"> Install app to {source_pkg_name}") + + arg = install_pkg.ArgumentInfo() + arg.tman_path = tman_path + arg.pkg_type = "app" + arg.pkg_src_root_dir = app_src_root_dir + arg.src_pkg = pkg_name + arg.build_type = build_config.target_build + arg.config_file = tman_config_file + arg.log_level = log_level + arg.local_registry_path = local_registry_path + + install_res = install_pkg.main(arg) + if install_res != 0: + raise Exception("Failed to install app") + + # ======== + # Step 2: Replace files after install app. + if log_level and log_level > 0: + print("> Replace files after install app") + + rc = _replace_after_install_app(test_case_base_dir, source_pkg_name) + if rc != 0: + raise Exception("Failed to replace files after install app") + + # ======== + # Step 3: Install all. + if log_level and log_level > 0: + print("> Install all") + + install_all_args = install_all.ArgumentInfo() + install_all_args.tman_path = tman_path + install_all_args.pkg_src_root_dir = app_src_root_dir + install_all_args.build_type = build_config.target_build + install_all_args.config_file = tman_config_file + install_all_args.log_level = log_level + install_all_args.assume_yes = True + + rc = install_all.main(install_all_args) + + # ======== + # Step 4: Replace files after install all. + if log_level and log_level > 0: + print("> Replace files after install all") + + rc = _replace_after_install_all(test_case_base_dir, source_pkg_name) + if rc != 0: + raise Exception("Failed to replace files after install all") + + return rc + + +def _replace_after_install_app( + test_case_base_dir: str, source_pkg_name: str +) -> int: + assemble_info_dir = os.path.join( + test_case_base_dir, ".assemble_info", source_pkg_name + ) + assemble_info_file = os.path.join(assemble_info_dir, "info.json") + + replace_files_after_install_app: list[str] = [] + + with open(assemble_info_file, "r") as f: + info = json.load(f) + replace_files_after_install_app = info[ + "replace_files_after_install_app" + ] + + if ( + not replace_files_after_install_app + or len(replace_files_after_install_app) == 0 + ): + return 0 + + replaced_files = [] + for replace_file in replace_files_after_install_app: + src_file = os.path.join( + assemble_info_dir, + "files_to_be_replaced_after_install_app", + replace_file, + ) + + if not os.path.exists(src_file): + raise Exception(f"{src_file} does not exist.") + + dst_file = os.path.join(test_case_base_dir, replace_file) + replaced_files.append((src_file, dst_file)) + + replace.replace_normal_files_or_merge_json_files(replaced_files) + + return 0 + + +def _replace_after_install_all( + test_case_base_dir: str, source_pkg_name: str +) -> int: + assemble_info_dir = os.path.join( + test_case_base_dir, ".assemble_info", source_pkg_name + ) + assemble_info_file = os.path.join(assemble_info_dir, "info.json") + + replace_files_after_install_all: list[str] = [] + + with open(assemble_info_file, "r") as f: + info = json.load(f) + replace_files_after_install_all = info[ + "replace_files_after_install_all" + ] + + if ( + not replace_files_after_install_all + or len(replace_files_after_install_all) == 0 + ): + return 0 + + replaced_files = [] + for replace_file in replace_files_after_install_all: + src_file = os.path.join( + assemble_info_dir, + "files_to_be_replaced_after_install_all", + replace_file, + ) + + if not os.path.exists(src_file): + raise Exception(f"{src_file} does not exist.") + + dst_file = os.path.join(test_case_base_dir, replace_file) + replaced_files.append((src_file, dst_file)) + + replace.replace_normal_files_or_merge_json_files(replaced_files) + + return 0 + + +def build_app( + build_config: build_config.BuildConfig, + pkg_src_root_dir: str, + pkg_run_root_dir: str, + pkg_name: str, + pkg_language: str, + log_level: int = 0, +) -> int: + args = ArgumentInfo() + args.pkg_src_root_dir = pkg_src_root_dir + args.pkg_run_root_dir = pkg_run_root_dir + args.pkg_name = pkg_name + args.pkg_language = pkg_language + args.os = build_config.target_os + args.cpu = build_config.target_cpu + args.build = build_config.target_build + args.is_clang = build_config.is_clang + args.enable_sanitizer = build_config.enable_sanitizer + args.vs_version = build_config.vs_version + args.log_level = log_level + + if args.os == "win": + tgn_path_in_env = os.getenv("tgn") + if tgn_path_in_env: + args.tgn_path = tgn_path_in_env + else: + return 1 + else: + args.tgn_path = "tgn" + + if args.log_level > 0: + msg = ( + f"> Start to build package({args.pkg_name})" + " in {args.pkg_src_root_dir}" + ) + print(msg) + + origin_wd = os.getcwd() + returncode = 0 + + try: + os.chdir(args.pkg_src_root_dir) + pkg_type = _get_pkg_type(args.pkg_src_root_dir) + if pkg_type == "app": + returncode = _build_app(args) + elif pkg_type == "extension": + returncode = _build_extension(args) + else: + returncode = 0 + + if returncode > 0: + raise Exception(f"Failed to build {pkg_type}({args.pkg_name})") + + if args.log_level > 0: + print(f"Build {pkg_type}({args.pkg_name}) success") + + except Exception as e: + returncode = 1 + print(f"Build package({args.pkg_name}) failed: {repr(e)}") + + finally: + os.chdir(origin_wd) + + return returncode + + +def prepare_and_build_app( + build_config: build_config.BuildConfig, + root_dir: str, + test_case_base_dir: str, + pkg_run_root_dir: str, + source_pkg_name: str, + pkg_language: str, + log_level: int = 2, +) -> int: + rc = prepare_app( + build_config, + root_dir, + test_case_base_dir, + source_pkg_name, + log_level, + ) + if rc != 0: + return rc + + pkg_src_root_dir = os.path.join(test_case_base_dir, source_pkg_name) + + rc = build_app( + build_config, + pkg_src_root_dir, + pkg_run_root_dir, + source_pkg_name, + pkg_language, + log_level, + ) + + return rc + + +def cleanup( + pkg_src_dir: str, + pkg_run_dir: str, +) -> None: + fs_utils.remove_tree(pkg_src_dir) + fs_utils.remove_tree(pkg_run_dir) diff --git a/tests/ten_runtime/integration/common/cmd_exec.py b/tests/ten_runtime/integration/common/cmd_exec.py new file mode 100644 index 0000000000..d90caceb0b --- /dev/null +++ b/tests/ten_runtime/integration/common/cmd_exec.py @@ -0,0 +1,174 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import sys +import os +import subprocess + + +# psutil is not a builtin module, so use it if it exists. +try: + import psutil + + has_psutil = True +except ImportError: + has_psutil = False + + +def get_cmd_output(cmd: str, log_level: int = 0) -> tuple[int, str]: + """Return (status, output) of executing cmd in a shell.""" + + if sys.platform != "win32": + if cmd.endswith(";"): + cmd = "{ " + cmd + " }" + else: + cmd = "{ " + cmd + "; }" + else: + # Leaves the item unchanged if it starts with "http", or replaces all + # forward slashes (/) with backslashes (\) in other items, and the items + # are then joined back into a single string with spaces. + cmd = " ".join( + [ + ( + item + if item.startswith("http") or item.startswith("/") + else item.replace("/", "\\") + ) + for item in cmd.split() + ] + ) + + if log_level > 1: + print(f"> {cmd}") + + pipe = os.popen(cmd + " 2>&1", "r") + output_text = "" + + while 1: + line = pipe.readline() + if not line: + break + output_text += line + + try: + returncode = pipe.close() + except Exception: + returncode = 1 + + if returncode is None: + returncode = 0 + + # According to the implementation of 'os::popen()', the 'returncode' will + # be shifted left to match old behavior if the system is not Windows NT. + # Refer to '_wrap_close::close()' in os.py. + if os.name != "nt" and returncode >= 1 << 8: + returncode = returncode >> 8 + + if output_text[-1:] == "\n": + output_text = output_text[:-1] + + return returncode, output_text + + +def run_cmd(argv: list[str], log_level: int = 0) -> tuple[int, str]: + cmd = " ".join(argv) + returncode, output_text = get_cmd_output(cmd, log_level) + if returncode != 0: + sys.stderr.write(output_text) + sys.stderr.write("\n") + sys.stderr.flush() + return returncode, output_text + + +def run_cmd_realtime( + cmd, + cwd: str | None = None, + env: dict[str, str] | None = None, + log_level: int = 0, +): + # print(cmd) + + my_cmd = cmd + set_shell = True + + if isinstance(cmd, list): + if sys.platform == "win32": + if cmd[0] != "cmd": + my_cmd = ["cmd", "/c"] + cmd + else: + set_shell = False + + if isinstance(cmd, str): + if sys.platform == "win32" and cmd[:3] != "cmd": + my_cmd = "cmd /c " + cmd + + child = subprocess.Popen( + my_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + shell=set_shell, + bufsize=0, + env=env, + cwd=cwd, + ) + + console_log = "" + pid = child.pid + process_name = "" + + if has_psutil: + try: + process = psutil.Process(pid) + process_name = process.name() + except (psutil.NoSuchProcess, psutil.AccessDenied): + pass + + line = "" + + try: + while child.poll() is None: + if child.stdout: + try: + line = child.stdout.readline() + except UnicodeDecodeError: + line = child.stdout.readline().encode("gbk").decode("gbk") + + if line != "": + console_log += line + if log_level > 0: + sys.stdout.flush() + if log_level == 3: + sys.stdout.write( + "{}: {}{} > {}\n".format( + cmd, + process_name if process_name else "", + f"({pid})", + line.rstrip(), + ) + ) + elif log_level == 2: + sys.stdout.write( + "{}{} > {}\n".format( + process_name if process_name else "", + f"({pid})", + line.rstrip(), + ) + ) + + sys.stdout.flush() + except UnicodeDecodeError: + pass + except Exception as e: + sys.stdout.write( + "{}{} > {}\n".format( + process_name if process_name else "", f"({pid})", line.rstrip() + ) + ) + print(repr(e)) + raise e + + return child.returncode, console_log diff --git a/tests/ten_runtime/integration/common/fs_utils.py b/tests/ten_runtime/integration/common/fs_utils.py new file mode 100644 index 0000000000..cc27f6ce19 --- /dev/null +++ b/tests/ten_runtime/integration/common/fs_utils.py @@ -0,0 +1,286 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import sys +import stat +import os +import shutil +import tempfile +from . import log +import subprocess +import inspect + + +def mkdir_p(path: str) -> None: + if sys.version > "3": + os.makedirs(path, exist_ok=True) + else: + raise Exception("tgn supports Python 3 only") + + +def remove_tree(path: str) -> None: + if os.path.exists(path): + if sys.platform == "win32": + # There are many corner cases in Windows which will prevent the + # target path from deleting. + # + # Therefore, we use robocopy to empty a folder before deleting it in + # Windows. robocopy could handle more cases in Windows when + # deleting a folder. + # + # 1. Create an empty tmp folder. + tmp_folder = tempfile.mkdtemp() + + # 2. Use 'robocopy' to clear the contents of the target folder. The + # important argument is '/mir'. + rt = subprocess.call( + [ + "robocopy", + tmp_folder, + path, + "/r:3", + "/w:2", + "/mir", + "/purge", + "/mt", + "/LOG:robocopy_remove_tree_log.txt", + ] + ) + if rt >= 8: + log.error(f"Failed to remove_tree({path}): {str(rt)}") + exit(rt) + + # 3. The target folder is empty now, its safe to remove it. + shutil.rmtree(path) + + # 4. Remove the tmp folder, too. + shutil.rmtree(tmp_folder) + else: + shutil.rmtree(path) + + +def copy_tree(src_path: str, dst_path: str, rm_dst=False) -> None: + if not os.path.exists(src_path): + raise Exception(src_path + " not exist") + + if not os.path.isdir(src_path): + raise Exception(src_path + " is not a directory.") + + try: + if sys.platform == "win32": + # Use 'robocopy' in Windows to perform copying. + cmd = [ + "robocopy", + src_path, + dst_path, + # Copies subdirectories. This option automatically includes + # empty directories. + "/e", + # Creates multi-threaded copies with n threads. The default + # value for n is 8. + "/mt", + # Specifies the number of retries on failed copies. + "/r:30", + # Specifies the wait time between retries, in seconds. + "/w:3", + # Specifies that there's no job header. + "/njh", + # Specifies that there's no job summary. + "/njs", + # Specifies that directory names aren't to be logged. + "/ndl", + # Specifies that file classes aren't to be logged. + "/nc", + # Specifies that file sizes aren't to be logged. + "/ns", + # Specifies that the progress of the copying operation (the + # number of files or directories copied so far) won't be + # displayed. + "/np", + # Specifies that file names aren't to be logged. + "/nfl", + "/LOG:robocopy_tree_log.txt", + # Specifies what to copy in directories. DA (data and + # attributes). + "/dcopy:DA", + ] + + if rm_dst is True: + cmd += [ + # Mirrors a directory tree (equivalent to /e plus /purge). + "/mir" + ] + + rt = subprocess.call(cmd) + if rt >= 8: + log.error( + f"Failed to copy_tree: {src_path} => {dst_path}: {str(rt)}" + ) + exit(rt) + else: + try: + if rm_dst: + remove_tree(dst_path) + + # shutil.copytree requires the destination folder is empty, + # otherwise, this function will throw exceptions. So use it + # in this case. + shutil.copytree( + src_path, + dst_path, + symlinks=True, + copy_function=shutil.copy, + ) + + # Loop all immediate items in src_path, and copy them one by + # one. + for name in os.listdir(src_path): + src_item_path = os.path.join(src_path, name) + dest_item_path = os.path.join(dst_path, name) + + if os.path.isdir(src_item_path): + # Create the destination folder if not exist. + if not os.path.exists(dest_item_path): + os.makedirs(dest_item_path, exist_ok=True) + copy_tree(src_item_path, dest_item_path) + else: + copy_file(src_item_path, dest_item_path, rm_dst=rm_dst) + except Exception as exc: + log.error( + inspect.cleandoc( + f"""Failed to copy tree: + {src_path} => + {dst_path} + Exception: {exc} + rm_dst: {rm_dst}""" + ) + ) + raise + + try: + # Update the file access and modify time to the current time. + os.utime(dst_path, follow_symlinks=False) + except Exception: + try: + # If follow_symlinks parameter is not supported, fall back to + # default behavior + os.utime(dst_path) + except Exception as exc: + log.error( + inspect.cleandoc( + f"""Failed to copy_tree: + {src_path} => + {dst_path} + Exception: {exc} + rm_dst: {rm_dst}""" + ) + ) + exit(1) + + except Exception as exc: + log.error( + inspect.cleandoc( + f"""Failed to copy_tree: + {src_path} => + {dst_path} + Exception: {exc} + rm_dst: {rm_dst}""" + ) + ) + exit(1) + + +def copy_file(src_file: str, dst_file: str, rm_dst=False) -> None: + if not os.path.exists(src_file): + raise Exception(f"{src_file} not exist") + + if os.path.isdir(src_file): + raise Exception(f"{src_file} is a directory.") + + src_file = os.path.abspath(src_file) + dst_file = os.path.abspath(dst_file) + + try: + mkdir_p(os.path.dirname(dst_file)) + except Exception as exc: + log.error( + inspect.cleandoc( + f"""Failed to create destination folder before copy_file: + {src_file} => + {dst_file} + Exception: {exc} + rm_dst: {rm_dst}""" + ) + ) + exit(1) + + try: + if rm_dst and os.path.exists(dst_file): + os.remove(dst_file) + except Exception as exc: + log.error( + inspect.cleandoc( + f"""Failed to delete dst_file before copy_file: + {src_file} => + {dst_file} + Exception: {exc} + rm_dst: {rm_dst}""" + ) + ) + exit(1) + + try: + if os.path.islink(src_file): + subprocess.call(["cp", "-a", src_file, dst_file]) + else: + # Ensure the destination file is writable, so that the copying + # operation would not be fail due to this. + if os.path.exists(dst_file): + st = os.stat(dst_file) + os.chmod(dst_file, st.st_mode | stat.S_IWUSR) + shutil.copy(src_file, dst_file) + except Exception as exc: + log.error( + inspect.cleandoc( + f"""Failed to copy_file: + {src_file} => + {dst_file} + Exception: {exc} + rm_dst: {rm_dst}""" + ) + ) + exit(1) + + try: + # Update the file access and modify time to the current time. + os.utime(dst_file, follow_symlinks=False) + except Exception: + try: + # If follow_symlinks parameter is not supported, fall back to + # default behavior + os.utime(dst_file) + except Exception as exc: + log.error( + inspect.cleandoc( + f"""Failed to copy_file: + {src_file} => + {dst_file} + Exception: {exc} + rm_dst: {rm_dst}""" + ) + ) + exit(1) + + +def copy(src: str, dst: str, rm_dst=False) -> None: + if os.path.exists(src): + # Perform copying. + if os.path.isdir(src): + copy_tree(src, dst, rm_dst) + else: + copy_file(src, dst, rm_dst) + else: + raise Exception(f"{src} does not exist.") diff --git a/tests/ten_runtime/integration/common/install_all.py b/tests/ten_runtime/integration/common/install_all.py new file mode 100644 index 0000000000..610fc3cb78 --- /dev/null +++ b/tests/ten_runtime/integration/common/install_all.py @@ -0,0 +1,97 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import argparse +import sys +import os +from . import cmd_exec + + +class ArgumentInfo(argparse.Namespace): + def __init__(self): + self.tman_path: str + self.pkg_src_root_dir: str + self.build_type: str + self.config_file: str + self.log_level: int + self.assume_yes: bool + + +def main(args: ArgumentInfo) -> int: + if args.log_level > 0: + print(f"> Install_all: {args.pkg_src_root_dir}") + + origin_wd = os.getcwd() + returncode = 0 + + try: + os.chdir(args.pkg_src_root_dir) + + cmd = [args.tman_path] + + if args.config_file is not None: + cmd += ["--config-file=" + args.config_file] + + if args.assume_yes: + cmd += ["--yes"] + + cmd += ["install"] + + if args.build_type is not None: + cmd += ["--build-type=" + args.build_type] + + returncode, output_text = cmd_exec.run_cmd(cmd, args.log_level) + if returncode: + raise Exception("Failed to install_all") + + except Exception as exc: + returncode = 1 + print(exc) + + finally: + if args.log_level > 0: + print(output_text) + + os.chdir(origin_wd) + return returncode + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--tman-path", + type=str, + required=True, + help="Path to tman command itself", + ) + parser.add_argument( + "--pkg-src-root-dir", + type=str, + required=True, + help="Path to app root folder", + ) + parser.add_argument( + "--build-type", + type=str, + required=False, + help="'debug', 'release'", + ) + parser.add_argument( + "--config-file", + type=str, + required=False, + help="Path of tman config file", + ) + parser.add_argument( + "--log-level", type=int, required=True, help="specify log level" + ) + parser.add_argument("--assume-yes", type=bool, default=False) + + arg_info = ArgumentInfo() + args = parser.parse_args(namespace=arg_info) + + sys.exit(main(args)) diff --git a/tests/ten_runtime/integration/common/install_pkg.py b/tests/ten_runtime/integration/common/install_pkg.py new file mode 100644 index 0000000000..b78b2d1ed7 --- /dev/null +++ b/tests/ten_runtime/integration/common/install_pkg.py @@ -0,0 +1,156 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import argparse +import sys +import os +from . import cmd_exec + + +class ArgumentInfo(argparse.Namespace): + def __init__(self): + self.tman_path: str + self.pkg_type: str + self.pkg_src_root_dir: str + self.src_pkg: str + self.build_type: str + self.config_file: str + self.log_level: int + self.local_registry_path: str + + +def get_pkgs_from_local_registry( + local_registry_path: str, pkg_type: str, pkg_name: str +) -> list[str]: + # Find directories under // and + # return their names. + pkg_dir = os.path.join(local_registry_path, pkg_type, pkg_name) + if not os.path.exists(pkg_dir): + return [] + + return os.listdir(pkg_dir) + + +def main(args: ArgumentInfo) -> int: + if args.log_level > 0: + print(f"> Install {args.pkg_type}: {args.pkg_src_root_dir}") + + origin_wd = os.getcwd() + returncode = 0 + + generated_app_name = os.path.basename(args.pkg_src_root_dir) + + try: + # Install app. + base_dir = os.path.dirname(args.pkg_src_root_dir) + os.makedirs(base_dir, exist_ok=True) + os.chdir(base_dir) + + cmd = [ + args.tman_path, + ] + + if args.log_level > 0: + cmd += ["--verbose"] + + if args.config_file is not None: + list.append(cmd, "--config-file=" + args.config_file) + + if args.local_registry_path is not None: + versions = get_pkgs_from_local_registry( + args.local_registry_path, args.pkg_type, args.src_pkg + ) + + if len(versions) == 1: + # If there is only one version, install using that specific + # version number to avoid installation failures due to it being + # a pre-release version. + args.src_pkg += f"@{versions[0]}" + + cmd += [ + "install", + args.pkg_type, + args.src_pkg, + "--template-mode", + "--template-data", + f"package_name={generated_app_name}", + ] + + if args.build_type is not None: + list.append(cmd, "--build-type=" + args.build_type) + + if args.log_level > 0: + print(f"> {cmd}") + + returncode, output_text = cmd_exec.run_cmd(cmd, args.log_level) + if returncode: + if args.log_level > 0: + print(output_text) + raise Exception("Failed to install app.") + + except Exception as exc: + returncode = 1 + print(exc) + + finally: + os.chdir(origin_wd) + return returncode + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--tman-path", + type=str, + required=True, + help="Path to tman command itself", + ) + parser.add_argument( + "--pkg-type", + type=str, + required=True, + help="The type of package", + choices=["app", "extension"], + ) + parser.add_argument( + "--pkg-src-root-dir", + type=str, + required=True, + help="Path to app source root directory", + ) + parser.add_argument( + "--src-pkg", + type=str, + required=True, + help="The name of TEN package", + ) + parser.add_argument( + "--build-type", + type=str, + required=False, + help="'debug', 'release'", + ) + parser.add_argument( + "--config-file", + type=str, + required=False, + help="Path of tman config file", + ) + parser.add_argument( + "--log-level", type=int, required=True, help="specify log level" + ) + parser.add_argument( + "--local-registry-path", + type=str, + required=False, + help="Path to local registry", + ) + + arg_info = ArgumentInfo() + args = parser.parse_args(namespace=arg_info) + + sys.exit(main(args)) diff --git a/tests/ten_runtime/integration/common/log.py b/tests/ten_runtime/integration/common/log.py new file mode 100644 index 0000000000..af809d7b07 --- /dev/null +++ b/tests/ten_runtime/integration/common/log.py @@ -0,0 +1,126 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import logging + + +class ColorCodes: + grey = "\x1b[38;21m" + green = "\x1b[1;32m" + yellow = "\x1b[33;21m" + red = "\x1b[31;21m" + bold_red = "\x1b[31;1m" + blue = "\x1b[1;34m" + light_blue = "\x1b[1;36m" + purple = "\x1b[1;35m" + pink = "\x1b[35;1m" + normal = "\x1b[0m" + + +def setup_logger(logger): + logger.setLevel(logging.DEBUG) + + sh = logging.StreamHandler() + formatter = logging.Formatter(fmt="%(asctime)s [%(levelname)s] %(message)s") + sh.setFormatter(formatter) + + def decorate_emit(fn): + # Add methods we need to the class + def new(*args): + levelno = args[0].levelno + if levelno >= logging.CRITICAL: + color = ColorCodes.red + elif levelno >= logging.ERROR: + color = ColorCodes.red + elif levelno >= logging.WARNING: + color = ColorCodes.yellow + elif levelno >= logging.INFO: + color = ColorCodes.green + elif levelno >= logging.DEBUG: + color = ColorCodes.pink + else: + color = ColorCodes.normal + + # Add colored *** in the beginning of the message + args[0].msg = "{0}***{1} {2}".format( + color, ColorCodes.normal, args[0].msg + ) + + # Bolder each args of message + args[0].args = tuple( + "\x1b[1m" + arg + "\x1b[0m" for arg in args[0].args + ) + + return fn(*args) + + return new + + sh.emit = decorate_emit(sh.emit) # type: ignore + logger.addHandler(sh) + + def decorate_loglevel(): + logging.addLevelName( + logging.CRITICAL, + "{0}{1}{2}".format( + ColorCodes.red, + logging.getLevelName(logging.CRITICAL), + ColorCodes.normal, + ), + ) + + logging.addLevelName( + logging.ERROR, + "{0}{1}{2}".format( + ColorCodes.red, + logging.getLevelName(logging.ERROR), + ColorCodes.normal, + ), + ) + + logging.addLevelName( + logging.WARNING, + "{0}{1}{2}".format( + ColorCodes.yellow, + logging.getLevelName(logging.WARNING), + ColorCodes.normal, + ), + ) + + logging.addLevelName( + logging.INFO, + "{0}{1}{2}".format( + ColorCodes.green, + logging.getLevelName(logging.INFO), + ColorCodes.normal, + ), + ) + + logging.addLevelName( + logging.DEBUG, + "{0}{1}{2}".format( + ColorCodes.pink, + logging.getLevelName(logging.DEBUG), + ColorCodes.normal, + ), + ) + + decorate_loglevel() + + +logger = logging.getLogger("ten_gn") +setup_logger(logger) + + +def info(msg, *args, **kwargs): + logger.info(msg, *args, **kwargs) + + +def warn(msg, *args, **kwargs): + logger.warning(msg, *args, **kwargs) + + +def error(msg, *args, **kwargs): + logger.error(msg, *args, **kwargs) diff --git a/tests/ten_runtime/integration/common/replace.py b/tests/ten_runtime/integration/common/replace.py new file mode 100644 index 0000000000..74718355a0 --- /dev/null +++ b/tests/ten_runtime/integration/common/replace.py @@ -0,0 +1,115 @@ +# +# Copyright © 2024 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import argparse +import json +import os +import sys +from . import fs_utils + + +class ArgumentInfo(argparse.Namespace): + def __init__(self): + self.replaced_files: list[str] + + +def merge_json_file_at_root_level(src: str, dest: str) -> None: + if not os.path.exists(src): + raise Exception(f"{src} does not exist.") + if not os.path.exists(dest): + raise Exception(f"{dest} does not exist.") + + with open(src, "r") as src_file, open(dest, "r+") as dest_file: + try: + src_file_content = json.load(src_file) + except Exception as e: + print(f"{src_file} contains invalid JSON: {e}") + raise e + + try: + dest_file_content = json.load(dest_file) + except Exception as e: + print(f"{dest_file} contains invalid JSON: {e}") + raise e + + for key, value in src_file_content.items(): + dest_file_content[key] = value + + dest_file.seek(0) + json.dump(dest_file_content, dest_file, indent=2) + dest_file.truncate() + + +def split(input: str, split_key: str) -> tuple[str, str]: + split_key_index = str(input).find(split_key) + if split_key_index == -1: + # split_key is not found, this means the source and the destination + # are equal. + return (input, input) + else: + return ( + str(input)[:split_key_index], + str(input)[split_key_index + len(split_key) :], + ) + + +def _parsing_replace_files( + replaced_files: list[str], +) -> list[tuple[str, str]]: + result = [] + for res in replaced_files: + res_src, res_dest = split(res, "=>") + result.append((res_src, res_dest)) + + return result + + +def replace_normal_files_or_merge_json_files( + replaced_files: list[tuple[str, str]] +) -> None: + for res in replaced_files: + res_src, res_dest = res + + if not os.path.exists(res_src): + raise Exception(f"{res_src} does not exist.") + + if ( + res_src.endswith(".json") + and res_dest.endswith(".json") + and os.path.exists(res_dest) + ): + merge_json_file_at_root_level(res_src, res_dest) + else: + fs_utils.copy(res_src, res_dest) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--replaced-files", + type=str, + action="append", + default=[], + help="Resources to be replaced", + ) + + arg_info = ArgumentInfo() + args = parser.parse_args(namespace=arg_info) + + origin_wd = os.getcwd() + returncode = 0 + + try: + replace_normal_files_or_merge_json_files( + _parsing_replace_files(args.replaced_files) + ) + except Exception as exc: + returncode = 1 + print(exc) + finally: + os.chdir(origin_wd) + sys.exit(returncode) diff --git a/tests/ten_runtime/integration/cpp/BUILD.gn b/tests/ten_runtime/integration/cpp/BUILD.gn index a0377989a4..2b3693a40e 100644 --- a/tests/ten_runtime/integration/cpp/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/BUILD.gn @@ -23,7 +23,7 @@ group("cpp") { deps += [ "standalone_test_cpp" ] } - if (ten_enable_ffmpeg_extensions) { + if (ten_enable_ffmpeg_extensions && ten_enable_integration_tests_prebuilt) { deps += [ "ffmpeg_basic", "ffmpeg_bypass", diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/BUILD.gn b/tests/ten_runtime/integration/cpp/check_start_graph/BUILD.gn index 10d5097466..e656307e8c 100644 --- a/tests/ten_runtime/integration/cpp/check_start_graph/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/check_start_graph/BUILD.gn @@ -39,9 +39,6 @@ ten_package_test_prepare_auxiliary_resources("check_start_graph_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("check_start_graph") { diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/test_case.py b/tests/ten_runtime/integration/cpp/check_start_graph/test_case.py index b896773f6b..1303285737 100644 --- a/tests/ten_runtime/integration/cpp/check_start_graph/test_case.py +++ b/tests/ten_runtime/integration/cpp/check_start_graph/test_case.py @@ -6,6 +6,7 @@ import os import sys from sys import stdout +from .common import build_config, build_pkg def test_check_start_graph(): @@ -16,6 +17,28 @@ def test_check_start_graph(): my_env = os.environ.copy() app_root_path = os.path.join(base_path, "check_start_graph_app") + source_pkg_name = "check_start_graph_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print( + f"Assembling and building integration test case '{source_pkg_name}'" + ) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to assemble and build integration test case." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -50,7 +73,10 @@ def test_check_start_graph(): else: server_cmd = os.path.join(app_root_path, "bin/check_start_graph_source") - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( app_root_path, "ten_packages/system/ten_runtime/lib/libasan.so", @@ -72,3 +98,10 @@ def test_check_start_graph(): print("server: ", server_rc) assert server_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/cpp/ffmpeg_basic/BUILD.gn b/tests/ten_runtime/integration/cpp/ffmpeg_basic/BUILD.gn index 0326ddefdb..5431d853c9 100644 --- a/tests/ten_runtime/integration/cpp/ffmpeg_basic/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/ffmpeg_basic/BUILD.gn @@ -41,9 +41,6 @@ ten_package_test_prepare_auxiliary_resources("ffmpeg_basic_app_test_files") { "test_case.py", "video_cmp.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("ffmpeg_basic") { diff --git a/tests/ten_runtime/integration/cpp/ffmpeg_basic/test_case.py b/tests/ten_runtime/integration/cpp/ffmpeg_basic/test_case.py index fd4969c098..1565562ccb 100644 --- a/tests/ten_runtime/integration/cpp/ffmpeg_basic/test_case.py +++ b/tests/ten_runtime/integration/cpp/ffmpeg_basic/test_case.py @@ -7,6 +7,7 @@ import sys from . import video_cmp from sys import stdout +from .common import build_config, build_pkg def test_ffmpeg_basic_app(): @@ -17,6 +18,25 @@ def test_ffmpeg_basic_app(): my_env = os.environ.copy() app_root_path = os.path.join(base_path, "ffmpeg_basic_app") + source_pkg_name = "ffmpeg_basic_app_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -57,7 +77,10 @@ def test_ffmpeg_basic_app(): ) server_cmd = "bin/ffmpeg_basic_app_source" - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "ffmpeg_basic_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -106,3 +129,10 @@ def test_ffmpeg_basic_app(): except Exception as e: # Maybe 'LD_LIBRARY_PATH' has been unset. print(e) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/cpp/ffmpeg_bypass/BUILD.gn b/tests/ten_runtime/integration/cpp/ffmpeg_bypass/BUILD.gn index 022aef596c..9ba07767e2 100644 --- a/tests/ten_runtime/integration/cpp/ffmpeg_bypass/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/ffmpeg_bypass/BUILD.gn @@ -41,9 +41,6 @@ ten_package_test_prepare_auxiliary_resources("ffmpeg_bypass_app_test_files") { "test_case.py", "video_cmp.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("ffmpeg_bypass") { diff --git a/tests/ten_runtime/integration/cpp/ffmpeg_bypass/test_case.py b/tests/ten_runtime/integration/cpp/ffmpeg_bypass/test_case.py index ba922d97f5..d689176801 100644 --- a/tests/ten_runtime/integration/cpp/ffmpeg_bypass/test_case.py +++ b/tests/ten_runtime/integration/cpp/ffmpeg_bypass/test_case.py @@ -7,6 +7,7 @@ import sys from . import video_cmp from sys import stdout +from .common import build_config, build_pkg def test_ffmpeg_bypass_app(): @@ -17,6 +18,26 @@ def test_ffmpeg_bypass_app(): my_env = os.environ.copy() app_root_path = os.path.join(base_path, "ffmpeg_bypass_app") + source_pkg_name = "ffmpeg_bypass_app_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -57,7 +78,10 @@ def test_ffmpeg_bypass_app(): ) server_cmd = "bin/ffmpeg_bypass_app_source" - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "ffmpeg_bypass_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -106,3 +130,10 @@ def test_ffmpeg_bypass_app(): except Exception as e: # Maybe 'LD_LIBRARY_PATH' has been unset. print(e) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/cpp/graph_env_var_1/BUILD.gn b/tests/ten_runtime/integration/cpp/graph_env_var_1/BUILD.gn index 641ecf1bc4..9662d89a86 100644 --- a/tests/ten_runtime/integration/cpp/graph_env_var_1/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/graph_env_var_1/BUILD.gn @@ -58,9 +58,6 @@ ten_package_test_prepare_auxiliary_resources("graph_env_var_1_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("graph_env_var_1") { diff --git a/tests/ten_runtime/integration/cpp/graph_env_var_1/test_case.py b/tests/ten_runtime/integration/cpp/graph_env_var_1/test_case.py index 8aacdac1d3..39cf4446ec 100644 --- a/tests/ten_runtime/integration/cpp/graph_env_var_1/test_case.py +++ b/tests/ten_runtime/integration/cpp/graph_env_var_1/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_graph_env_var_1_app(): @@ -17,6 +17,26 @@ def test_graph_env_var_1_app(): my_env = os.environ.copy() app_root_path = os.path.join(base_path, "graph_env_var_1_app") + source_pkg_name = "graph_env_var_1_app_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -69,7 +89,10 @@ def test_graph_env_var_1_app(): ) client_cmd = os.path.join(base_path, "graph_env_var_1_app_client") - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "graph_env_var_1_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -118,3 +141,10 @@ def test_graph_env_var_1_app(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/cpp/graph_env_var_2/BUILD.gn b/tests/ten_runtime/integration/cpp/graph_env_var_2/BUILD.gn index 81002cb569..e437b668f4 100644 --- a/tests/ten_runtime/integration/cpp/graph_env_var_2/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/graph_env_var_2/BUILD.gn @@ -58,9 +58,6 @@ ten_package_test_prepare_auxiliary_resources("graph_env_var_2_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("graph_env_var_2") { diff --git a/tests/ten_runtime/integration/cpp/graph_env_var_2/test_case.py b/tests/ten_runtime/integration/cpp/graph_env_var_2/test_case.py index 92cb46bdb3..a96db1fb9d 100644 --- a/tests/ten_runtime/integration/cpp/graph_env_var_2/test_case.py +++ b/tests/ten_runtime/integration/cpp/graph_env_var_2/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_graph_env_var_2_app(): @@ -17,6 +17,26 @@ def test_graph_env_var_2_app(): my_env = os.environ.copy() app_root_path = os.path.join(base_path, "graph_env_var_2_app") + source_pkg_name = "graph_env_var_2_app_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -71,7 +91,10 @@ def test_graph_env_var_2_app(): ) client_cmd = os.path.join(base_path, "graph_env_var_2_app_client") - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "graph_env_var_2_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -121,3 +144,10 @@ def test_graph_env_var_2_app(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/cpp/graph_env_var_3/BUILD.gn b/tests/ten_runtime/integration/cpp/graph_env_var_3/BUILD.gn index 0f9108cdeb..8dc660b4e5 100644 --- a/tests/ten_runtime/integration/cpp/graph_env_var_3/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/graph_env_var_3/BUILD.gn @@ -58,9 +58,6 @@ ten_package_test_prepare_auxiliary_resources("graph_env_var_3_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("graph_env_var_3") { diff --git a/tests/ten_runtime/integration/cpp/graph_env_var_3/test_case.py b/tests/ten_runtime/integration/cpp/graph_env_var_3/test_case.py index a682cc1b05..24c9f1df7e 100644 --- a/tests/ten_runtime/integration/cpp/graph_env_var_3/test_case.py +++ b/tests/ten_runtime/integration/cpp/graph_env_var_3/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_graph_env_var_3_app(): @@ -17,6 +17,26 @@ def test_graph_env_var_3_app(): my_env = os.environ.copy() app_root_path = os.path.join(base_path, "graph_env_var_3_app") + source_pkg_name = "graph_env_var_3_app_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -71,7 +91,10 @@ def test_graph_env_var_3_app(): ) client_cmd = os.path.join(base_path, "graph_env_var_3_app_client") - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "graph_env_var_3_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -123,3 +146,10 @@ def test_graph_env_var_3_app(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/cpp/hello_world/BUILD.gn b/tests/ten_runtime/integration/cpp/hello_world/BUILD.gn index 77a295d059..5f792c2bbc 100644 --- a/tests/ten_runtime/integration/cpp/hello_world/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/hello_world/BUILD.gn @@ -67,9 +67,6 @@ ten_package_test_prepare_auxiliary_resources("hello_world_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("hello_world") { diff --git a/tests/ten_runtime/integration/cpp/hello_world/test_case.py b/tests/ten_runtime/integration/cpp/hello_world/test_case.py index 3cc1552669..069c47cfb3 100644 --- a/tests/ten_runtime/integration/cpp/hello_world/test_case.py +++ b/tests/ten_runtime/integration/cpp/hello_world/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_hello_world_app(): @@ -17,6 +17,26 @@ def test_hello_world_app(): my_env = os.environ.copy() app_root_path = os.path.join(base_path, "hello_world_app") + source_pkg_name = "hello_world_app_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -65,7 +85,10 @@ def test_hello_world_app(): ) client_cmd = os.path.join(base_path, "hello_world_app_client") - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "hello_world_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -112,3 +135,10 @@ def test_hello_world_app(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/cpp/http_basic/BUILD.gn b/tests/ten_runtime/integration/cpp/http_basic/BUILD.gn index 513cb6798f..152f4355f8 100644 --- a/tests/ten_runtime/integration/cpp/http_basic/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/http_basic/BUILD.gn @@ -33,9 +33,6 @@ ten_package_test_prepare_auxiliary_resources("restful_http_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("http_basic") { diff --git a/tests/ten_runtime/integration/cpp/http_basic/test_case.py b/tests/ten_runtime/integration/cpp/http_basic/test_case.py index 0f9d81585b..fdb0d011bd 100644 --- a/tests/ten_runtime/integration/cpp/http_basic/test_case.py +++ b/tests/ten_runtime/integration/cpp/http_basic/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def run_test_post(): @@ -47,6 +47,26 @@ def test_restful_http_app(): ) app_root_path = os.path.join(base_path, "restful_http_app") + source_pkg_name = "restful_app_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -99,3 +119,9 @@ def test_restful_http_app(): print("The exit code of restful_http_app: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/cpp/large_result/BUILD.gn b/tests/ten_runtime/integration/cpp/large_result/BUILD.gn index cb5c4974f4..bf236b5bf6 100644 --- a/tests/ten_runtime/integration/cpp/large_result/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/large_result/BUILD.gn @@ -34,9 +34,6 @@ ten_package_test_prepare_auxiliary_resources("large_result_http_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("large_result") { diff --git a/tests/ten_runtime/integration/cpp/large_result/test_case.py b/tests/ten_runtime/integration/cpp/large_result/test_case.py index f70877b038..49ea594579 100644 --- a/tests/ten_runtime/integration/cpp/large_result/test_case.py +++ b/tests/ten_runtime/integration/cpp/large_result/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def get_large_result(): @@ -48,6 +48,26 @@ def test_large_result_http(): ) app_root_path = os.path.join(base_path, "large_result_http") + source_pkg_name = "large_result_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -100,3 +120,9 @@ def test_large_result_http(): print("The exit code of large_result_http: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/cpp/multi_apps/BUILD.gn b/tests/ten_runtime/integration/cpp/multi_apps/BUILD.gn index 32d666e3a6..152c584bdb 100644 --- a/tests/ten_runtime/integration/cpp/multi_apps/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/multi_apps/BUILD.gn @@ -74,9 +74,6 @@ ten_package_test_prepare_auxiliary_resources("multi_apps_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("multi_apps") { diff --git a/tests/ten_runtime/integration/cpp/multi_apps/test_case.py b/tests/ten_runtime/integration/cpp/multi_apps/test_case.py index 029c5c7271..82221c3eed 100644 --- a/tests/ten_runtime/integration/cpp/multi_apps/test_case.py +++ b/tests/ten_runtime/integration/cpp/multi_apps/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def install_app(app_name: str): @@ -16,6 +16,27 @@ def install_app(app_name: str): my_env = os.environ.copy() app_root_path = os.path.join(base_path, app_name) + source_pkg_name = app_name + "_source" + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + source_root_path = os.path.join(base_path, source_pkg_name) + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -67,7 +88,15 @@ def start_app(app_name: str, port: int) -> subprocess.Popen: base_path, f"{app_name}/bin/{app_name}_source" ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + root_dir = os.path.join(base_path, "../../../../../") + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, f"{app_name}/ten_packages/system/ten_runtime/lib/libasan.so", @@ -123,7 +152,14 @@ def start_client(app_name: str) -> subprocess.Popen: ) client_cmd = os.path.join(base_path, "multi_apps_client") - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + root_dir = os.path.join(base_path, "../../../../../") + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, f"{app_name}/ten_packages/system/ten_runtime/lib/libasan.so", diff --git a/tests/ten_runtime/integration/cpp/standalone_test_cpp/BUILD.gn b/tests/ten_runtime/integration/cpp/standalone_test_cpp/BUILD.gn index f0b0d0cba1..f84ed4f415 100644 --- a/tests/ten_runtime/integration/cpp/standalone_test_cpp/BUILD.gn +++ b/tests/ten_runtime/integration/cpp/standalone_test_cpp/BUILD.gn @@ -9,17 +9,14 @@ import("//build/ten_runtime/ten.gni") ten_package_test_prepare_auxiliary_resources("standalone_test_cpp_files") { resources = [ - "//tests/ten_runtime/integration/common/build_config.py=>common/build_config.py", + "//tests/ten_runtime/integration/common=>common", "//tests/ten_runtime/integration/cpp/standalone_test_cpp/default_extension_cpp=>default_extension_cpp", "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } if (ten_enable_package_manager) { - # The standalone testing for the C++ extension depends on the Googletest + # The standalone testing for the C++ extension depends on the googletest # system package. deps = [ "//third_party/googletest:googletest_system_package" ] } diff --git a/tests/ten_runtime/integration/cpp/standalone_test_cpp/test_case.py b/tests/ten_runtime/integration/cpp/standalone_test_cpp/test_case.py index 6390e340b9..b4b408fc49 100644 --- a/tests/ten_runtime/integration/cpp/standalone_test_cpp/test_case.py +++ b/tests/ten_runtime/integration/cpp/standalone_test_cpp/test_case.py @@ -38,7 +38,7 @@ def test_standalone_test_cpp(): assert tman_install_rc == 0 build_config_args = build_config.parse_build_config( - os.path.join(root_dir, "args.gn"), + os.path.join(root_dir, "tgn_args.txt"), ) # Step 2: diff --git a/tests/ten_runtime/integration/go/access_property_go/BUILD.gn b/tests/ten_runtime/integration/go/access_property_go/BUILD.gn index 88c9f7e988..dbf77e1eae 100644 --- a/tests/ten_runtime/integration/go/access_property_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/access_property_go/BUILD.gn @@ -50,9 +50,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("access_property_go") { diff --git a/tests/ten_runtime/integration/go/access_property_go/test_case.py b/tests/ten_runtime/integration/go/access_property_go/test_case.py index 42c35fdac6..5a965fe6a6 100644 --- a/tests/ten_runtime/integration/go/access_property_go/test_case.py +++ b/tests/ten_runtime/integration/go/access_property_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_access_property_go(): @@ -16,7 +16,27 @@ def test_access_property_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "access_property_go_app") + source_pkg_name = "access_property_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -50,7 +70,10 @@ def test_access_property_go(): "access_property_go_app/ten_packages/system/ten_runtime/lib", ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "access_property_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -96,3 +119,10 @@ def test_access_property_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/close_app_go/BUILD.gn b/tests/ten_runtime/integration/go/close_app_go/BUILD.gn index cb1bbd553b..2e7bc23f60 100644 --- a/tests/ten_runtime/integration/go/close_app_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/close_app_go/BUILD.gn @@ -51,9 +51,6 @@ ten_package_test_prepare_auxiliary_resources("close_app_go_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("close_app_go") { diff --git a/tests/ten_runtime/integration/go/close_app_go/test_case.py b/tests/ten_runtime/integration/go/close_app_go/test_case.py index 75ce1d8fda..4e24967499 100644 --- a/tests/ten_runtime/integration/go/close_app_go/test_case.py +++ b/tests/ten_runtime/integration/go/close_app_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_close_app_go(): @@ -16,7 +16,27 @@ def test_close_app_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "close_app_go_app") + source_pkg_name = "close_app_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -48,7 +68,10 @@ def test_close_app_go(): base_path, "close_app_go_app/ten_packages/system/ten_runtime/lib" ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "close_app_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -94,3 +117,10 @@ def test_close_app_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/exit_signal/BUILD.gn b/tests/ten_runtime/integration/go/exit_signal/BUILD.gn index 417fca7ed0..d922b431a4 100644 --- a/tests/ten_runtime/integration/go/exit_signal/BUILD.gn +++ b/tests/ten_runtime/integration/go/exit_signal/BUILD.gn @@ -31,12 +31,10 @@ ten_package_test_prepare_app("exit_signal_app") { ten_package_test_prepare_auxiliary_resources("exit_signal_app_test_files") { resources = [ + "//tests/ten_runtime/integration/common=>common", "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("exit_signal") { diff --git a/tests/ten_runtime/integration/go/exit_signal/test_case.py b/tests/ten_runtime/integration/go/exit_signal/test_case.py index 88defe271b..7bc27cd4cb 100644 --- a/tests/ten_runtime/integration/go/exit_signal/test_case.py +++ b/tests/ten_runtime/integration/go/exit_signal/test_case.py @@ -9,6 +9,7 @@ from sys import stdout import signal import time +from .common import build_config, build_pkg def start_app(): @@ -18,7 +19,28 @@ def start_app(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "exit_signal_app") + source_pkg_name = "exit_signal_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + source_root_path = os.path.join(base_path, source_pkg_name) + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -50,7 +72,10 @@ def start_app(): base_path, "exit_signal_app/lib" ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "exit_signal_app/ten_packages/system/ten_runtime/lib/libasan.so", diff --git a/tests/ten_runtime/integration/go/expired_ten_go/BUILD.gn b/tests/ten_runtime/integration/go/expired_ten_go/BUILD.gn index d9d7892ac9..94df810b0f 100644 --- a/tests/ten_runtime/integration/go/expired_ten_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/expired_ten_go/BUILD.gn @@ -53,9 +53,6 @@ ten_package_test_prepare_auxiliary_resources("expired_ten_go_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("expired_ten_go") { diff --git a/tests/ten_runtime/integration/go/expired_ten_go/test_case.py b/tests/ten_runtime/integration/go/expired_ten_go/test_case.py index 48774fd34b..a8379696f9 100644 --- a/tests/ten_runtime/integration/go/expired_ten_go/test_case.py +++ b/tests/ten_runtime/integration/go/expired_ten_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_expired_ten_go(): @@ -16,7 +16,27 @@ def test_expired_ten_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "expired_ten_go_app") + source_pkg_name = "expired_ten_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -48,7 +68,10 @@ def test_expired_ten_go(): base_path, "expired_ten_go_app/ten_packages/system/ten_runtime/lib" ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "expired_ten_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -94,3 +117,10 @@ def test_expired_ten_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/frequently_cgo_call_go/BUILD.gn b/tests/ten_runtime/integration/go/frequently_cgo_call_go/BUILD.gn index 0bbaadacc0..985af54931 100644 --- a/tests/ten_runtime/integration/go/frequently_cgo_call_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/frequently_cgo_call_go/BUILD.gn @@ -52,9 +52,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("frequently_cgo_call_go") { diff --git a/tests/ten_runtime/integration/go/frequently_cgo_call_go/test_case.py b/tests/ten_runtime/integration/go/frequently_cgo_call_go/test_case.py index eb4521380f..c19f282122 100644 --- a/tests/ten_runtime/integration/go/frequently_cgo_call_go/test_case.py +++ b/tests/ten_runtime/integration/go/frequently_cgo_call_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_frequently_cgo_call_go(): @@ -32,7 +32,27 @@ def test_frequently_cgo_call_go(): "frequently_cgo_call_go_app/ten_packages/system/ten_runtime/lib", ) - app_root_path = os.path.join(base_path, "frequently_cgo_call_go_app") + source_pkg_name = "frequently_cgo_call_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -88,3 +108,10 @@ def test_frequently_cgo_call_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/handle_error_go/BUILD.gn b/tests/ten_runtime/integration/go/handle_error_go/BUILD.gn index af99fdd2a3..d7b6345849 100644 --- a/tests/ten_runtime/integration/go/handle_error_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/handle_error_go/BUILD.gn @@ -51,9 +51,6 @@ ten_package_test_prepare_auxiliary_resources("handle_error_go_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("handle_error_go") { diff --git a/tests/ten_runtime/integration/go/handle_error_go/test_case.py b/tests/ten_runtime/integration/go/handle_error_go/test_case.py index f81e221db8..c5bf35552d 100644 --- a/tests/ten_runtime/integration/go/handle_error_go/test_case.py +++ b/tests/ten_runtime/integration/go/handle_error_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_handle_error_go(): @@ -16,7 +16,27 @@ def test_handle_error_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "handle_error_go_app") + source_pkg_name = "handle_error_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -48,7 +68,10 @@ def test_handle_error_go(): base_path, "handle_error_go_app/ten_packages/system/ten_runtime/lib" ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "handle_error_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -94,3 +117,10 @@ def test_handle_error_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/no_dest_go/BUILD.gn b/tests/ten_runtime/integration/go/no_dest_go/BUILD.gn index 703724c680..20994cecee 100644 --- a/tests/ten_runtime/integration/go/no_dest_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/no_dest_go/BUILD.gn @@ -49,9 +49,6 @@ ten_package_test_prepare_auxiliary_resources("no_dest_go_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("no_dest_go") { diff --git a/tests/ten_runtime/integration/go/no_dest_go/test_case.py b/tests/ten_runtime/integration/go/no_dest_go/test_case.py index b118d4c842..3db6cd4138 100644 --- a/tests/ten_runtime/integration/go/no_dest_go/test_case.py +++ b/tests/ten_runtime/integration/go/no_dest_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_no_dest_go(): @@ -16,7 +16,27 @@ def test_no_dest_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "no_dest_go_app") + source_pkg_name = "no_dest_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -50,7 +70,10 @@ def test_no_dest_go(): "no_dest_go_app/ten_packages/system/ten_runtime/lib", ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "no_dest_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -96,3 +119,10 @@ def test_no_dest_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/prepare_to_stop_go/BUILD.gn b/tests/ten_runtime/integration/go/prepare_to_stop_go/BUILD.gn index 10cb85f473..d50cb13070 100644 --- a/tests/ten_runtime/integration/go/prepare_to_stop_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/prepare_to_stop_go/BUILD.gn @@ -52,9 +52,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("prepare_to_stop_go") { diff --git a/tests/ten_runtime/integration/go/prepare_to_stop_go/test_case.py b/tests/ten_runtime/integration/go/prepare_to_stop_go/test_case.py index 52d24ad9ce..d5de198390 100644 --- a/tests/ten_runtime/integration/go/prepare_to_stop_go/test_case.py +++ b/tests/ten_runtime/integration/go/prepare_to_stop_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_prepare_to_stop_go(): @@ -16,7 +16,27 @@ def test_prepare_to_stop_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "prepare_to_stop_go_app") + source_pkg_name = "prepare_to_stop_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -50,7 +70,10 @@ def test_prepare_to_stop_go(): "prepare_to_stop_go_app/ten_packages/system/ten_runtime/lib", ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "prepare_to_stop_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -96,3 +119,10 @@ def test_prepare_to_stop_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/return_result_go/BUILD.gn b/tests/ten_runtime/integration/go/return_result_go/BUILD.gn index 7bdfa81f55..97bc87b004 100644 --- a/tests/ten_runtime/integration/go/return_result_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/return_result_go/BUILD.gn @@ -52,9 +52,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("return_result_go") { diff --git a/tests/ten_runtime/integration/go/return_result_go/test_case.py b/tests/ten_runtime/integration/go/return_result_go/test_case.py index d7e7a9a049..a79a3e2da3 100644 --- a/tests/ten_runtime/integration/go/return_result_go/test_case.py +++ b/tests/ten_runtime/integration/go/return_result_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_return_result_go(): @@ -16,7 +16,27 @@ def test_return_result_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "return_result_go_app") + source_pkg_name = "return_result_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -50,7 +70,10 @@ def test_return_result_go(): "return_result_go_app/ten_packages/system/ten_runtime/lib", ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "return_result_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -96,3 +119,10 @@ def test_return_result_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/return_value_go/BUILD.gn b/tests/ten_runtime/integration/go/return_value_go/BUILD.gn index 17920a3815..3633589548 100644 --- a/tests/ten_runtime/integration/go/return_value_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/return_value_go/BUILD.gn @@ -53,9 +53,6 @@ ten_package_test_prepare_auxiliary_resources("return_value_go_app_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("return_value_go") { diff --git a/tests/ten_runtime/integration/go/return_value_go/test_case.py b/tests/ten_runtime/integration/go/return_value_go/test_case.py index 86d8f7dd0a..2f3cfed597 100644 --- a/tests/ten_runtime/integration/go/return_value_go/test_case.py +++ b/tests/ten_runtime/integration/go/return_value_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_return_value_go(): @@ -16,7 +16,27 @@ def test_return_value_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "return_value_go_app") + source_pkg_name = "return_value_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -48,7 +68,10 @@ def test_return_value_go(): base_path, "return_value_go_app/ten_packages/system/ten_runtime/lib" ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "return_value_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -94,3 +117,10 @@ def test_return_value_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/start_app_sync_go/BUILD.gn b/tests/ten_runtime/integration/go/start_app_sync_go/BUILD.gn index 5bcb84566f..acb179417a 100644 --- a/tests/ten_runtime/integration/go/start_app_sync_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/start_app_sync_go/BUILD.gn @@ -52,9 +52,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("start_app_sync_go") { diff --git a/tests/ten_runtime/integration/go/start_app_sync_go/test_case.py b/tests/ten_runtime/integration/go/start_app_sync_go/test_case.py index 5377e62cd3..69955fd2fd 100644 --- a/tests/ten_runtime/integration/go/start_app_sync_go/test_case.py +++ b/tests/ten_runtime/integration/go/start_app_sync_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_start_app_sync_go(): @@ -16,7 +16,27 @@ def test_start_app_sync_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "start_app_sync_go_app") + source_pkg_name = "start_app_sync_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -50,7 +70,10 @@ def test_start_app_sync_go(): "start_app_sync_go_app/ten_packages/system/ten_runtime/lib", ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "start_app_sync_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -96,3 +119,10 @@ def test_start_app_sync_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/three_extension_cmd_go/BUILD.gn b/tests/ten_runtime/integration/go/three_extension_cmd_go/BUILD.gn index 5f2649eaf1..83f6f918c6 100644 --- a/tests/ten_runtime/integration/go/three_extension_cmd_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/three_extension_cmd_go/BUILD.gn @@ -52,9 +52,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("three_extension_cmd_go") { diff --git a/tests/ten_runtime/integration/go/three_extension_cmd_go/test_case.py b/tests/ten_runtime/integration/go/three_extension_cmd_go/test_case.py index a8d05325f8..619b83f8c3 100644 --- a/tests/ten_runtime/integration/go/three_extension_cmd_go/test_case.py +++ b/tests/ten_runtime/integration/go/three_extension_cmd_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_three_extension_cmd_go(): @@ -16,7 +16,27 @@ def test_three_extension_cmd_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "three_extension_cmd_go_app") + source_pkg_name = "three_extension_cmd_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -50,7 +70,10 @@ def test_three_extension_cmd_go(): "three_extension_cmd_go_app/ten_packages/system/ten_runtime/lib", ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "three_extension_cmd_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -96,3 +119,10 @@ def test_three_extension_cmd_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/transfer_pointer_go/BUILD.gn b/tests/ten_runtime/integration/go/transfer_pointer_go/BUILD.gn index 34cc87f4b2..7a06e43bc5 100644 --- a/tests/ten_runtime/integration/go/transfer_pointer_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/transfer_pointer_go/BUILD.gn @@ -54,9 +54,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("transfer_pointer_go") { diff --git a/tests/ten_runtime/integration/go/transfer_pointer_go/test_case.py b/tests/ten_runtime/integration/go/transfer_pointer_go/test_case.py index 8abac3c3d5..77066c06a9 100644 --- a/tests/ten_runtime/integration/go/transfer_pointer_go/test_case.py +++ b/tests/ten_runtime/integration/go/transfer_pointer_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_transfer_pointer_go(): @@ -16,7 +16,27 @@ def test_transfer_pointer_go(): my_env = os.environ.copy() - app_root_path = os.path.join(base_path, "transfer_pointer_go_app") + source_pkg_name = "transfer_pointer_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -50,7 +70,10 @@ def test_transfer_pointer_go(): "transfer_pointer_go_app/ten_packages/system/ten_runtime/lib", ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "transfer_pointer_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -96,3 +119,10 @@ def test_transfer_pointer_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/go/two_extension_one_group_cmd_go/BUILD.gn b/tests/ten_runtime/integration/go/two_extension_one_group_cmd_go/BUILD.gn index 03fa134a0b..432c2966fb 100644 --- a/tests/ten_runtime/integration/go/two_extension_one_group_cmd_go/BUILD.gn +++ b/tests/ten_runtime/integration/go/two_extension_one_group_cmd_go/BUILD.gn @@ -52,9 +52,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("two_extension_one_group_cmd_go") { diff --git a/tests/ten_runtime/integration/go/two_extension_one_group_cmd_go/test_case.py b/tests/ten_runtime/integration/go/two_extension_one_group_cmd_go/test_case.py index 839d1b776a..4f617b3ca0 100644 --- a/tests/ten_runtime/integration/go/two_extension_one_group_cmd_go/test_case.py +++ b/tests/ten_runtime/integration/go/two_extension_one_group_cmd_go/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import msgpack +from .common import msgpack, build_config, build_pkg def test_two_extension_on_group_cmd_go(): @@ -16,10 +16,28 @@ def test_two_extension_on_group_cmd_go(): my_env = os.environ.copy() - app_root_path = os.path.join( - base_path, "two_extension_one_group_cmd_go_app" + source_pkg_name = "two_extension_one_group_cmd_go_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), ) + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." + tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), "--config-file", @@ -52,7 +70,10 @@ def test_two_extension_on_group_cmd_go(): "two_extension_one_group_cmd_go_app/ten_packages/system/ten_runtime/lib", ) - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "two_extension_one_group_cmd_go_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -105,3 +126,10 @@ def test_two_extension_on_group_cmd_go(): print("client: ", client_rc) assert server_rc == 0 assert client_rc == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing phase, + # we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/BUILD.gn b/tests/ten_runtime/integration/python/BUILD.gn index f9c89624ff..edca1ece15 100644 --- a/tests/ten_runtime/integration/python/BUILD.gn +++ b/tests/ten_runtime/integration/python/BUILD.gn @@ -44,11 +44,16 @@ group("python") { if (ten_enable_python_binding && ten_enable_go_binding) { deps += [ - "go_app_cythonize", - "go_app_partially_cythonize", "go_app_python", "unused_addon_python", ] + + if (ten_enable_integration_tests_prebuilt) { + deps += [ + "go_app_cythonize", + "go_app_partially_cythonize", + ] + } } } diff --git a/tests/ten_runtime/integration/python/aio_http_server_python/BUILD.gn b/tests/ten_runtime/integration/python/aio_http_server_python/BUILD.gn index f73a474aea..02ee73980d 100644 --- a/tests/ten_runtime/integration/python/aio_http_server_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/aio_http_server_python/BUILD.gn @@ -34,9 +34,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("aio_http_server_python") { diff --git a/tests/ten_runtime/integration/python/aio_http_server_python/test_case.py b/tests/ten_runtime/integration/python/aio_http_server_python/test_case.py index e6d5f7d79d..32eb98f961 100644 --- a/tests/ten_runtime/integration/python/aio_http_server_python/test_case.py +++ b/tests/ten_runtime/integration/python/aio_http_server_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_aio_http_server_python(): base_path, "aio_http_server_python_app/lib" ) - app_root_path = os.path.join(base_path, "aio_http_server_python_app") + source_pkg_name = "aio_http_server_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_aio_http_server_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "aio_http_server_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -128,3 +148,10 @@ def test_aio_http_server_python(): print("The exit code of aio_http_server_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/async_extension_basic_python/BUILD.gn b/tests/ten_runtime/integration/python/async_extension_basic_python/BUILD.gn index 4828c81873..85220a1c2d 100644 --- a/tests/ten_runtime/integration/python/async_extension_basic_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/async_extension_basic_python/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("async_extension_basic_python") { diff --git a/tests/ten_runtime/integration/python/async_extension_basic_python/test_case.py b/tests/ten_runtime/integration/python/async_extension_basic_python/test_case.py index ea089778ab..660587fbb0 100644 --- a/tests/ten_runtime/integration/python/async_extension_basic_python/test_case.py +++ b/tests/ten_runtime/integration/python/async_extension_basic_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_async_extension_basic_python(): base_path, "async_extension_basic_python_app/lib" ) - app_root_path = os.path.join(base_path, "async_extension_basic_python_app") + source_pkg_name = "async_extension_basic_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_async_extension_basic_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "async_extension_basic_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -134,3 +154,10 @@ def test_async_extension_basic_python(): print("The exit code of async_extension_basic_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/async_io_basic_python/BUILD.gn b/tests/ten_runtime/integration/python/async_io_basic_python/BUILD.gn index fe7591dbc5..efdf4b86e4 100644 --- a/tests/ten_runtime/integration/python/async_io_basic_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/async_io_basic_python/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("async_io_basic_python") { diff --git a/tests/ten_runtime/integration/python/async_io_basic_python/test_case.py b/tests/ten_runtime/integration/python/async_io_basic_python/test_case.py index 3d92a871ca..dbeb81b2ca 100644 --- a/tests/ten_runtime/integration/python/async_io_basic_python/test_case.py +++ b/tests/ten_runtime/integration/python/async_io_basic_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_async_io_basic_python(): base_path, "async_io_basic_python_app/lib" ) - app_root_path = os.path.join(base_path, "async_io_basic_python_app") + source_pkg_name = "async_io_basic_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_async_io_basic_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "async_io_basic_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -128,3 +148,10 @@ def test_async_io_basic_python(): print("The exit code of async_io_basic_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/cpp_app_multi_process_python/BUILD.gn b/tests/ten_runtime/integration/python/cpp_app_multi_process_python/BUILD.gn index 4c0c60b7c6..30c7074d2a 100644 --- a/tests/ten_runtime/integration/python/cpp_app_multi_process_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/cpp_app_multi_process_python/BUILD.gn @@ -42,9 +42,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("cpp_app_multi_process_python") { diff --git a/tests/ten_runtime/integration/python/cpp_app_multi_process_python/test_case.py b/tests/ten_runtime/integration/python/cpp_app_multi_process_python/test_case.py index dd202ab96f..2387b175d6 100644 --- a/tests/ten_runtime/integration/python/cpp_app_multi_process_python/test_case.py +++ b/tests/ten_runtime/integration/python/cpp_app_multi_process_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_cpp_app_multi_process_python(): base_path, "cpp_app_multi_process_python_app/lib" ) + source_pkg_name = "cpp_app_multi_process_python_app_source" app_root_path = os.path.join(base_path, "cpp_app_multi_process_python_app") + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,10 @@ def test_cpp_app_multi_process_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "cpp_app_multi_process_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -134,3 +157,10 @@ def test_cpp_app_multi_process_python(): print("The exit code of cpp_app_multi_process_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/cpp_app_python/BUILD.gn b/tests/ten_runtime/integration/python/cpp_app_python/BUILD.gn index 9dc546be2d..3c620f977a 100644 --- a/tests/ten_runtime/integration/python/cpp_app_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/cpp_app_python/BUILD.gn @@ -42,9 +42,6 @@ ten_package_test_prepare_auxiliary_resources("cpp_app_python_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("cpp_app_python") { diff --git a/tests/ten_runtime/integration/python/cpp_app_python/test_case.py b/tests/ten_runtime/integration/python/cpp_app_python/test_case.py index 749999df16..333025d7fe 100644 --- a/tests/ten_runtime/integration/python/cpp_app_python/test_case.py +++ b/tests/ten_runtime/integration/python/cpp_app_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -56,7 +56,27 @@ def test_cpp_app_python(): base_path, "cpp_app_python_app/lib" ) + source_pkg_name = "cpp_app_python_app_source" app_root_path = os.path.join(base_path, "cpp_app_python_app") + app_language = "cpp" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -82,7 +102,10 @@ def test_cpp_app_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "cpp_app_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -129,3 +152,10 @@ def test_cpp_app_python(): print("The exit code of cpp_app_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/get_set_prop_python/BUILD.gn b/tests/ten_runtime/integration/python/get_set_prop_python/BUILD.gn index d1d28cf664..31074416bc 100644 --- a/tests/ten_runtime/integration/python/get_set_prop_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/get_set_prop_python/BUILD.gn @@ -36,9 +36,6 @@ ten_package_test_prepare_auxiliary_resources("get_set_prop_python_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("get_set_prop_python") { diff --git a/tests/ten_runtime/integration/python/get_set_prop_python/test_case.py b/tests/ten_runtime/integration/python/get_set_prop_python/test_case.py index 3bf0bbb80a..ee563528a7 100644 --- a/tests/ten_runtime/integration/python/get_set_prop_python/test_case.py +++ b/tests/ten_runtime/integration/python/get_set_prop_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_get_set_prop_python(): base_path, "get_set_prop_python_app/lib" ) - app_root_path = os.path.join(base_path, "get_set_prop_python_app") + source_pkg_name = "get_set_prop_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_get_set_prop_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "get_set_prop_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -128,3 +148,10 @@ def test_get_set_prop_python(): print("The exit code of get_set_prop_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/go_app_async_extension_python/BUILD.gn b/tests/ten_runtime/integration/python/go_app_async_extension_python/BUILD.gn index 462fc2cb4a..f31c212934 100644 --- a/tests/ten_runtime/integration/python/go_app_async_extension_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/go_app_async_extension_python/BUILD.gn @@ -42,9 +42,6 @@ ten_package_test_prepare_auxiliary_resources("go_app_async_extension_python_test "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("go_app_async_extension_python") { diff --git a/tests/ten_runtime/integration/python/go_app_async_extension_python/test_case.py b/tests/ten_runtime/integration/python/go_app_async_extension_python/test_case.py index 0440d9f454..bd3c042754 100644 --- a/tests/ten_runtime/integration/python/go_app_async_extension_python/test_case.py +++ b/tests/ten_runtime/integration/python/go_app_async_extension_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_go_app_async_extension_python(): base_path, "go_app_async_extension_python_app/lib" ) - app_root_path = os.path.join(base_path, "go_app_async_extension_python_app") + source_pkg_name = "go_app_async_extension_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -71,7 +91,9 @@ def test_go_app_async_extension_python(): ) tman_install_process.wait() - bootstrap_cmd = os.path.join(base_path, "go_app_async_extension_python_app/bin/bootstrap") + bootstrap_cmd = os.path.join( + base_path, "go_app_async_extension_python_app/bin/bootstrap" + ) bootstrap_process = subprocess.Popen( bootstrap_cmd, stdout=stdout, stderr=subprocess.STDOUT, env=my_env @@ -79,7 +101,10 @@ def test_go_app_async_extension_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "go_app_async_extension_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -88,7 +113,9 @@ def test_go_app_async_extension_python(): if os.path.exists(libasan_path): my_env["LD_PRELOAD"] = libasan_path - server_cmd = os.path.join(base_path, "go_app_async_extension_python_app/bin/start") + server_cmd = os.path.join( + base_path, "go_app_async_extension_python_app/bin/start" + ) server = subprocess.Popen( server_cmd, @@ -100,7 +127,9 @@ def test_go_app_async_extension_python(): is_started = http.is_app_started("127.0.0.1", 8002, 30) if not is_started: - print("The go_app_async_extension_python is not started after 30 seconds.") + print( + "The go_app_async_extension_python is not started after 30 seconds." + ) server.kill() exit_code = server.wait() @@ -119,10 +148,19 @@ def test_go_app_async_extension_python(): finally: is_stopped = http.stop_app("127.0.0.1", 8002, 30) if not is_stopped: - print("The go_app_async_extension_python can not stop after 30 seconds.") + print( + "The go_app_async_extension_python can not stop after 30 seconds." + ) server.kill() exit_code = server.wait() print("The exit code of go_app_async_extension_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/go_app_cythonize/BUILD.gn b/tests/ten_runtime/integration/python/go_app_cythonize/BUILD.gn index b429f4400d..ebcfc8917d 100644 --- a/tests/ten_runtime/integration/python/go_app_cythonize/BUILD.gn +++ b/tests/ten_runtime/integration/python/go_app_cythonize/BUILD.gn @@ -40,9 +40,6 @@ ten_package_test_prepare_auxiliary_resources("go_app_cythonize_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("go_app_cythonize") { diff --git a/tests/ten_runtime/integration/python/go_app_cythonize/test_case.py b/tests/ten_runtime/integration/python/go_app_cythonize/test_case.py index 1f3990ff62..f3a05e71f8 100644 --- a/tests/ten_runtime/integration/python/go_app_cythonize/test_case.py +++ b/tests/ten_runtime/integration/python/go_app_cythonize/test_case.py @@ -7,7 +7,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -118,7 +118,27 @@ def test_go_app_cythonize(): base_path, "go_app_cythonize_app/lib" ) - app_root_path = os.path.join(base_path, "go_app_cythonize_app") + source_pkg_name = "go_app_cythonize_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -148,7 +168,10 @@ def test_go_app_cythonize(): compile_pyx(app_root_path) if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "go_app_cythonize_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -195,3 +218,10 @@ def test_go_app_cythonize(): print("The exit code of go_app_cythonize: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/go_app_partially_cythonize/BUILD.gn b/tests/ten_runtime/integration/python/go_app_partially_cythonize/BUILD.gn index dd45ed288d..8053494c1e 100644 --- a/tests/ten_runtime/integration/python/go_app_partially_cythonize/BUILD.gn +++ b/tests/ten_runtime/integration/python/go_app_partially_cythonize/BUILD.gn @@ -41,9 +41,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("go_app_partially_cythonize") { diff --git a/tests/ten_runtime/integration/python/go_app_partially_cythonize/test_case.py b/tests/ten_runtime/integration/python/go_app_partially_cythonize/test_case.py index f4a45a5bdc..6aff6f6f0f 100644 --- a/tests/ten_runtime/integration/python/go_app_partially_cythonize/test_case.py +++ b/tests/ten_runtime/integration/python/go_app_partially_cythonize/test_case.py @@ -7,7 +7,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -121,7 +121,27 @@ def test_go_app_partially_cythonize(): base_path, "go_app_partially_cythonize_app/lib" ) - app_root_path = os.path.join(base_path, "go_app_partially_cythonize_app") + source_pkg_name = "go_app_partially_cythonize_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -151,7 +171,10 @@ def test_go_app_partially_cythonize(): compile_pyx(app_root_path) if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "go_app_partially_cythonize_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -202,3 +225,10 @@ def test_go_app_partially_cythonize(): print("The exit code of go_app_partially_cythonize: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/go_app_python/BUILD.gn b/tests/ten_runtime/integration/python/go_app_python/BUILD.gn index 32ae726da3..8871279f50 100644 --- a/tests/ten_runtime/integration/python/go_app_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/go_app_python/BUILD.gn @@ -42,9 +42,6 @@ ten_package_test_prepare_auxiliary_resources("go_app_python_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("go_app_python") { diff --git a/tests/ten_runtime/integration/python/go_app_python/test_case.py b/tests/ten_runtime/integration/python/go_app_python/test_case.py index 73db7c4771..617fe61d31 100644 --- a/tests/ten_runtime/integration/python/go_app_python/test_case.py +++ b/tests/ten_runtime/integration/python/go_app_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_go_app_python(): base_path, "go_app_python_app/lib" ) - app_root_path = os.path.join(base_path, "go_app_python_app") + source_pkg_name = "go_app_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -79,7 +99,10 @@ def test_go_app_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "go_app_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -126,3 +149,10 @@ def test_go_app_python(): print("The exit code of go_app_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/large_json_python/BUILD.gn b/tests/ten_runtime/integration/python/large_json_python/BUILD.gn index 83536eb9bb..fdb3e5c1e5 100644 --- a/tests/ten_runtime/integration/python/large_json_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/large_json_python/BUILD.gn @@ -39,9 +39,6 @@ ten_package_test_prepare_auxiliary_resources("large_json_python_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("large_json_python") { diff --git a/tests/ten_runtime/integration/python/large_json_python/test_case.py b/tests/ten_runtime/integration/python/large_json_python/test_case.py index fdb69bc5c2..7e0665d068 100644 --- a/tests/ten_runtime/integration/python/large_json_python/test_case.py +++ b/tests/ten_runtime/integration/python/large_json_python/test_case.py @@ -7,7 +7,7 @@ import sys import pytest from sys import stdout -from .common import http +from .common import http, build_config, build_pkg @pytest.fixture(scope="function") @@ -86,7 +86,27 @@ def test_large_json_python(): base_path, "large_json_python_app/lib" ) - app_root_path = os.path.join(base_path, "large_json_python_app") + source_pkg_name = "large_json_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -114,7 +134,7 @@ def test_large_json_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "large_json_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -161,3 +181,10 @@ def test_large_json_python(): print("The exit code of large_json_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/multi_process_python/BUILD.gn b/tests/ten_runtime/integration/python/multi_process_python/BUILD.gn index 44761817b8..4a4959c164 100644 --- a/tests/ten_runtime/integration/python/multi_process_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/multi_process_python/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("multi_process_python") { diff --git a/tests/ten_runtime/integration/python/multi_process_python/test_case.py b/tests/ten_runtime/integration/python/multi_process_python/test_case.py index 755bf64fea..4ca1b78557 100644 --- a/tests/ten_runtime/integration/python/multi_process_python/test_case.py +++ b/tests/ten_runtime/integration/python/multi_process_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_multi_process_python(): base_path, "multi_process_python_app/lib" ) - app_root_path = os.path.join(base_path, "multi_process_python_app") + source_pkg_name = "multi_process_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_multi_process_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "multi_process_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -128,3 +148,10 @@ def test_multi_process_python(): print("The exit code of multi_process_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/multiple_results_python_1/BUILD.gn b/tests/ten_runtime/integration/python/multiple_results_python_1/BUILD.gn index 4837a4d0ef..dc0434891b 100644 --- a/tests/ten_runtime/integration/python/multiple_results_python_1/BUILD.gn +++ b/tests/ten_runtime/integration/python/multiple_results_python_1/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("multiple_results_python_1") { diff --git a/tests/ten_runtime/integration/python/multiple_results_python_1/test_case.py b/tests/ten_runtime/integration/python/multiple_results_python_1/test_case.py index f545decdff..3edd0cac24 100644 --- a/tests/ten_runtime/integration/python/multiple_results_python_1/test_case.py +++ b/tests/ten_runtime/integration/python/multiple_results_python_1/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_multiple_results_python_1(): base_path, "multiple_results_python_1_app/lib" ) - app_root_path = os.path.join(base_path, "multiple_results_python_1_app") + source_pkg_name = "multiple_results_python_1_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_multiple_results_python_1(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "multiple_results_python_1_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -132,3 +152,10 @@ def test_multiple_results_python_1(): print("The exit code of multiple_results_python_1: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/multiple_results_python_2/BUILD.gn b/tests/ten_runtime/integration/python/multiple_results_python_2/BUILD.gn index 3dce110940..36f31537f8 100644 --- a/tests/ten_runtime/integration/python/multiple_results_python_2/BUILD.gn +++ b/tests/ten_runtime/integration/python/multiple_results_python_2/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("multiple_results_python_2") { diff --git a/tests/ten_runtime/integration/python/multiple_results_python_2/test_case.py b/tests/ten_runtime/integration/python/multiple_results_python_2/test_case.py index a9e8720938..35cfd046cc 100644 --- a/tests/ten_runtime/integration/python/multiple_results_python_2/test_case.py +++ b/tests/ten_runtime/integration/python/multiple_results_python_2/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_multiple_results_python_2(): base_path, "multiple_results_python_2_app/lib" ) - app_root_path = os.path.join(base_path, "multiple_results_python_2_app") + source_pkg_name = "multiple_results_python_2_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_multiple_results_python_2(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "multiple_results_python_2_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -132,3 +152,10 @@ def test_multiple_results_python_2(): print("The exit code of multiple_results_python_2: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/multiple_results_python_3/BUILD.gn b/tests/ten_runtime/integration/python/multiple_results_python_3/BUILD.gn index aab3f7d7a1..9e7d727923 100644 --- a/tests/ten_runtime/integration/python/multiple_results_python_3/BUILD.gn +++ b/tests/ten_runtime/integration/python/multiple_results_python_3/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("multiple_results_python_3") { diff --git a/tests/ten_runtime/integration/python/multiple_results_python_3/test_case.py b/tests/ten_runtime/integration/python/multiple_results_python_3/test_case.py index 179ff5fd7e..1374aab9f6 100644 --- a/tests/ten_runtime/integration/python/multiple_results_python_3/test_case.py +++ b/tests/ten_runtime/integration/python/multiple_results_python_3/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_multiple_results_python_3(): base_path, "multiple_results_python_3_app/lib" ) - app_root_path = os.path.join(base_path, "multiple_results_python_3_app") + source_pkg_name = "multiple_results_python_3_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_multiple_results_python_3(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "multiple_results_python_3_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -132,3 +152,10 @@ def test_multiple_results_python_3(): print("The exit code of multiple_results_python_3: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/no_dest_async_python/BUILD.gn b/tests/ten_runtime/integration/python/no_dest_async_python/BUILD.gn index c0ecef1ead..e0b5833e14 100644 --- a/tests/ten_runtime/integration/python/no_dest_async_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/no_dest_async_python/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("no_dest_async_python") { diff --git a/tests/ten_runtime/integration/python/no_dest_async_python/test_case.py b/tests/ten_runtime/integration/python/no_dest_async_python/test_case.py index 896ba6c7d7..06a9051b56 100644 --- a/tests/ten_runtime/integration/python/no_dest_async_python/test_case.py +++ b/tests/ten_runtime/integration/python/no_dest_async_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_no_dest_async_python(): base_path, "no_dest_async_python_app/lib" ) - app_root_path = os.path.join(base_path, "no_dest_async_python_app") + source_pkg_name = "no_dest_async_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_no_dest_async_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "no_dest_async_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -90,9 +110,7 @@ def test_no_dest_async_python(): if os.path.exists(libasan_path): my_env["LD_PRELOAD"] = libasan_path - server_cmd = os.path.join( - base_path, "no_dest_async_python_app/bin/start" - ) + server_cmd = os.path.join(base_path, "no_dest_async_python_app/bin/start") server = subprocess.Popen( server_cmd, @@ -104,9 +122,7 @@ def test_no_dest_async_python(): is_started = http.is_app_started("127.0.0.1", 8002, 30) if not is_started: - print( - "The no_dest_async_python is not started after 30 seconds." - ) + print("The no_dest_async_python is not started after 30 seconds.") server.kill() exit_code = server.wait() @@ -125,12 +141,17 @@ def test_no_dest_async_python(): finally: is_stopped = http.stop_app("127.0.0.1", 8002, 30) if not is_stopped: - print( - "The no_dest_async_python can not stop after 30 seconds." - ) + print("The no_dest_async_python can not stop after 30 seconds.") server.kill() exit_code = server.wait() print("The exit code of no_dest_async_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/no_dest_python/BUILD.gn b/tests/ten_runtime/integration/python/no_dest_python/BUILD.gn index 98eac65164..e386fddcb5 100644 --- a/tests/ten_runtime/integration/python/no_dest_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/no_dest_python/BUILD.gn @@ -36,9 +36,6 @@ ten_package_test_prepare_auxiliary_resources("no_dest_python_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("no_dest_python") { diff --git a/tests/ten_runtime/integration/python/no_dest_python/no_dest_python_app/ten_packages/extension/default_extension_python/addon.py b/tests/ten_runtime/integration/python/no_dest_python/no_dest_python_app/ten_packages/extension/default_extension_python/addon.py deleted file mode 100644 index 699fa5a885..0000000000 --- a/tests/ten_runtime/integration/python/no_dest_python/no_dest_python_app/ten_packages/extension/default_extension_python/addon.py +++ /dev/null @@ -1,19 +0,0 @@ -# -# This file is part of TEN Framework, an open source project. -# Licensed under the Apache License, Version 2.0. -# See the LICENSE file for more information. -# -from ten import ( - Addon, - register_addon_as_extension, - TenEnv, -) -from .extension import DefaultExtension - - -@register_addon_as_extension("default_extension_python") -class DefaultExtensionAddon(Addon): - - def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None: - ten_env.log_info("DefaultExtensionAddon on_create_instance") - ten_env.on_create_instance_done(DefaultExtension(name), context) diff --git a/tests/ten_runtime/integration/python/no_dest_python/no_dest_python_app/ten_packages/extension/default_extension_python/extension.py b/tests/ten_runtime/integration/python/no_dest_python/no_dest_python_app/ten_packages/extension/default_extension_python/extension.py index ffb7b04e2c..dd1db02499 100644 --- a/tests/ten_runtime/integration/python/no_dest_python/no_dest_python_app/ten_packages/extension/default_extension_python/extension.py +++ b/tests/ten_runtime/integration/python/no_dest_python/no_dest_python_app/ten_packages/extension/default_extension_python/extension.py @@ -14,7 +14,6 @@ VideoFrame, StatusCode, CmdResult, - LogLevel, TenError, ) diff --git a/tests/ten_runtime/integration/python/no_dest_python/test_case.py b/tests/ten_runtime/integration/python/no_dest_python/test_case.py index e3d62e2816..497b74cbf1 100644 --- a/tests/ten_runtime/integration/python/no_dest_python/test_case.py +++ b/tests/ten_runtime/integration/python/no_dest_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_no_dest_python(): base_path, "no_dest_python_app/lib" ) - app_root_path = os.path.join(base_path, "no_dest_python_app") + source_pkg_name = "no_dest_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -79,7 +99,7 @@ def test_no_dest_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "no_dest_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -126,3 +146,10 @@ def test_no_dest_python(): print("The exit code of no_dest_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/resp_handler_yield_python/BUILD.gn b/tests/ten_runtime/integration/python/resp_handler_yield_python/BUILD.gn index 29847a2181..9d537c443f 100644 --- a/tests/ten_runtime/integration/python/resp_handler_yield_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/resp_handler_yield_python/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("resp_handler_yield_python") { diff --git a/tests/ten_runtime/integration/python/resp_handler_yield_python/test_case.py b/tests/ten_runtime/integration/python/resp_handler_yield_python/test_case.py index 8986c7489b..e2803c60d5 100644 --- a/tests/ten_runtime/integration/python/resp_handler_yield_python/test_case.py +++ b/tests/ten_runtime/integration/python/resp_handler_yield_python/test_case.py @@ -7,7 +7,7 @@ import sys import pytest from sys import stdout -from .common import http +from .common import http, build_config, build_pkg @pytest.fixture(scope="function") @@ -86,7 +86,27 @@ def test_resp_handler_yield_python(): base_path, "resp_handler_yield_python_app/lib" ) - app_root_path = os.path.join(base_path, "resp_handler_yield_python_app") + source_pkg_name = "resp_handler_yield_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -114,7 +134,7 @@ def test_resp_handler_yield_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "resp_handler_yield_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -165,3 +185,10 @@ def test_resp_handler_yield_python(): print("The exit code of resp_handler_yield_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/send_cmd_discard_result_python/BUILD.gn b/tests/ten_runtime/integration/python/send_cmd_discard_result_python/BUILD.gn index a87263d735..16ae727881 100644 --- a/tests/ten_runtime/integration/python/send_cmd_discard_result_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/send_cmd_discard_result_python/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("send_cmd_discard_result_python") { diff --git a/tests/ten_runtime/integration/python/send_cmd_discard_result_python/test_case.py b/tests/ten_runtime/integration/python/send_cmd_discard_result_python/test_case.py index ca21f48c76..6a474d07d1 100644 --- a/tests/ten_runtime/integration/python/send_cmd_discard_result_python/test_case.py +++ b/tests/ten_runtime/integration/python/send_cmd_discard_result_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -52,11 +52,28 @@ def test_send_cmd_discard_result_python(): my_env["LD_LIBRARY_PATH"] = os.path.join( base_path, "send_cmd_discard_result_python_app/lib" ) + source_pkg_name = "send_cmd_discard_result_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" - app_root_path = os.path.join( - base_path, "send_cmd_discard_result_python_app" + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), ) + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." + tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), "--config-file", @@ -83,7 +100,7 @@ def test_send_cmd_discard_result_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "send_cmd_discard_result_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -136,3 +153,10 @@ def test_send_cmd_discard_result_python(): print("The exit code of send_cmd_discard_result_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/send_cmd_python/BUILD.gn b/tests/ten_runtime/integration/python/send_cmd_python/BUILD.gn index 741344fb36..72a0af6e3e 100644 --- a/tests/ten_runtime/integration/python/send_cmd_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/send_cmd_python/BUILD.gn @@ -36,9 +36,6 @@ ten_package_test_prepare_auxiliary_resources("send_cmd_python_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("send_cmd_python") { diff --git a/tests/ten_runtime/integration/python/send_cmd_python/test_case.py b/tests/ten_runtime/integration/python/send_cmd_python/test_case.py index 4a61335dd8..f5b75696e3 100644 --- a/tests/ten_runtime/integration/python/send_cmd_python/test_case.py +++ b/tests/ten_runtime/integration/python/send_cmd_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_send_cmd_python(): base_path, "send_cmd_python_app/lib" ) - app_root_path = os.path.join(base_path, "send_cmd_python_app") + source_pkg_name = "send_cmd_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -79,7 +99,7 @@ def test_send_cmd_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "send_cmd_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -126,3 +146,10 @@ def test_send_cmd_python(): print("The exit code of send_cmd_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/send_data_python/BUILD.gn b/tests/ten_runtime/integration/python/send_data_python/BUILD.gn index fe15630850..8d7ad216a0 100644 --- a/tests/ten_runtime/integration/python/send_data_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/send_data_python/BUILD.gn @@ -36,9 +36,6 @@ ten_package_test_prepare_auxiliary_resources("send_data_python_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("send_data_python") { diff --git a/tests/ten_runtime/integration/python/send_data_python/test_case.py b/tests/ten_runtime/integration/python/send_data_python/test_case.py index 6d01fbd5f9..46928ef750 100644 --- a/tests/ten_runtime/integration/python/send_data_python/test_case.py +++ b/tests/ten_runtime/integration/python/send_data_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_send_data_python(): base_path, "send_data_python_app/lib" ) - app_root_path = os.path.join(base_path, "send_data_python_app") + source_pkg_name = "send_data_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_send_data_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "send_data_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -128,3 +148,10 @@ def test_send_data_python(): print("The exit code of send_data_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/send_recv_image_python/BUILD.gn b/tests/ten_runtime/integration/python/send_recv_image_python/BUILD.gn index a3d1d7e467..708e492656 100644 --- a/tests/ten_runtime/integration/python/send_recv_image_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/send_recv_image_python/BUILD.gn @@ -42,9 +42,6 @@ ten_package_test_prepare_auxiliary_resources( "test_case.py", "test_data", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("send_recv_image_python") { diff --git a/tests/ten_runtime/integration/python/send_recv_image_python/test_case.py b/tests/ten_runtime/integration/python/send_recv_image_python/test_case.py index b77a02c0f2..c1bfa24f30 100644 --- a/tests/ten_runtime/integration/python/send_recv_image_python/test_case.py +++ b/tests/ten_runtime/integration/python/send_recv_image_python/test_case.py @@ -7,7 +7,7 @@ import sys import pytest from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -86,7 +86,27 @@ def test_send_recv_image_python(): base_path, "send_recv_image_python_app/lib" ) - app_root_path = os.path.join(base_path, "send_recv_image_python_app") + source_pkg_name = "send_recv_image_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -114,7 +134,7 @@ def test_send_recv_image_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "send_recv_image_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -161,3 +181,10 @@ def test_send_recv_image_python(): print("The exit code of send_recv_image_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/send_recv_pcm_python/BUILD.gn b/tests/ten_runtime/integration/python/send_recv_pcm_python/BUILD.gn index 7f9ceba249..c334f08060 100644 --- a/tests/ten_runtime/integration/python/send_recv_pcm_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/send_recv_pcm_python/BUILD.gn @@ -41,9 +41,6 @@ ten_package_test_prepare_auxiliary_resources( "test_case.py", "test_data", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("send_recv_pcm_python") { diff --git a/tests/ten_runtime/integration/python/send_recv_pcm_python/test_case.py b/tests/ten_runtime/integration/python/send_recv_pcm_python/test_case.py index 28069dda2a..db166a20f7 100644 --- a/tests/ten_runtime/integration/python/send_recv_pcm_python/test_case.py +++ b/tests/ten_runtime/integration/python/send_recv_pcm_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_send_recv_pcm_python(): base_path, "send_recv_pcm_python_app/lib" ) - app_root_path = os.path.join(base_path, "send_recv_pcm_python_app") + source_pkg_name = "send_recv_pcm_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_send_recv_pcm_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "send_recv_pcm_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -128,3 +148,10 @@ def test_send_recv_pcm_python(): print("The exit code of send_recv_pcm_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/standalone_test_python/BUILD.gn b/tests/ten_runtime/integration/python/standalone_test_python/BUILD.gn index 943150c354..d2c826f498 100644 --- a/tests/ten_runtime/integration/python/standalone_test_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/standalone_test_python/BUILD.gn @@ -10,13 +10,11 @@ import("//build/ten_runtime/ten.gni") ten_package_test_prepare_auxiliary_resources( "standalone_test_python_test_files") { resources = [ + "//tests/ten_runtime/integration/common=>common", "//tests/ten_runtime/integration/python/standalone_test_python/default_extension_python=>default_extension_python", "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("standalone_test_python") { diff --git a/tests/ten_runtime/integration/python/standalone_test_python/test_case.py b/tests/ten_runtime/integration/python/standalone_test_python/test_case.py index 61c7f6dd63..5c214cfb09 100644 --- a/tests/ten_runtime/integration/python/standalone_test_python/test_case.py +++ b/tests/ten_runtime/integration/python/standalone_test_python/test_case.py @@ -6,6 +6,7 @@ import os import sys from sys import stdout +from .common import build_config def test_standalone_test_python(): @@ -46,7 +47,11 @@ def test_standalone_test_python(): my_env["PYTHONDEVMODE"] = "1" if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, ( diff --git a/tests/ten_runtime/integration/python/two_async_exts_one_group_python/BUILD.gn b/tests/ten_runtime/integration/python/two_async_exts_one_group_python/BUILD.gn index 3918a98ecc..85afa3eb7d 100644 --- a/tests/ten_runtime/integration/python/two_async_exts_one_group_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/two_async_exts_one_group_python/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("two_async_exts_one_group_python") { diff --git a/tests/ten_runtime/integration/python/two_async_exts_one_group_python/test_case.py b/tests/ten_runtime/integration/python/two_async_exts_one_group_python/test_case.py index 61f10f485e..3122df5281 100644 --- a/tests/ten_runtime/integration/python/two_async_exts_one_group_python/test_case.py +++ b/tests/ten_runtime/integration/python/two_async_exts_one_group_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_two_async_exts_one_group_python(): base_path, "two_async_exts_one_group_python_app/lib" ) - app_root_path = os.path.join(base_path, "two_async_exts_one_group_python_app") + source_pkg_name = "two_async_exts_one_group_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_two_async_exts_one_group_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "two_async_exts_one_group_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -90,7 +110,9 @@ def test_two_async_exts_one_group_python(): if os.path.exists(libasan_path): my_env["LD_PRELOAD"] = libasan_path - server_cmd = os.path.join(base_path, "two_async_exts_one_group_python_app/bin/start") + server_cmd = os.path.join( + base_path, "two_async_exts_one_group_python_app/bin/start" + ) server = subprocess.Popen( server_cmd, @@ -102,7 +124,9 @@ def test_two_async_exts_one_group_python(): is_started = http.is_app_started("127.0.0.1", 8002, 30) if not is_started: - print("The two_async_exts_one_group_python is not started after 30 seconds.") + print( + "The two_async_exts_one_group_python is not started after 30 seconds." + ) server.kill() exit_code = server.wait() @@ -121,10 +145,19 @@ def test_two_async_exts_one_group_python(): finally: is_stopped = http.stop_app("127.0.0.1", 8002, 30) if not is_stopped: - print("The two_async_exts_one_group_python can not stop after 30 seconds.") + print( + "The two_async_exts_one_group_python can not stop after 30 seconds." + ) server.kill() exit_code = server.wait() print("The exit code of two_async_exts_one_group_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/two_async_exts_python/BUILD.gn b/tests/ten_runtime/integration/python/two_async_exts_python/BUILD.gn index 5601b48624..d009f787dc 100644 --- a/tests/ten_runtime/integration/python/two_async_exts_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/two_async_exts_python/BUILD.gn @@ -37,9 +37,6 @@ ten_package_test_prepare_auxiliary_resources( "__init__.py", "test_case.py", ] - if (enable_sanitizer) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("two_async_exts_python") { diff --git a/tests/ten_runtime/integration/python/two_async_exts_python/test_case.py b/tests/ten_runtime/integration/python/two_async_exts_python/test_case.py index 304dded44b..7c30118175 100644 --- a/tests/ten_runtime/integration/python/two_async_exts_python/test_case.py +++ b/tests/ten_runtime/integration/python/two_async_exts_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,27 @@ def test_two_async_exts_python(): base_path, "two_async_exts_python_app/lib" ) + source_pkg_name = "two_async_exts_python_app" app_root_path = os.path.join(base_path, "two_async_exts_python_app") + app_language = "python" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +101,7 @@ def test_two_async_exts_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if build_config_args.enable_sanitizer: libasan_path = os.path.join( base_path, "two_async_exts_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -128,3 +148,10 @@ def test_two_async_exts_python(): print("The exit code of two_async_exts_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/python/unused_addon_python/BUILD.gn b/tests/ten_runtime/integration/python/unused_addon_python/BUILD.gn index 9180f9289e..e8dc1a9e3d 100644 --- a/tests/ten_runtime/integration/python/unused_addon_python/BUILD.gn +++ b/tests/ten_runtime/integration/python/unused_addon_python/BUILD.gn @@ -43,9 +43,6 @@ ten_package_test_prepare_auxiliary_resources("unused_addon_python_test_files") { "__init__.py", "test_case.py", ] - if (enable_sanitizer && !is_clang) { - resources += [ "//tests/ten_runtime/integration/tools/use_asan_lib_marker=>use_asan_lib_marker" ] - } } group("unused_addon_python") { diff --git a/tests/ten_runtime/integration/python/unused_addon_python/test_case.py b/tests/ten_runtime/integration/python/unused_addon_python/test_case.py index 61e1fa5815..00bd87c4b6 100644 --- a/tests/ten_runtime/integration/python/unused_addon_python/test_case.py +++ b/tests/ten_runtime/integration/python/unused_addon_python/test_case.py @@ -6,7 +6,7 @@ import os import sys from sys import stdout -from .common import http +from .common import http, build_config, build_pkg def http_request(): @@ -53,7 +53,28 @@ def test_unused_addon_python(): base_path, "unused_addon_python_app/lib" ) - app_root_path = os.path.join(base_path, "unused_addon_python_app") + source_pkg_name = "unused_addon_python_app" + app_root_path = os.path.join(base_path, source_pkg_name) + app_language = "go" + + build_config_args = build_config.parse_build_config( + os.path.join(root_dir, "tgn_args.txt"), + ) + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + print('Assembling and building package "{}".'.format(source_pkg_name)) + + source_root_path = os.path.join(base_path, source_pkg_name) + rc = build_pkg.prepare_and_build_app( + build_config_args, + root_dir, + base_path, + app_root_path, + source_pkg_name, + app_language, + ) + if rc != 0: + assert False, "Failed to build package." tman_install_cmd = [ os.path.join(root_dir, "ten_manager/bin/tman"), @@ -81,7 +102,10 @@ def test_unused_addon_python(): bootstrap_process.wait() if sys.platform == "linux": - if os.path.exists(os.path.join(base_path, "use_asan_lib_marker")): + if ( + build_config_args.enable_sanitizer + and not build_config_args.is_clang + ): libasan_path = os.path.join( base_path, "unused_addon_python_app/ten_packages/system/ten_runtime/lib/libasan.so", @@ -128,3 +152,10 @@ def test_unused_addon_python(): print("The exit code of unused_addon_python: ", exit_code) assert exit_code == 0 + + if build_config_args.ten_enable_integration_tests_prebuilt is False: + source_root_path = os.path.join(base_path, source_pkg_name) + + # Testing complete. If builds are only created during the testing + # phase, we can clear the build results to save disk space. + build_pkg.cleanup(source_root_path, app_root_path) diff --git a/tests/ten_runtime/integration/tools/use_asan_lib_marker b/tests/ten_runtime/integration/tools/use_asan_lib_marker deleted file mode 100644 index e69de29bb2..0000000000