1818# Note that gdb comes with its own testsuite. I was unable to figure out how to
1919# run that testsuite against the spike simulator.
2020
21+ class TestLibError (Exception ):
22+ pass
23+
2124def find_file (path ):
2225 for directory in (os .getcwd (), os .path .dirname (__file__ )):
2326 fullpath = os .path .join (directory , path )
@@ -113,7 +116,7 @@ def __init__(self, target, halted=False, timeout=None, with_jtag_gdb=True,
113116 time .sleep (0.11 )
114117 if not self .port :
115118 print_log (logname )
116- raise Exception ("Didn't get spike message about bitbang "
119+ raise TestLibError ("Didn't get spike message about bitbang "
117120 "connection" )
118121
119122 # pylint: disable=too-many-branches
@@ -220,8 +223,9 @@ def __init__(self, spikes):
220223 time .sleep (0.11 )
221224 if not self .port :
222225 print_log (self .lognames [- 1 ])
223- raise Exception ("Didn't get daisy chain message about which port "
224- "it's listening on." )
226+ raise TestLibError (
227+ "Didn't get daisy chain message about which port "
228+ "it's listening on." )
225229
226230 os .environ ['REMOTE_BITBANG_HOST' ] = 'localhost'
227231 os .environ ['REMOTE_BITBANG_PORT' ] = str (self .port )
@@ -281,7 +285,7 @@ def __init__(self, sim_cmd=None, debug=False, timeout=300):
281285 os .environ ['JTAG_VPI_PORT' ] = str (self .port )
282286
283287 if (time .time () - start ) > timeout :
284- raise Exception (
288+ raise TestLibError (
285289 "Timed out waiting for VCS to listen for JTAG vpi" )
286290
287291 def __del__ (self ):
@@ -382,7 +386,7 @@ def start(self, cmd, logfile, extra_env):
382386 line = fd .readline ()
383387 if not line :
384388 if not process .poll () is None :
385- raise Exception ("OpenOCD exited early." )
389+ raise TestLibError ("OpenOCD exited early." )
386390 time .sleep (0.1 )
387391 continue
388392
@@ -398,7 +402,7 @@ def start(self, cmd, logfile, extra_env):
398402 messaged = True
399403 print ("Waiting for OpenOCD to start..." )
400404 if (time .time () - start ) > self .timeout :
401- raise Exception ("Timed out waiting for OpenOCD to "
405+ raise TestLibError ("Timed out waiting for OpenOCD to "
402406 "listen for gdb" )
403407
404408 if self .debug_openocd :
@@ -533,7 +537,7 @@ def tokenize(text):
533537 yield token
534538 break
535539 else :
536- raise Exception (repr (text [index :]))
540+ raise TestLibError (repr (text [index :]))
537541
538542def parse_dict (tokens ):
539543 assert tokens [0 ] == "{"
@@ -579,13 +583,13 @@ def parse_tokens(tokens):
579583 return parse_dict_or_list (tokens )
580584 if isinstance (tokens [0 ], str ):
581585 return tokens .pop (0 )
582- raise Exception (f"Unsupported tokens: { tokens !r} " )
586+ raise TestLibError (f"Unsupported tokens: { tokens !r} " )
583587
584588def parse_rhs (text ):
585589 tokens = list (tokenize (text ))
586590 result = parse_tokens (tokens )
587591 if tokens :
588- raise Exception (f"Unexpected input: { tokens !r} " )
592+ raise TestLibError (f"Unexpected input: { tokens !r} " )
589593 return result
590594
591595class Gdb :
0 commit comments