make test: detect hung tests
[vpp.git] / test / debug.py
1 """ debug utilities """
2
3 import os
4 import pexpect
5
6 gdb_path = '/usr/bin/gdb'
7
8
9 def spawn_gdb(binary_path, core_path, logger):
10     if os.path.isfile(gdb_path) and os.access(gdb_path, os.X_OK):
11         # automatically attach gdb
12         gdb_cmdline = "%s %s %s" % (gdb_path, binary_path, core_path)
13         gdb = pexpect.spawn(gdb_cmdline)
14         gdb.interact()
15         try:
16             gdb.terminate(True)
17         except:
18             pass
19         if gdb.isalive():
20             raise Exception("GDB refused to die...")
21     else:
22         logger.error("Debugger '%s' does not exist or is not an "
23                      "executable.." % gdb_path)