Flag unknown Manticore state terminations as crashes

This is an over-approximation, which we will tighten later.
This commit is contained in:
Joe Ranweiler 2018-02-14 17:21:17 -08:00
parent c1b91432fd
commit 4814e8184b
No known key found for this signature in database
GPG Key ID: E0B6458CB03D167E

View File

@ -130,6 +130,10 @@ class DeepManticore(DeepState):
super(DeepManticore, self).pass_test()
raise TerminateState(OUR_TERMINATION_REASON, testcase=False)
def crash_test(self):
super(DeepManticore, self).crash_test()
raise TerminateState(OUR_TERMINATION_REASON, testcase=False)
def fail_test(self):
super(DeepManticore, self).fail_test()
raise TerminateState(OUR_TERMINATION_REASON, testcase=False)
@ -184,6 +188,9 @@ def hook_Pass(state):
"""Implements DeepState_Pass, which notifies us of a passing test."""
DeepManticore(state).api_pass()
def hook_Crash(state):
"""Implements DeepState_Crash, which notifies us of a crashing test."""
DeepManticore(state).api_crash()
def hook_Fail(state):
"""Implements DeepState_Fail, which notifies us of a failing test."""
@ -238,11 +245,13 @@ def hook(func):
def done_test(_, state, state_id, reason):
"""Called when a state is terminated."""
if OUR_TERMINATION_REASON not in reason:
L.error("State {} terminated for unknown reason: {}".format(
state_id, reason))
return
mc = DeepManticore(state)
if OUR_TERMINATION_REASON not in reason:
L.info("State {} terminated for unknown reason, treating as crash: {}".format(
state_id, reason))
super(DeepManticore, mc).crash_test()
mc.report()
@ -280,6 +289,7 @@ def do_run_test(state, apis, test):
m.add_hook(apis['MaxUInt'], hook(hook_MaxUInt))
m.add_hook(apis['Assume'], hook(hook_Assume))
m.add_hook(apis['Pass'], hook(hook_Pass))
m.add_hook(apis['Crash'], hook(hook_Crash))
m.add_hook(apis['Fail'], hook(hook_Fail))
m.add_hook(apis['SoftFail'], hook(hook_SoftFail))
m.add_hook(apis['Abandon'], hook(hook_Abandon))