pykd
1"""Execution status event test"""
2
3import unittest
4import target
5import pykd
6import testutils
7
8class StatusChangeHandler(pykd.eventHandler):
9
10def __init__(self):
11pykd.eventHandler.__init__(self)
12self.breakCount = 0
13self.goCount = 0
14self.noDebuggee = 0
15
16def onExecutionStatusChange(self, executionStatus):
17if executionStatus == pykd.executionStatus.Break:
18self.breakCount += 1
19if executionStatus == pykd.executionStatus.Go:
20self.goCount += 1
21if executionStatus == pykd.executionStatus.NoDebuggee:
22self.noDebuggee += 1
23
24
25class EhStatusTest(unittest.TestCase):
26"""Execution status event test"""
27
28def testException(self):
29"""Start new process and track exceptions"""
30_locProcessId = pykd.startProcess( target.appPath + " -testChangeStatus" )
31with testutils.ContextCallIt( testutils.KillProcess(_locProcessId) ) as killStartedProcess :
32
33pykd.go() #skip initial break
34
35statusChangeHandler = StatusChangeHandler()
36
37self.assertRaises(pykd.WaitEventException, testutils.infGo)
38
39self.assertEqual( 2, statusChangeHandler.breakCount )
40self.assertEqual( 1, statusChangeHandler.noDebuggee )
41self.assertEqual( statusChangeHandler.breakCount + statusChangeHandler.noDebuggee , statusChangeHandler.goCount )
42