[0.3.x] updated: tests

git-svn-id: https://pykd.svn.codeplex.com/svn@83865 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2013-05-31 07:23:41 +00:00 committed by Mikhail I. Izmestev
parent e0fc219466
commit fd0174d87c
4 changed files with 35 additions and 24 deletions

View File

@ -59,5 +59,15 @@ inline python::list loadDoubles( kdlib::MEMOFFSET_64 offset, unsigned long count
return vectorToList( kdlib::loadDoubles( offset, count, phyAddr ) );
}
inline python::list loadPtrList( kdlib::MEMOFFSET_64 offset )
{
return vectorToList( kdlib::loadPtrList(offset) );
}
inline python::list loadPtrArray( kdlib::MEMOFFSET_64 offset, unsigned long count )
{
return vectorToList( kdlib::loadPtrs(offset, count) );
}
} // end namespace pykd

View File

@ -229,10 +229,10 @@ BOOST_PYTHON_MODULE( pykd )
// "Return string represention of windows UNICODE_STRING type" );
//python::def( "loadAnsiString", &loadAnsiStr,
// "Return string represention of windows ANSI_STRING type" );
//python::def( "loadPtrList", &loadPtrList,
// "Return list of pointers, each points to next" );
//python::def( "loadPtrs", &loadPtrArray,
// "Read the block of the target's memory and return it as a list of pointers" );
python::def( "loadPtrList", &loadPtrList,
"Return list of pointers, each points to next" );
python::def( "loadPtrs", &loadPtrArray,
"Read the block of the target's memory and return it as a list of pointers" );
python::def( "loadFloats", &loadFloats, loadFloats_( python::args( "offset", "count", "phyAddr" ),
"Read the block of the target's memory and return it as list of floats" ) );
python::def( "loadDoubles", &loadDoubles, loadDoubles_( python::args( "offset", "count", "phyAddr" ),
@ -458,8 +458,8 @@ BOOST_PYTHON_MODULE( pykd )
// "Add a new field to custom defined struct" )
.def( "ptrTo", &kdlib::TypeInfo::ptrTo,
"Return pointer to the type" )
//.def( "arrayOf", &kdlib::TypeInfo::arrayOf,
// "Return array of the type" )
.def( "arrayOf", &kdlib::TypeInfo::arrayOf,
"Return array of the type" )
.def( "__str__", &TypeInfoAdapter::print,
"Return typa as a printable string" )
.def( "__getattr__", TypeInfoAdapter::getElementByName )

View File

@ -22,14 +22,14 @@ class TypedVarTest( unittest.TestCase ):
tv = pykd.typedVar( target.moduleName + "!g_structTest" )
def testBaseTypes(self):
self.assertEqual( 1, target.module.typedVar( "ucharVar" ) )
self.assertEqual( 2, target.module.typedVar( "ushortVar" ) )
self.assertEqual( 4, target.module.typedVar( "ulongVar" ) )
self.assertEqual( 8, target.module.typedVar( "ulonglongVar" ) )
self.assertEqual( -1, target.module.typedVar( "charVar" ) )
self.assertEqual( -2, target.module.typedVar( "shortVar" ) )
self.assertEqual( -4, target.module.typedVar( "longVar" ) )
self.assertEqual( -8, target.module.typedVar( "longlongVar" ) )
self.assertEqual( 10, target.module.typedVar( "ucharVar" ) )
self.assertEqual( 1020, target.module.typedVar( "ushortVar" ) )
self.assertEqual( 10002000, target.module.typedVar( "ulongVar" ) )
self.assertEqual( 1234567890, target.module.typedVar( "ulonglongVar" ) )
self.assertEqual( -5, target.module.typedVar( "charVar" ) )
self.assertEqual( -1020, target.module.typedVar( "shortVar" ) )
self.assertEqual( -1002000, target.module.typedVar( "longVar" ) )
self.assertEqual( -1234567890, target.module.typedVar( "longlongVar" ) )
def testPtrTo(self):
tvBaseType = pykd.typedVar( pykd.typeInfo("UInt8B").ptrTo(), target.module.offset("pbigValue") )
@ -272,8 +272,8 @@ class TypedVarTest( unittest.TestCase ):
self.assertTrue( str(target.module.typedVar( "ptrIntMatrix" ) ) )
self.assertTrue( str(target.module.typedVar( "g_classChild" ) ) )
#self.assertTrue( str(target.module.typedVar( "g_struct3" ) ) )
#self.assertTrue( str(target.module.typedVar( "g_listHead" ) ) )
#self.assertTrue( str(target.module.typedVar( "g_voidPtr" ) ) )
self.assertTrue( str(target.module.typedVar( "g_listHead" ) ) )
self.assertTrue( str(target.module.typedVar( "voidPtr" ) ) )
#self.assertTrue( str(target.module.typedVar( "g_arrOfPtrToFunc" ) ) )
#self.assertTrue( str(target.module.typedVar( "g_unTypedPtrToFunction" ) ) )

View File

@ -120,13 +120,13 @@ class TypeInfoTest( unittest.TestCase ):
self.assertEqual( pykd.ptrSize(), target.module.type("structTest**").size() )
self.assertEqual( pykd.sizeof("structTest"), target.module.type("structTest").size() )
self.assertEqual( pykd.sizeof("structTest**"), target.module.type("structTest**").size() )
self.assertEqual( pykd.sizeof("Int1B"), target.module.type("Int1B").size() )
self.assertEqual( pykd.sizeof("Int1B"), pykd.typeInfo("Int1B").size() )
def testBitField( self ):
ti = target.module.type( "g_structWithBits" )
self.assertEqual( 0, ti.fieldOffset("m_bit6_8") )
self.assertEqual( 4, ti.m_bit6_8.size() )
self.assertEqual( "ULong:3", ti.m_bit6_8.name() )
self.assertEqual( "UInt4B:3", ti.m_bit6_8.name() )
self.assertEqual( 3, ti.m_bit6_8.bitWidth() )
self.assertEqual( 6, ti.m_bit6_8.bitOffset() )
@ -139,12 +139,13 @@ class TypeInfoTest( unittest.TestCase ):
self.assertEqual( "enumType", ti.m_enumField.name() )
def testPtr(self):
self.assertEqual( "listStruct1*", target.module.type( "g_listHead1" ).name() )
self.assertEqual( "listStruct1*[2]", target.module.type( "g_arrOfListStruct1" ).name())
self.assertEqual( "Void*", target.module.type( "g_voidPtr" ).name() )
self.assertEqual( "Void*[3]", target.module.type( "g_arrOfVoidPtr" ).name())
self.assertEqual( "<function>*", target.module.type( "g_ptrToFunction" ).name())
self.assertEqual( "<function>*[4]", target.module.type( "g_arrOfPtrToFunc" ).name())
self.assertEqual( "ULongLong*", target.module.type( "pbigValue" ).name() )
self.assertEqual( "testStruct*", target.module.type( "testStruct*" ).name() )
self.assertEqual( "UShort*", target.module.type( "UShort*" ).name() )
self.assertEqual( "Void*", target.module.type( "voidPtr" ).name() )
self.assertEqual( "Void*[3]", target.module.type( "voidPtrArray" ).name())
#self.assertEqual( "<function>*", target.module.type( "g_ptrToFunction" ).name())
#self.assertEqual( "<function>*[4]", target.module.type( "g_arrOfPtrToFunc" ).name())
def testUnion(self):
ti = target.module.type("unionTest")