pykd/test/scripts/excepttest.py
SND\kernelnet_cp d427d8192a [0.3.x] added : excepttest.py
git-svn-id: https://pykd.svn.codeplex.com/svn@88442 9b283d60-5439-405e-af05-b73fd8c4d996
2017-11-03 14:36:27 +04:00

46 lines
1.6 KiB
Python

"""Exception event test"""
import unittest
import target
import pykd
import testutils
class ExceptionTest(unittest.TestCase):
"""Exception event test"""
def testExceptionHandler(self):
class ExceptionHandler(pykd.eventHandler):
def __init__(self):
pykd.eventHandler.__init__(self)
def onException(self, exceptInfo):
self.exceptInfo = exceptInfo
return pykd.eventResult.Break
processId = pykd.startProcess( target.appPath + " exception" )
with testutils.ContextCallIt( testutils.KillProcess(processId) ) as killStartedProcess :
exceptionHandler = ExceptionHandler()
self.assertEqual( pykd.Break, pykd.go() )
self.assertEqual( 0xC0000005, exceptionHandler.exceptInfo.exceptionCode) #0xC0000005 = Access violation
def testSecondChance(self):
class ExceptionHandler(pykd.eventHandler):
def __init__(self):
pykd.eventHandler.__init__(self)
def onException(self, exceptInfo):
self.exceptInfo = exceptInfo
return pykd.eventResult.Proceed
processId = pykd.startProcess( target.appPath + " exception" )
with testutils.ContextCallIt( testutils.KillProcess(processId) ) as killStartedProcess :
exceptionHandler = ExceptionHandler()
self.assertEqual( pykd.Break, pykd.go() )
self.assertEqual( True, exceptionHandler.exceptInfo.firstChance)
self.assertEqual( pykd.Break, pykd.go() )
self.assertEqual( False, exceptionHandler.exceptInfo.firstChance)