Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable ten_runtime pytest on windows #376

Merged
merged 47 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f624c47
chore: enable ten_runtime integration test on mar arm64
halajohn Dec 7, 2024
8a066c5
fix: refine codes
halajohn Dec 7, 2024
4597ea6
fix: refine codes
halajohn Dec 7, 2024
5665c66
fix: refine codes
halajohn Dec 7, 2024
fe1e2a0
fix: refine codes
halajohn Dec 7, 2024
3ff4c90
feat: enable ten_runtime pytest on windows
halajohn Dec 7, 2024
bfa1cfc
fix: refine codes
halajohn Dec 7, 2024
f5269ba
fix: refine codes
halajohn Dec 7, 2024
e3e9b58
fix: refine codes
halajohn Dec 7, 2024
82918c3
fix: refine codes
halajohn Dec 7, 2024
5a096ea
fix: refine codes
halajohn Dec 7, 2024
02f539b
fix: refine codes
halajohn Dec 7, 2024
65d8e82
fix: refine codes
halajohn Dec 7, 2024
d4f17bc
fix: refine codes
halajohn Dec 7, 2024
8ed0914
fix: refine codes
halajohn Dec 7, 2024
24031b9
fix: refine codes
halajohn Dec 8, 2024
6419d4d
fix: refine codes
halajohn Dec 8, 2024
67a53af
fix: refine codes
halajohn Dec 8, 2024
b646439
fix: refine codes
halajohn Dec 8, 2024
834f456
fix: refine codes
halajohn Dec 8, 2024
4668f1f
fix: refine codes
halajohn Dec 8, 2024
167f7f4
fix: refine codes
halajohn Dec 8, 2024
03fd678
fix: refine codes
halajohn Dec 8, 2024
d038ad1
fix: refine codes
halajohn Dec 8, 2024
7854e36
fix: refine codes
halajohn Dec 8, 2024
8f7428d
fix: refine codes
halajohn Dec 8, 2024
38985a3
fix: refine codes
halajohn Dec 8, 2024
79e4e14
fix: refine codes
halajohn Dec 8, 2024
a3b19f4
fix: refine codes
halajohn Dec 8, 2024
b85149d
fix: refine codes
halajohn Dec 8, 2024
d62f077
fix: refine codes
halajohn Dec 8, 2024
9cf40da
fix: refine codes
halajohn Dec 8, 2024
685c608
fix: refine codes
halajohn Dec 8, 2024
c53d2f2
fix: refine codes
halajohn Dec 8, 2024
8cdad07
fix: refine codes
halajohn Dec 8, 2024
4a792ed
fix: refine codes
halajohn Dec 8, 2024
8fa4e5a
fix: refine codes
halajohn Dec 8, 2024
7a18a5b
fix: refine codes
halajohn Dec 8, 2024
0e6f4f5
fix: refine codes
halajohn Dec 8, 2024
5084be5
fix: refine codes
halajohn Dec 8, 2024
f441dc3
fix: refine codes
halajohn Dec 8, 2024
e975332
fix: refine codes
halajohn Dec 8, 2024
f509898
fix: refine codes
halajohn Dec 8, 2024
c07327b
fix: refine codes
halajohn Dec 8, 2024
3970567
fix: refine codes
halajohn Dec 8, 2024
d5147d0
fix: refine codes
halajohn Dec 8, 2024
1e3d9fd
fix: refine codes
halajohn Dec 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ def run_cmd_with_retry(cmd: list[str], cnt: int = 10):
return rc, output
else:
time.sleep(1)
assert 0
assert False
return []
88 changes: 44 additions & 44 deletions .github/workflows/build_linux_ubuntu1804.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,50 +56,50 @@ jobs:
tgn build linux x64 ${{ matrix.build_type }}
tree -I 'gen|obj' out

# - name: Run Tests (ten_utils_unit_test)
# 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: |
# chmod +x out/linux/x64/tests/standalone/ten_utils_unit_test
# out/linux/x64/tests/standalone/ten_utils_unit_test || { echo "test failed"; exit 1; }

# - name: Run Tests (ten_runtime_unit_test)
# 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: |
# chmod +x out/linux/x64/tests/standalone/ten_runtime_unit_test
# out/linux/x64/tests/standalone/ten_runtime_unit_test || { echo "test failed"; exit 1; }

# - name: Run Tests (ten_runtime_smoke_test)
# 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: |
# chmod +x out/linux/x64/tests/standalone/ten_runtime_smoke_test
# out/linux/x64/tests/standalone/ten_runtime_smoke_test || { echo "test failed"; exit 1; }

# - name: Run Tests (ten_rust standalone 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: |
# cd out/linux/x64/tests/standalone/ten_rust

# chmod +x unit_test
# chmod +x integration_test

# ./unit_test || { echo "ten_rust unit test failed"; exit 1; }
# ./integration_test || { echo "ten_rust integration test failed"; exit 1; }
- name: Run Tests (ten_utils_unit_test)
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: |
chmod +x out/linux/x64/tests/standalone/ten_utils_unit_test
out/linux/x64/tests/standalone/ten_utils_unit_test || { echo "test failed"; exit 1; }

- name: Run Tests (ten_runtime_unit_test)
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: |
chmod +x out/linux/x64/tests/standalone/ten_runtime_unit_test
out/linux/x64/tests/standalone/ten_runtime_unit_test || { echo "test failed"; exit 1; }

- name: Run Tests (ten_runtime_smoke_test)
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: |
chmod +x out/linux/x64/tests/standalone/ten_runtime_smoke_test
out/linux/x64/tests/standalone/ten_runtime_smoke_test || { echo "test failed"; exit 1; }

- name: Run Tests (ten_rust standalone 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: |
cd out/linux/x64/tests/standalone/ten_rust

chmod +x unit_test
chmod +x integration_test

./unit_test || { echo "ten_rust unit test failed"; exit 1; }
./integration_test || { echo "ten_rust integration test failed"; exit 1; }

- name: Install jq
if: startsWith(github.ref, 'refs/tags/')
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_linux_ubuntu2204.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,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_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 ten_enable_go_lint=true
tgn build linux x64 ${{ matrix.build_type }}
tree -I 'gen|obj' out

Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:
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; }
pytest -s tests/ten_runtime/integration/

- name: Update supports before upload or publish
run: |
Expand Down
23 changes: 22 additions & 1 deletion .github/workflows/build_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,24 @@ jobs:
cd out/mac/arm64/
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: |
if [ ${{ matrix.build_type }} == "debug" ]; then
export PATH="/opt/homebrew/opt/llvm@18/bin:$PATH"
fi
export PATH=$(pwd)/core/ten_gn:$PATH
cd out/mac/arm64/
pytest -s tests/ten_runtime/integration/
# continue-on-error: true

# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

build-mac-x64:
concurrency:
group: build-mac-x64-${{ github.head_ref }}-${{ matrix.build_type }}
Expand Down Expand Up @@ -308,9 +326,12 @@ jobs:
TEN_ENABLE_MEMORY_TRACKING: "true"
TEN_ENABLE_BACKTRACE_DUMP: "true"
run: |
if [ ${{ matrix.build_type }} == "debug" ]; then
export PATH="/usr/local/opt/llvm@18/bin:$PATH"
fi
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; }
pytest -s tests/ten_runtime/integration/

# Building ten_runtime without the ten_rust library (i.e., ten_enable_ten_rust_apis=false).
build-mac-arm64-without-ten-rust:
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/build_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ jobs:
out/win/x64/tests/standalone/ten_runtime_smoke_test

- name: Run Tests (ten_rust standalone tests)
env:
TEN_ENABLE_MEMORY_TRACKING: "true"
TEN_ENABLE_BACKTRACE_DUMP: "true"
run: |
cd out/win/x64/tests/standalone/ten_rust

Expand All @@ -87,9 +84,6 @@ jobs:
./integration_test || { echo "ten_rust integration test failed"; exit 1; }

- name: Run Tests (ten_manager standalone tests)
env:
TEN_ENABLE_MEMORY_TRACKING: "true"
TEN_ENABLE_BACKTRACE_DUMP: "true"
run: |
cd out/win/x64/tests/standalone/ten_manager

Expand All @@ -107,9 +101,18 @@ jobs:
python .github/tools/setup_pytest_dependencies.py

- name: Run Tests (ten_manager pytest tests)
run: |
cd out/win/x64/
pytest -s tests/ten_manager/

- name: Run Tests (ten_runtime pytest tests)
env:
TEN_ENABLE_MEMORY_TRACKING: "true"
TEN_ENABLE_BACKTRACE_DUMP: "true"
run: |
$ENV:PATH += ";$PWD/core/ten_gn"
cd out/win/x64/
pytest -s tests/ten_manager/
pytest -s tests/ten_runtime/integration/
# continue-on-error: true

# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/linux/x64/ten_manager/bin/tman",
"cwd": "${workspaceFolder}/out/linux/x64/app/ffmpeg",
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_manager/install/template_mode_with_same_name_extension/mock_app",
"args": [
"install",
"extension",
Expand Down
2 changes: 1 addition & 1 deletion build/common/scripts/copy_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def main(src_files: list[str], dst_files: list[str]):
shutil.copytree(
src_file,
dst_file,
False,
symlinks=True,
ignore=shutil.ignore_patterns("**/tsconfig.tsbuildinfo"),
)
else:
Expand Down
11 changes: 10 additions & 1 deletion build/common/scripts/delete_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@
#
import sys
import os
import stat
import shutil


def remove_readonly(func, path, excinfo):
if not os.access(path, os.W_OK):
os.chmod(path, stat.S_IWUSR)
func(path)
else:
raise


def delete_files(files: list[str]):
for file in files:
if not os.path.exists(file):
Expand All @@ -17,7 +26,7 @@ def delete_files(files: list[str]):
if os.path.isfile(file):
os.remove(file)
else:
shutil.rmtree(file)
shutil.rmtree(file, onerror=remove_readonly)


if __name__ == "__main__":
Expand Down
49 changes: 31 additions & 18 deletions build/ten_runtime/feature/build_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import os
import sys
import platform
from datetime import datetime
from build.scripts import fs_utils, cmd_exec, timestamp_proxy

Expand All @@ -22,7 +23,6 @@ def __init__(self):
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
Expand Down Expand Up @@ -50,16 +50,17 @@ def construct_extra_args_for_cpp_ag(args: ArgumentInfo) -> list[str]:

def build_cpp_app(args: ArgumentInfo) -> int:
# tgn gen ...
cmd = [f"{args.tgn_path}", "gen", args.os, args.cpu, args.build]
cmd = ["tgn", "gen", args.os, args.cpu, args.build]
cmd += construct_extra_args_for_cpp_ag(args)

returncode, output = cmd_exec.run_cmd(cmd, args.log_level)

if returncode:
raise Exception("Failed to build c++ app")
print(f"Failed to build c++ app: {output}")
return 1

# tgn build ...
cmd = [f"{args.tgn_path}", "build", args.os, args.cpu, args.build]
cmd = ["tgn", "build", args.os, args.cpu, args.build]

t1 = datetime.now()
returncode, output = cmd_exec.run_cmd(cmd, args.log_level)
Expand All @@ -71,7 +72,8 @@ def build_cpp_app(args: ArgumentInfo) -> int:
print(f"Build c++ app({args.pkg_name}) costs {duration} seconds.")

if returncode:
raise Exception("Failed to build c++ app")
print(f"Failed to build c++ app: {output}")
return 1

# Copy the build result to the specified run folder.
fs_utils.copy(
Expand All @@ -85,25 +87,34 @@ def build_cpp_app(args: ArgumentInfo) -> int:

def build_cpp_extension(args: ArgumentInfo) -> int:
# tgn gen ...
cmd = [f"{args.tgn_path}", "gen", args.os, args.cpu, args.build]
cmd = ["tgn", "gen", args.os, args.cpu, args.build]
cmd += construct_extra_args_for_cpp_ag(args)

returncode, _ = cmd_exec.run_cmd(cmd, args.log_level)
returncode, output = cmd_exec.run_cmd(cmd, args.log_level)

if returncode:
raise Exception("Failed to build c++ extension.")
print(f"Failed to build c++ extension: {output}")
return 1

# tgn build ...
cmd = [f"{args.tgn_path}", "build", args.os, args.cpu, args.build]
cmd = ["tgn", "build", args.os, args.cpu, args.build]

returncode, _ = cmd_exec.run_cmd(cmd, args.log_level)
returncode, output = cmd_exec.run_cmd(cmd, args.log_level)

if returncode:
raise Exception("Failed to build c++ extension.")
print(f"Failed to build c++ extension: {output}")
return 1

return returncode


def is_mac_arm64() -> bool:
return (
platform.system().lower() == "darwin"
and platform.machine().lower() == "arm64"
)


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
Expand All @@ -116,7 +127,8 @@ def build_go_app(args: ArgumentInfo) -> int:
if args.log_level > 0:
cmd += ["--verbose"]

if args.enable_sanitizer:
# `-asan` is not supported by go compiler on darwin/arm64.
if args.enable_sanitizer and not is_mac_arm64():
cmd += ["-asan"]

envs = os.environ.copy()
Expand All @@ -139,8 +151,8 @@ def build_go_app(args: ArgumentInfo) -> int:
print(f"Build go app({args.pkg_name}) costs {duration} seconds.")

if returncode:
print(output)
raise Exception("Failed to build go app.")
print(f"Failed to build go app: {output}")
return 1

return returncode

Expand All @@ -162,7 +174,8 @@ def build_app(args: ArgumentInfo) -> int:
elif args.pkg_language == "python":
returncode = 0
else:
raise Exception(f"Unknown app language: {args.pkg_language}")
print(f"Unknown app language: {args.pkg_language}")
returncode = 1

return returncode

Expand All @@ -182,7 +195,7 @@ def build(args: ArgumentInfo) -> int:
if args.log_level > 0:
msg = (
f"> Start to build package({args.pkg_name})"
" in {args.pkg_src_root_dir}"
f" in {args.pkg_src_root_dir}"
)
print(msg)

Expand All @@ -200,7 +213,8 @@ def build(args: ArgumentInfo) -> int:
returncode = 0

if returncode > 0:
raise Exception(f"Failed to build {pkg_type}({args.pkg_name})")
print(f"Failed to build {pkg_type}({args.pkg_name})")
return 1

# Success to build the app, update the stamp file to represent this
# fact.
Expand Down Expand Up @@ -237,7 +251,6 @@ def build(args: ArgumentInfo) -> int:
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
Expand Down
Loading
Loading