36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""循环编译 FuncTest 直到崩溃,捕获 ASAN 栈(崩溃约 50% 概率)"""
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
|
|
EXE = r'd:\Users\TermiNexus\Desktop\TransPyC\TransPyV\output\TransPyV.exe'
|
|
PROJ = r'd:\Users\TermiNexus\Desktop\TransPyC\Test\FuncTest\project.json'
|
|
CWD = r'd:\Users\TermiNexus\Desktop\TransPyC\Test\FuncTest'
|
|
OUT_LOG = r'd:\Users\TermiNexus\Desktop\TransPyC\_asan_crash.log'
|
|
|
|
os.environ.setdefault('ASAN_OPTIONS', 'abort_on_error=1:detect_leaks=0')
|
|
|
|
for i in range(1, 21):
|
|
print(f"[run {i}] 编译 FuncTest ...", flush=True)
|
|
try:
|
|
r = subprocess.run([EXE, '--project', PROJ, '--clean'],
|
|
cwd=CWD, capture_output=True, text=True,
|
|
encoding='utf-8', errors='replace', timeout=600)
|
|
except subprocess.TimeoutExpired:
|
|
print(f"[run {i}] 超时", flush=True)
|
|
continue
|
|
out = (r.stdout or '') + '\n' + (r.stderr or '')
|
|
tail = out.strip().splitlines()[-12:]
|
|
print(f"[run {i}] returncode={r.returncode}", flush=True)
|
|
for line in tail:
|
|
print(f" {line}", flush=True)
|
|
if r.returncode != 0:
|
|
with open(OUT_LOG, 'w', encoding='utf-8', errors='replace') as f:
|
|
f.write(out)
|
|
print(f"=== 崩溃捕获于 run {i},完整输出已存 {OUT_LOG} ===", flush=True)
|
|
sys.exit(0)
|
|
|
|
print("12 次均未崩溃", flush=True)
|
|
sys.exit(1)
|