mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[test] scripts cleanup and improvement.
git-svn-id: https://pykd.svn.codeplex.com/svn@68996 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
a1f689530c
commit
089684dca7
@ -1,8 +1,15 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
|
||||
# Dynamically append current pykd.pyd path to PYTHONPATH
|
||||
sys.path.append(os.path.dirname(sys.argv[1]))
|
||||
import pykd
|
||||
|
||||
import target
|
||||
import basetest
|
||||
import typeinfo
|
||||
@ -13,57 +20,16 @@ if __name__ == "__main__":
|
||||
targetAppPath = sys.argv[1]
|
||||
|
||||
target.moduleName = os.path.splitext(os.path.basename(targetAppPath))[0]
|
||||
|
||||
print "\nTest module: %s" % targetAppPath
|
||||
|
||||
pykd.startProcess( targetAppPath )
|
||||
pykd.go()
|
||||
|
||||
target.module = pykd.loadModule( target.moduleName )
|
||||
|
||||
suite = unittest.TestSuite( [
|
||||
# unittest.TestLoader().loadTestsFromTestCase( basetest.BaseTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( basetest.BaseTest ),
|
||||
unittest.TestLoader().loadTestsFromTestCase( typeinfo.TypeInfoTest ),
|
||||
] )
|
||||
|
||||
unittest.TextTestRunner().run( suite )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Append current pykd.pyd path to PYTHONPATH
|
||||
#sys.path.append(os.path.dirname(sys.argv[1]))
|
||||
#import pykd
|
||||
|
||||
#class TestPykd(unittest.TestCase):
|
||||
|
||||
# def setUp(self):
|
||||
# self.targetAppPath = sys.argv[1]
|
||||
# self.targetModuleName = os.path.splitext(os.path.basename(self.targetAppPath))[0]
|
||||
# self.targetModule = None
|
||||
# self.gVerInfoOffset = 0L
|
||||
# self.verInfo = None
|
||||
|
||||
# def testPykd(self):
|
||||
# print self.targetAppPath
|
||||
|
||||
# self.assertTrue(pykd.startProcess(self.targetAppPath))
|
||||
|
||||
# self.targetModule = pykd.loadModule(self.targetModuleName)
|
||||
# self.assertNotEqual(self.targetModule, None)
|
||||
# pykd.go()
|
||||
|
||||
# self.gVerInfoOffset = pykd.getOffset(self.targetModuleName, "gVerInfo")
|
||||
# self.assertNotEqual(self.gVerInfoOffset, 0L)
|
||||
|
||||
# self.verInfo = pykd.typedVar(self.targetModuleName, "_OSVERSIONINFOA", self.gVerInfoOffset)
|
||||
# self.assertNotEqual(self.verInfo, None)
|
||||
# pykd.go()
|
||||
|
||||
|
||||
#if __name__ == '__main__':
|
||||
#unittest.main(argv=[])
|
||||
# suite = unittest.TestLoader().loadTestsFromTestCase(TestPykd)
|
||||
# unittest.TextTestRunner().run(suite)
|
||||
|
@ -10,14 +10,14 @@ import target
|
||||
class TypeInfoTest( unittest.TestCase ):
|
||||
|
||||
def testBasicTypes(self):
|
||||
|
||||
print "Testing basic types"
|
||||
self.assertEqual( pykd.char_t.name(), "char" )
|
||||
self.assertEqual( pykd.char_t.size(), 1 )
|
||||
self.assertEqual( pykd.uchar_t.name(), "unsigned char" )
|
||||
self.assertEqual( pykd.uchar_t.size(), 1 )
|
||||
|
||||
def testSimpleStruct(self):
|
||||
|
||||
print "Testing simple struct"
|
||||
ti = pykd.typeInfo( target.moduleName, "Type1" )
|
||||
self.assertEqual( hasattr( ti, "field1" ), True )
|
||||
self.assertEqual( hasattr( ti, "field2" ), True )
|
||||
@ -29,6 +29,7 @@ class TypeInfoTest( unittest.TestCase ):
|
||||
# self.assertLess( tv.field3 - 1.0095, 0.0001 )
|
||||
|
||||
def testEnumField(self):
|
||||
print "Testing enum field"
|
||||
ti = pykd.typeInfo( target.moduleName, "Type2" )
|
||||
self.assertEqual( hasattr( ti, "field1" ), True )
|
||||
|
||||
@ -36,6 +37,7 @@ class TypeInfoTest( unittest.TestCase ):
|
||||
self.assertEqual( tv.field1, 100 )
|
||||
|
||||
def testNamespace(self):
|
||||
print "Testing namespace"
|
||||
ti1 = pykd.typeInfo( target.moduleName, "Namespace1::Class1" )
|
||||
ti2 = pykd.typeInfo( target.moduleName, "Namespace1::Namespace2::Class2" )
|
||||
var3 = pykd.typedVar( ti1, pykd.getOffset( target.moduleName, "Namespace1::var3" ) )
|
||||
|
@ -6,21 +6,12 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
OSVERSIONINFOA gVerInfo = {0};
|
||||
|
||||
void test_getOffset_typedVar()
|
||||
{
|
||||
gVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
||||
if (!::GetVersionExA(&gVerInfo))
|
||||
throw std::runtime_error("Can't get OS version: " + utils::GetLastErrorStr());
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
test_getOffset_typedVar();
|
||||
// Let test scripts to execute
|
||||
__debugbreak();
|
||||
}
|
||||
catch(std::exception & ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user