2121os .makedirs (SYMBOL_DIR , exist_ok = True )
2222HOMEPATH = os .path .join (TEMP_DIR , "homepath" )
2323
24- dummy = False
25- if dummy :
26- GAMELOGIC_NACL = os .path .join (GAME_BUILD_DIR , f"cgame-{ ARCH } .nexe" )
27- else :
28- GAMELOGIC_NACL = os .path .join (GAME_BUILD_DIR , f"sgame-{ ARCH } .nexe" )
2924
3025
31- assert os .path .isfile (GAMELOGIC_NACL ), GAMELOGIC_NACL
3226assert os .path .isfile (DAEMON_SERVER )
3327assert os .path .isfile (STACKWALK )
3428
35- print (f"Symbolizing '{ GAMELOGIC_NACL } '..." )
36- subprocess .check_call ([sys .executable , SYMBOLIZE , "--symbol-directory" , SYMBOL_DIR , GAMELOGIC_NACL ])
3729
3830class CrashTest :
3931 def __init__ (self , name ):
@@ -42,8 +34,6 @@ def __init__(self, name):
4234 def Begin (self ):
4335 self .status = "PASSED"
4436 print (f"===RUNNING: { self .name } ===" )
45- self .tmpdir = os .path .join (TEMP_DIR , self .name )
46- os .makedirs (self .tmpdir , exist_ok = True )
4737
4838 def End (self ):
4939 print (f"==={ self .status } : { self .name } ===" )
@@ -64,37 +54,43 @@ def Go(self):
6454 return self .status == "PASSED"
6555
6656class NaclCrashTest (CrashTest ):
67- def __init__ (self , fault ):
57+ def __init__ (self , engine , tprefix , fault ):
6858 super ().__init__ (f"nacl.{ fault } " )
59+ self .engine = engine
60+ self .tprefix = tprefix
6961 self .fault = fault
7062
7163 def Do (self ):
7264 print ("Running daemon..." )
73- p = subprocess .run ([DAEMON_SERVER , "-set" , "vm.sgame.type" , "1" ,
65+ p = subprocess .run ([self .engine , "-set" , "vm.sgame.type" , "1" ,
66+ "-set" , "vm.cgame.type" , "1" ,
7467 #"-set", "logs.level.fs", "warning",
7568 "-set" , "sv_fps" , "1000" ,
69+ "-set" , "common.framerate.max" , "0" ,
7670 #"-set", "server.private", "2",
7771 #"-set", "sv_networkScope", "0",
7872 "-set" , "net_enabled" , "0" ,
7973 "-set" , "common.framerate.max" , "0" ,
74+ "-pakpath" , "/unv/Unvanquished/pkg" ,
8075 #"-homepath", HOMEPATH,
8176 #"-pakpath", os.path.join(DAEMON_DIR, "pkg"),
8277 #"-set", "fs_basepak", "testdata",
8378 "+devmap plat23" ,
8479 "+delay 20f echo CRASHTEST_BEGIN" ,
85- "+delay 20f sgame. injectFault" , self .fault ,
80+ f "+delay 20f { self . tprefix } injectFault" , self .fault ,
8681 "+delay 20f echo CRASHTEST_END" ,
8782 "+delay 40f quit" ],
88- stderr = subprocess .PIPE )
83+ stderr = subprocess .PIPE , check = False )
8984 log = [s .strip () for s in p .stderr .decode ("utf8" ).splitlines ()]
9085 i = log .index ("CRASHTEST_BEGIN" )
91- j = log .index ("CRASHTEST_END" )
86+ #j = log.index("CRASHTEST_END")
87+ j = len (log ) - 1
9288 # TODO expected vs. actual Warn's
9389 DUMP_PREFIX = "Wrote crash dump to "
9490 dumps = [l for l in log if l .startswith (DUMP_PREFIX )]
9591 assert len (dumps ) == 1 , "Daemon log contains 1 crash dump"
9692 dump = dumps [0 ][len (DUMP_PREFIX ):]
97- sw_out = os .path .join (self .tmpdir , " stackwalk.log" )
93+ sw_out = os .path .join (TEMP_DIR , self .tprefix + self . fault + ". stackwalk.log" )
9894 with open (sw_out , "a+" ) as sw_f :
9995 print (f"Extracting stack trace to '{ sw_out } '..." )
10096 sw_f .truncate ()
@@ -104,10 +100,33 @@ def Do(self):
104100 TRACE_FUNC = "InjectFaultCmd::Run"
105101 self .Verify (TRACE_FUNC in sw , "function names not found in trace (did you build with symbols?)" )
106102
107- passed = (True
108- & NaclCrashTest ("exception" ).Go ()
109- & NaclCrashTest ("throw" ).Go ()
110- & NaclCrashTest ("abort" ).Go ()
111- & NaclCrashTest ("segfault" ).Go ())
103+ def DoModule (module ):
104+ try :
105+ engine = DAEMON_TTYCLIENT
106+ if module == "sgame" :
107+ target = os .path .join (GAME_BUILD_DIR , f"sgame-{ ARCH } .nexe" )
108+ tprefix = "sgame."
109+ elif module == "cgame" :
110+ target = os .path .join (GAME_BUILD_DIR , f"cgame-{ ARCH } .nexe" )
111+ tprefix = "cgame."
112+ elif module == "server" :
113+ tprefix = ""
114+ engine = target = DAEMON_SERVER
115+
116+ assert os .path .isfile (target ), target
117+ print (f"Symbolizing '{ target } '..." )
118+ subprocess .check_call ([sys .executable , SYMBOLIZE , "--symbol-directory" , SYMBOL_DIR , target ])
119+
120+ return (True
121+ & NaclCrashTest (DAEMON_TTYCLIENT , tprefix , "exception" ).Go ()
122+ & NaclCrashTest (DAEMON_TTYCLIENT , tprefix , "throw" ).Go ()
123+ & NaclCrashTest (DAEMON_TTYCLIENT , tprefix , "abort" ).Go ()
124+ & NaclCrashTest (DAEMON_TTYCLIENT , tprefix , "segfault" ).Go ())
125+ except Exception :
126+ raise
127+ return False
128+
129+ #passed = DoModule("sgame") & DoModule("cgame")
130+ passed = DoModule ("server" )
112131sys .exit (1 - passed )
113132
0 commit comments