2013-03-12 15:08:01 +08:00
|
|
|
"""Execution status event test"""
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import target
|
|
|
|
import pykd
|
|
|
|
import testutils
|
|
|
|
|
|
|
|
class StatusChangeHandler(pykd.eventHandler):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
pykd.eventHandler.__init__(self)
|
|
|
|
self.breakCount = 0
|
2013-03-12 15:32:26 +08:00
|
|
|
self.goCount = 0
|
2013-03-12 15:08:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
def onExecutionStatusChange(self, executionStatus):
|
|
|
|
if executionStatus == pykd.executionStatus.Break:
|
|
|
|
self.breakCount = self.breakCount + 1
|
2013-03-12 15:32:26 +08:00
|
|
|
if executionStatus == pykd.executionStatus.Go:
|
|
|
|
self.goCount = self.goCount + 1
|
2013-03-12 15:08:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
class EhStatusTest(unittest.TestCase):
|
|
|
|
"""Execution status event test"""
|
|
|
|
|
|
|
|
def testException(self):
|
|
|
|
"""Start new process and track exceptions"""
|
|
|
|
_locProcessId = pykd.startProcess( target.appPath + " -testChangeStatus" )
|
|
|
|
with testutils.ContextCallIt( testutils.KillProcess(_locProcessId) ) as killStartedProcess :
|
|
|
|
|
|
|
|
pykd.go() #skip initial break
|
|
|
|
|
|
|
|
statusChangeHandler = StatusChangeHandler()
|
|
|
|
|
|
|
|
pykd.go()
|
|
|
|
pykd.go()
|
|
|
|
|
|
|
|
self.assertEqual( 2, statusChangeHandler.breakCount )
|
2013-03-12 15:32:26 +08:00
|
|
|
self.assertEqual( statusChangeHandler.breakCount, statusChangeHandler.goCount )
|
2013-03-12 15:08:01 +08:00
|
|
|
|