Skip to content
Permalink
Browse files

[test] Fail gracefully if the regex doesn't match

This test is failing on the Fedora bot (staging). Rather than failing
with an IndexError, we should trigger an assert and dump the log when
the regex doesn't match.

llvm-svn: 372052
  • Loading branch information
JDevlieghere committed Sep 16, 2019
1 parent 0a0ea7e commit 71b32e4175d111e1d2a62bf681b5c49e92ff163a
Showing with 11 additions and 6 deletions.
  1. +11 −6 lldb/packages/Python/lldbsuite/test/api/log/TestAPILog.py
@@ -34,15 +34,20 @@ def cleanup():
with open(logfile, 'r') as f:
log = f.read()

# Find the debugger addr.
# Find the SBDebugger's address.
debugger_addr = re.findall(
r"lldb::SBDebugger::GetScriptingLanguage\(const char \*\) \(0x([0-9a-fA-F]+),",
log)[0]
log)

get_scripting_language = 'lldb::SBDebugger::GetScriptingLanguage(const char *) (0x{}, "")'.format(
debugger_addr)
create_target = 'lldb::SBDebugger::CreateTarget(const char *) (0x{}, "")'.format(
debugger_addr)
# Make sure we've found a match.
self.assertTrue(debugger_addr, log)

# Make sure the GetScriptingLanguage matches.
get_scripting_language = 'lldb::SBDebugger::GetScriptingLanguage(const char *) (0x{}, "")'.format(
debugger_addr[0])
self.assertTrue(get_scripting_language in log, log)

# Make sure the address matches.
create_target = 'lldb::SBDebugger::CreateTarget(const char *) (0x{}, "")'.format(
debugger_addr[0])
self.assertTrue(create_target in log, log)

0 comments on commit 71b32e4

Please sign in to comment.
You can’t perform that action at this time.