mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 19:53:22 +08:00
[0.2.x] + onSymbolsLoaded/onSymbolsUnloaded test
git-svn-id: https://pykd.svn.codeplex.com/svn@83133 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
aaaa72913e
commit
2ae5ead1ad
48
test/scripts/ehsymbolstest.py
Normal file
48
test/scripts/ehsymbolstest.py
Normal file
@ -0,0 +1,48 @@
|
||||
"""Execution symbols state event test"""
|
||||
|
||||
import unittest
|
||||
import target
|
||||
import pykd
|
||||
import testutils
|
||||
|
||||
class SymbolsStateHandler(pykd.eventHandler):
|
||||
def __init__(self, modBase):
|
||||
pykd.eventHandler.__init__(self)
|
||||
self._modBase = modBase
|
||||
self.modNames = set()
|
||||
self.unloadModuleTrigged = False
|
||||
self.unloadAllModulesTrigged = False
|
||||
|
||||
def onSymbolsLoaded(self, modBase):
|
||||
if modBase:
|
||||
self.modNames.add( pykd.module(modBase).name() )
|
||||
|
||||
def onSymbolsUnloaded(self, modBase):
|
||||
if not modBase:
|
||||
self.unloadAllModulesTrigged = True
|
||||
elif self._modBase == modBase:
|
||||
self.unloadModuleTrigged = True
|
||||
|
||||
class EhSymbolsTest(unittest.TestCase):
|
||||
"""Execution symbols state event test"""
|
||||
|
||||
def testChangeSymbolsState(self):
|
||||
"""Start new process and track change symbols exception"""
|
||||
_locProcessId = pykd.startProcess( target.appPath + " -testLoadUnload" )
|
||||
with testutils.ContextCallIt( testutils.KillProcess(_locProcessId) ) as killStartedProcess:
|
||||
|
||||
mod = pykd.module("targetapp")
|
||||
symbolsStateHandler = SymbolsStateHandler( mod.begin() )
|
||||
|
||||
pykd.dbgCommand(".reload /u targetapp.exe")
|
||||
self.assertTrue( symbolsStateHandler.unloadModuleTrigged )
|
||||
|
||||
pykd.dbgCommand(".reload /u")
|
||||
self.assertTrue( symbolsStateHandler.unloadAllModulesTrigged )
|
||||
|
||||
try:
|
||||
while True:
|
||||
pykd.go()
|
||||
except pykd.BaseException:
|
||||
pass
|
||||
self.assertTrue( "iphlpapi" in symbolsStateHandler.modNames )
|
@ -23,6 +23,7 @@ import localstest
|
||||
import customtypestest
|
||||
import ehexcepttest
|
||||
import ehstatustest
|
||||
import ehsymbolstest
|
||||
|
||||
class StartProcessWithoutParamsTest(unittest.TestCase):
|
||||
def testStart(self):
|
||||
@ -55,6 +56,7 @@ def getTestSuite( singleName = "" ):
|
||||
unittest.TestLoader().loadTestsFromTestCase( localstest.LocalVarsTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( ehexcepttest.EhExceptionTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( ehstatustest.EhStatusTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( ehsymbolstest.EhSymbolsTest ),
|
||||
] )
|
||||
else:
|
||||
return unittest.TestSuite(
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Version="9.00"
|
||||
Name="targetapp"
|
||||
ProjectGUID="{C6254E16-AB8E-41EE-887D-31458E93FC68}"
|
||||
RootNamespace="targetapp"
|
||||
@ -585,6 +585,10 @@
|
||||
RelativePath="..\scripts\ehstatustest.py"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\scripts\ehsymbolstest.py"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\scripts\eventtest.py"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user