import dis
import os.path
import re
+import shlex
import signal
import subprocess
import sys
if proc.returncode:
raise AssertionError(
- f"Command {' '.join(cmd)!r} failed "
+ f"Command {shlex.join(cmd)!r} failed "
f"with exit code {proc.returncode}: "
f"stdout={stdout!r} stderr={stderr!r}"
)
raise
if check_returncode and proc.returncode:
raise AssertionError(
- f"Command {' '.join(command)!r} failed "
+ f"Command {shlex.join(command)!r} failed "
f"with exit code {proc.returncode}: output={stdout!r}"
)
return stdout
python_flags = []
if optimize_python:
python_flags.extend(["-O"] * optimize_python)
- subcommand = " ".join([sys.executable] + python_flags + [python_file])
+ subcommand = shlex.join([sys.executable] + python_flags + [python_file])
return self.trace(script_file, subcommand, timeout=60,
check_returncode=True)
try:
proc = create_process_group(
- ["bpftrace", "-e", program, "-c", " ".join(subcommand)],
+ ["bpftrace", "-e", program, "-c", shlex.join(subcommand)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
program = f'usdt:{sys.executable}:python:function__entry {{ printf("probe: success\\n"); exit(); }}'
try:
proc = create_process_group(
- ["bpftrace", "-e", program, "-c", f"{sys.executable} -c pass"],
+ ["bpftrace", "-e", program, "-c",
+ shlex.join([sys.executable, "-c", "pass"])],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,