Skip to content

Commit 20d7352

Browse files
committed
release mode
1 parent a20bdd9 commit 20d7352

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

tools/crash_test.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import subprocess
77
import sys
88
import traceback
9+
import zipfile
910

1011
class CrashTest:
1112
def __init__(self, name):
@@ -50,10 +51,11 @@ def __init__(self, module, engine, tprefix, fault):
5051
os.makedirs(self.dir)
5152

5253
def Do(self):
54+
vmtype = "0" if SYMBOL_ZIPS else "1"
5355
print("Running daemon...")
5456
p = subprocess.run([self.engine,
55-
"-set", "vm.sgame.type", "1",
56-
"-set", "vm.cgame.type", "1",
57+
"-set", "vm.sgame.type", vmtype,
58+
"-set", "vm.cgame.type", vmtype,
5759
"-set", "sv_fps", "1000",
5860
"-set", "common.framerate.max", "0",
5961
"-set", "client.errorPopup", "0",
@@ -123,13 +125,14 @@ def Do(self):
123125
tprefix = ""
124126
eng = module
125127
engine = ModulePath(eng)
126-
target = ModulePath(module)
127-
128-
assert os.path.isfile(target), target
129128
assert os.path.isfile(engine), engine
130-
print(f"Symbolizing '{target}'...")
131-
subprocess.check_call(Virtualize([os.path.join(BREAKPAD_DIR, "symbolize.py"),
132-
"--symbol-directory", SYMBOL_DIR, target]))
129+
130+
if not SYMBOL_ZIPS:
131+
target = ModulePath(module)
132+
assert os.path.isfile(target), target
133+
print(f"Symbolizing '{target}'...")
134+
subprocess.check_call(Virtualize([os.path.join(BREAKPAD_DIR, "symbolize.py"),
135+
"--symbol-directory", SYMBOL_DIR, target]))
133136

134137
self.Verify(BreakpadCrashTest(module, engine, tprefix, "segfault").Go())
135138
if tprefix or not EXE:
@@ -144,8 +147,9 @@ def ArgParser(usage=None):
144147
ap.add_argument("--breakpad-dir", type=str, default=BREAKPAD_DIR, help=r"Path to Breakpad repo containing built dump_syms and stackwalk binaries. It may be a \\wsl.localhost\ path on Windows hosts in order to symbolize NaCl.")
145148
ap.add_argument("--give-up", action="store_true", help="Stop after first test failure")
146149
ap.add_argument("--nacl-arch", type=str, choices=["amd64", "i686", "armhf"], default="amd64") # TODO auto-detect?
147-
ap.add_argument("module", nargs="*", choices=[
148-
"dummyapp", "server", "ttyclient", "client",
150+
ap.add_argument("module", nargs="*",
151+
default="server", # bogus default needed due to buggy argparse
152+
choices=["dummyapp", "server", "ttyclient", "client",
149153
"cgame", "ttyclient:cgame", "client:cgame",
150154
"sgame", "server:sgame", "ttyclient:sgame", "client:sgame"])
151155
return ap
@@ -165,15 +169,27 @@ def ArgParser(usage=None):
165169
EXE = ""
166170

167171
ap = ArgParser(usage=ArgParser().format_usage().rstrip().removeprefix("usage: ")
168-
+ " [--daemon-args ARGS...]")
172+
+ " [--daemon-args ARGS...]")
169173
ap.add_argument("--daemon-args", nargs=argparse.REMAINDER, default=[],
170174
help="Extra arguments for Daemon (e.g. -pakpath)")
171175
pa = ap.parse_args(sys.argv[1:])
172176
BREAKPAD_DIR = pa.breakpad_dir
173177
GIVE_UP = pa.give_up
174178
DAEMON_USER_ARGS = pa.daemon_args
175179
NACL_ARCH = pa.nacl_arch
176-
modules = pa.module or ["server", "ttyclient", "sgame", "cgame"]
180+
SYMBOL_ZIPS = [p for p in os.listdir(GAME_BUILD_DIR) if p.startswith("symbols") and p.endswith(".zip")]
181+
modules = pa.module
182+
if isinstance(modules, str):
183+
modules = ["server", "ttyclient", "sgame", "cgame"]
184+
185+
if SYMBOL_ZIPS:
186+
print("Symbol zip(s) detected. Using release validation mode with pre-built symbols")
187+
for z in SYMBOL_ZIPS:
188+
with zipfile.ZipFile(z, 'r') as z:
189+
z.extractall(SYMBOL_DIR)
190+
else:
191+
print("No symbol zip detected. Using end2end Breakpad tooling test mode with dump_syms")
192+
177193
passed = True
178194
for module in modules:
179195
passed &= ModuleCrashTests(*module.split(":")[::-1]).Go()

0 commit comments

Comments
 (0)