diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index fdafe4a..9a073b6 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -96,84 +96,37 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( DebugClient_compareMemory, DebugClient:: BOOST_PYTHON_MODULE( pykd ) { python::class_( "intBase", "intBase", python::no_init ) - .def( int_( python::self ) ) - .def( "__long__", &intBase::convertLong ) - - .def( python::self + ULONG64() ) - .def( ULONG64() + python::self ) - .def( python::self += ULONG64() ) - .def( python::self + python::self ) - .def( python::self += python::self ) - - .def( python::self - ULONG64() ) - .def( ULONG64() - python::self ) - .def( python::self -= ULONG64() ) - .def( python::self - python::self ) - .def( python::self -= python::self ) - - .def( python::self * ULONG64() ) - .def( ULONG64() * python::self ) - .def( python::self *= ULONG64() ) - .def( python::self * python::self ) - .def( python::self *= python::self ) - - .def( python::self / ULONG64() ) - .def( ULONG64() / python::self ) - .def( python::self /= ULONG64() ) - .def( python::self / python::self ) - .def( python::self /= python::self ) - - .def( python::self % ULONG64() ) - .def( ULONG64() % python::self ) - .def( python::self %= ULONG64() ) - .def( python::self % python::self ) - .def( python::self %= python::self ) - - .def( python::self & ULONG64() ) - .def( ULONG64() & python::self ) - .def( python::self &= ULONG64() ) - .def( python::self & python::self ) - .def( python::self &= python::self ) - - .def( python::self | ULONG64() ) - .def( ULONG64() | python::self ) - .def( python::self |= ULONG64() ) - .def( python::self | python::self ) - .def( python::self |= python::self ) - - .def( python::self ^ ULONG64() ) - .def( ULONG64() ^ python::self ) - .def( python::self ^= ULONG64() ) - .def( python::self ^ python::self ) - .def( python::self ^= python::self ) - - .def( python::self << ULONG64() ) - .def( python::self <<= ULONG64() ) - - .def( python::self >> ULONG64() ) - .def( python::self >>= ULONG64() ) - - .def( python::self < ULONG64() ) - .def( python::self < python::self ) - - .def( python::self <= ULONG64() ) - .def( python::self <= python::self ) - - .def( python::self == ULONG64() ) - .def( python::self == boost::python::self ) - - .def( python::self >= ULONG64() ) - .def( python::self >= boost::python::self ) - - .def( python::self > ULONG64() ) - .def( python::self > boost::python::self ) - - .def( python::self != ULONG64() ) - .def( python::self != boost::python::self ) - - .def( ~boost::python::self ) - .def( !boost::python::self ) - + .def( python::init() ) + .def( "__eq__", &intBase::eq ) + .def( "__ne__", &intBase::ne) + .def( "__lt__", &intBase::lt) + .def( "__gt__", &intBase::gt ) + .def( "__le__", &intBase::le ) + .def( "__ge__", &intBase::ge ) + .def( "__add__", &intBase::add ) + .def( "__radd__", &intBase::add ) + .def( "__sub__", &intBase::sub ) + .def( "__rsub__", &intBase::rsub ) + .def( "__mul__", &intBase::mul ) + .def( "__rmul__", &intBase::mul ) + .def( "__div__", &intBase::div ) + .def( "__rdiv__", &intBase::rdiv ) + .def( "__mod__", &intBase::mod ) + .def( "__rmod__", &intBase::rmod ) + .def( "__rshift__", &intBase::rshift ) + .def( "__rrshift__", &intBase::rrshift ) + .def( "__lshift__", &intBase::lshift ) + .def( "__rlshift__", &intBase::rlshift ) + .def( "__and__", &intBase::and ) + .def( "__rand__", &intBase::and ) + .def( "__or__", &intBase::or ) + .def( "__ror__", &intBase::or ) + .def( "__xor__", &intBase::xor ) + .def( "__rxor__", &intBase::xor ) + .def( "__neg__", &intBase::neg ) + .def( "__pos__", &intBase::pos ) + .def( "__invert__", &intBase::invert ) + .def( "__nonzero__", &intBase::nonzero ) .def( "__str__", &intBase::str ) .def( "__hex__", &intBase::hex ); @@ -366,11 +319,11 @@ BOOST_PYTHON_MODULE( pykd ) "Wait for events that breaks into the debugger" ); python::class_("typeInfo", "Class representing typeInfo", python::no_init ) - .def( "name", &pykd::TypeInfo::getName ) - .def( "size", &pykd::TypeInfo::getSize ) - .def( "offset", &pykd::TypeInfo::getOffset ) - .def( "field", &pykd::TypeInfo::getField ) - .def( "__getattr__", &pykd::TypeInfo::getField ); + .def( "name", &TypeInfo::getName ) + .def( "size", &TypeInfo::getSize ) + .def( "offset", &TypeInfo::getOffset ) + .def( "field", &TypeInfo::getField ) + .def( "__getattr__", &TypeInfo::getField ); python::class_, boost::noncopyable >("typedVar", "Class of non-primitive type object, child class of typeClass. Data from target is copied into object instance", diff --git a/pykd/intbase.h b/pykd/intbase.h index 04fee50..6638036 100644 --- a/pykd/intbase.h +++ b/pykd/intbase.h @@ -2,92 +2,201 @@ namespace pykd { -class intBase : boost::integer_arithmetic +typedef boost::variant BaseTypeVariant; + +class VariantToStr : public boost::static_visitor { +public: + template + std::string operator()(T i ) const { + std::stringstream sstr; + sstr << i; + return sstr.str(); + } +}; + +class VariantToHex : public boost::static_visitor +{ +public: + template + std::string operator()(T i ) const { + std::stringstream sstr; + sstr << std::hex << i; + return sstr.str(); + } +}; + + + +class VariantToPyobj : public boost::static_visitor +{ +public: + template + python::object operator()(T i ) const { + return python::object( i ); + } +}; + + + +class intBase { public: - - operator ULONG64() const { - return getValue(); + + intBase(python::object &obj) { + m_variant = convertToVar(obj); } - - intBase& operator= ( ULONG64 val ) { - setValue( val ); - return *this; - } - - virtual ULONG64 getValue() const { - return m_intValue; - } - - virtual void setValue( ULONG64 value ) { - m_intValue = value; + + intBase() : m_variant(LONG(0)) + {} + + std::string + str() { + return boost::apply_visitor( VariantToStr(), getValue() ); } std::string - str() const { - std::stringstream ss; - ss << getValue(); - return ss.str(); + hex() { + return boost::apply_visitor( VariantToHex(), getValue() ); } - - std::string - hex() const { - std::stringstream ss; - ss << std::hex << getValue(); - return ss.str(); - } - template - bool operator!=(T const& rhs) - { return getValue() == rhs; } - - template - intBase& operator+=(T const& rhs) - { setValue( getValue() + rhs ); return *this; } - - template - intBase& operator-=(T const& rhs) - { setValue( getValue() - rhs ); return *this; } - - template - intBase& operator*=(T const& rhs) - { setValue( getValue() * rhs ); return *this; } - - template - intBase& operator/=(T const& rhs) - { setValue( getValue() / rhs ); return *this; } - - template - intBase& operator%=(T const& rhs) - { setValue( getValue() % rhs ); return *this; } - - template - intBase& operator&=(T const& rhs) - { setValue( getValue() & rhs ); return *this; } - - template - intBase& operator|=(T const& rhs) - { setValue( getValue() | rhs ); return *this; } - - template - intBase& operator^=(T const& rhs) - { setValue( getValue() ^ rhs ); return *this; } - - template - intBase& operator<<=(T const& rhs) - { setValue( getValue() << rhs ); return *this; } - - template - intBase& operator>>=(T const& rhs) - { setValue( getValue() >> rhs ); return *this; } + python::object eq( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) == obj; + } - PyObject* convertLong() { return PyLong_FromLongLong( getValue() ); } + python::object ne( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) != obj; + } + + python::object lt( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) < obj; + } + + python::object gt( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) > obj; + } + + python::object le( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) <= obj; + } + + python::object ge( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) >= obj; + } + + python::object add( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) + obj; + } + + python::object sub( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) - obj; + } + + python::object rsub( python::object& obj ) { + return obj - boost::apply_visitor( VariantToPyobj(), getValue() ); + } + + python::object mul( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) * obj; + } + + python::object div( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) / obj; + } + + python::object rdiv( python::object& obj ) { + return obj / boost::apply_visitor( VariantToPyobj(), getValue() ); + } + + python::object mod( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) % obj; + } + + python::object rmod( python::object& obj ) { + return obj % boost::apply_visitor( VariantToPyobj(), getValue() ); + } + + python::object rshift( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) >> obj; + } + + python::object rrshift( python::object& obj ) { + return obj >> boost::apply_visitor( VariantToPyobj(), getValue() ); + } + + python::object lshift( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) << obj; + } + + python::object rlshift( python::object& obj ) { + return obj << boost::apply_visitor( VariantToPyobj(), getValue() ); + } + + python::object and( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) & obj; + } + + python::object or( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) | obj; + } + + python::object xor( python::object& obj ) { + return boost::apply_visitor( VariantToPyobj(), getValue() ) ^ obj; + } + + python::object neg() { + return 0 - boost::apply_visitor( VariantToPyobj(), getValue() ); + } + + python::object pos() { + return 0 + boost::apply_visitor( VariantToPyobj(), getValue() ); + } + + python::object invert() { + return boost::apply_visitor( VariantToPyobj(), getValue() ) ^ boost::apply_visitor( VariantToPyobj(), getValue() ); + } + + python::object nonzero() { + return boost::apply_visitor( VariantToPyobj(), getValue() ) != 0; + } private: - ULONG64 m_intValue; + virtual BaseTypeVariant getValue() { + return m_variant; + } + BaseTypeVariant convertToVar( python::object &obj ) + { + + if ( PyBool_Check( obj.ptr() ) ) + { + if ( obj.ptr() == Py_True ) + return BaseTypeVariant(true); + + return BaseTypeVariant(false); + } + else if ( _PyLong_Sign( obj.ptr() ) >= 0 ) + { + if ( PyInt_CheckExact( obj.ptr() ) ) + return BaseTypeVariant( ULONG( PyLong_AsUnsignedLong( obj.ptr() ) ) ); + else + if( PyLong_CheckExact( obj.ptr() ) ) + return BaseTypeVariant( ULONG64( PyLong_AsUnsignedLongLong( obj.ptr() ) ) ); + } + else + { + if ( PyInt_CheckExact( obj.ptr() ) ) + return BaseTypeVariant( LONG( PyLong_AsLong( obj.ptr() ) ) ); + else + if( PyLong_CheckExact( obj.ptr() ) ) + return BaseTypeVariant( LONG64( PyLong_AsLongLong( obj.ptr() ) ) ); + } + + return BaseTypeVariant( false ); + } + + BaseTypeVariant m_variant; }; }; \ No newline at end of file diff --git a/pykd/stdafx.h b/pykd/stdafx.h index 09b1fcd..5ff2c5c 100644 --- a/pykd/stdafx.h +++ b/pykd/stdafx.h @@ -51,3 +51,4 @@ namespace python = boost::python; #include +#include diff --git a/pykd/typedvar.cpp b/pykd/typedvar.cpp index 50bc00b..8c9c440 100644 --- a/pykd/typedvar.cpp +++ b/pykd/typedvar.cpp @@ -51,24 +51,55 @@ TypedVar::TypedVar ( IDebugClient4 *client, const TypeInfoPtr& typeInfo, ULONG64 } /////////////////////////////////////////////////////////////////////////////////// -ULONG64 -BasicTypedVar::getValue() const +BaseTypeVariant BasicTypedVar::getValue() { + ULONG64 val = 0; HRESULT hres; - ULONG64 val = 0; hres = m_dataSpaces->ReadVirtual( m_offset, &val, getSize(), NULL ); if ( FAILED( hres ) ) throw MemoryException( m_offset, false ); - return val; + if ( m_typeInfo->getName() == "Char" ) + return (LONG)*(PCHAR)&val; + + if ( m_typeInfo->getName() == "WChar" ) + return (LONG)*(PWCHAR)&val; + + if ( m_typeInfo->getName() == "Int2B" ) + return (LONG)*(PSHORT)&val; + + if ( m_typeInfo->getName() == "UInt2B" ) + return (ULONG)*(PUSHORT)&val; + + if ( m_typeInfo->getName() == "Int4B" ) + return *(PLONG)&val; + + if ( m_typeInfo->getName() == "UInt4B" ) + return *(PULONG)&val; + + if ( m_typeInfo->getName() == "Int8B" ) + return (LONG64)*(PLONG64)&val; + + if ( m_typeInfo->getName() == "UInt8B" ) + return (ULONG64)*(PULONG64)&val; + + if ( m_typeInfo->getName() == "Long" ) + return *(PLONG)&val; + + if ( m_typeInfo->getName() == "ULong" ) + return *(PULONG)&val; + + if ( m_typeInfo->getName() == "Bool" ) + return *(bool*)&val; + + throw DbgException( "failed get value " ); } /////////////////////////////////////////////////////////////////////////////////// -ULONG64 -PtrTypedVar::getValue() const +BaseTypeVariant PtrTypedVar::getValue() { HRESULT hres; ULONG64 val = 0; diff --git a/pykd/typedvar.h b/pykd/typedvar.h index edb6405..afbbfb2 100644 --- a/pykd/typedvar.h +++ b/pykd/typedvar.h @@ -59,13 +59,9 @@ protected: TypedVar ( IDebugClient4 *client, const TypeInfoPtr& typeInfo, ULONG64 offset ); - virtual ULONG64 getValue() const { + virtual BaseTypeVariant getValue() { return m_offset; } - - virtual void setValue( ULONG64 value) { - throw DbgException("can not change"); - } TypeInfoPtr m_typeInfo; @@ -87,7 +83,7 @@ public: return intBase::str(); } - virtual ULONG64 getValue() const; + virtual BaseTypeVariant getValue(); }; @@ -108,7 +104,7 @@ public: return "PtrTypedVar"; } - virtual ULONG64 getValue() const; + virtual BaseTypeVariant getValue(); }; diff --git a/test/scripts/intbase.py b/test/scripts/intbase.py new file mode 100644 index 0000000..0a7f807 --- /dev/null +++ b/test/scripts/intbase.py @@ -0,0 +1,146 @@ + +import unittest +import target +from pykd import intBase + +class IntBaseTest( unittest.TestCase ): + + def testCtor( self ): + a = intBase(0xFF) + a = intBase(0xFFFF) + a = intBase(0xFFFFFFFF) + a = intBase(0x8000000000000000) + a = intBase(0xFFFFFFFFFFFFFFFF) + a = intBase(-20) + a = intBase(-2000) + a = intBase(-200000) + a = intBase(-20000000000) + a = intBase(-0xFFFFFFFFFFFFFFFF ) + a = intBase( True ) + + def testEq( self ): + self.assertTrue( 0xFF == intBase(0xFF) and intBase(0xFF) == 0xFF ) + self.assertTrue( 0xFFFF == intBase(0xFFFF) and 0xFFFF == intBase(0xFFFF) ) + self.assertTrue( 0xFFFFFFFF == intBase(0xFFFFFFFF) and intBase(0xFFFFFFFF) == 0xFFFFFFFF ) + self.assertTrue( 0x8000000000000000 == intBase(0x8000000000000000) ) + self.assertTrue( 0xFFFFFFFFFFFFFFFF == intBase(0xFFFFFFFFFFFFFFFF) ) + self.assertTrue( -20 == intBase(-20) ) + self.assertTrue( -2000 == intBase(-2000) ) + self.assertTrue( -20000000000 == intBase(-20000000000) ) + self.assertTrue( -0x8000000000000000 == intBase(-0x8000000000000000) ) + self.assertTrue( intBase(0x20L) == intBase(0x20) ) + self.assertTrue( True == intBase(True) ) + self.assertTrue( False == intBase(0) ) + self.assertTrue( True == intBase(1) ) + + def testNe( self ): + self.assertTrue( 0xFE != intBase(0xFF) ) + self.assertTrue( 0xFF00 != intBase(0xFFFF) ) + self.assertTrue( 0xFFFFFF88 != intBase(0xFFFFFFFF) ) + self.assertTrue( 0x8000000000000000 - 1 != intBase(0x8000000000000000) ) + self.assertTrue( 0xFFFFFFFFFFFFFFFF - 1 != intBase(0xFFFFFFFFFFFFFFFF) ) + self.assertTrue( -20 + 1 != intBase(-20) ) + self.assertTrue( -2000 + 1 != intBase(-2000) ) + self.assertTrue( -20000000000 + 1 != intBase(-20000000000) ) + self.assertTrue( -0x8000000000000000 - 1 != intBase(-0x8000000000000000) ) + + def testLtGt( self ): + self.assertTrue( 0xFE < intBase(0xFF) and intBase(0xFE) < 0xFF ) + self.assertFalse( -99 < intBase(-100) and intBase(-99) < - 100 ) + self.assertTrue( 0xFFFFFFFFFFFFFFFE < intBase(0xFFFFFFFFFFFFFFFF) ) + self.assertFalse(0xFFFFFFFFFFFFFFFF < intBase(0xFFFFFFFFFFFFFFFE) ) + self.assertTrue( intBase(0xFFFFFFFFFFFFFFFE) < 0xFFFFFFFFFFFFFFFF ) + + def testLeGe( self ): + self.assertTrue( 0xFE <= intBase(0xFF) and intBase(0xFE) <= 0xFF ) + self.assertTrue( 0xFF <= intBase(0xFF) ) + self.assertFalse( -99 <= intBase(-100) and intBase(-99) <= - 100 ) + self.assertTrue( 0xFFFFFFFFFFFFFFFE <= intBase(0xFFFFFFFFFFFFFFFF) ) + self.assertFalse(0xFFFFFFFFFFFFFFFF <= intBase(0xFFFFFFFFFFFFFFFE) ) + self.assertTrue( intBase(0xFFFFFFFFFFFFFFFF) <= 0xFFFFFFFFFFFFFFFF ) + + def testAdd( self ): + self.assertEqual( 10, intBase(5) + 5 ) + self.assertEqual( 10, 5 + intBase(5) ) + a = 10 + a += intBase(10) + self.assertEqual( 20, a ) + self.assertEqual( -20, intBase(-10) + (-10) ) + self.assertEqual( 10, intBase(-10) + 20 ) + self.assertEqual( 0x7fffffffffffffff + 1, intBase(0x7fffffffffffffff) + 1) + self.assertEqual( -0x8000000000000000 + 10, intBase(-0x8000000000000000) + 10 ) + self.assertEqual( 0, intBase(-0x8000000000000000) + 0x8000000000000000 ) + + def testSub( self ): + self.assertEqual( 0, intBase(5) - 5 ) + self.assertEqual( 10, 15 - intBase(5) ) + a = 10 + a -= intBase(5) + self.assertEqual( 5, a ) + self.assertEqual( -20, intBase(-10) -10 ) + self.assertEqual( -10, 10 - intBase(20) ) + self.assertEqual( -0xFFFFFFFF - 1, intBase(-0xFFFFFFFF) - 1 ) + + def testMul( self ): + self.assertEqual( 4, intBase(2) * 2 ) + self.assertEqual( 4, 2 * intBase(2) ) + self.assertEqual( -4, 2 * intBase(-2) ) + self.assertEqual( 4, -2 * intBase(-2) ) + self.assertEqual( 0x7fffffffffffffff * 2, intBase(0x7fffffffffffffff) * 2) + self.assertEqual( 0x80000000*2, intBase(0x80000000)*2 ) + self.assertEqual( -0x80000000*2, 2 * intBase(-0x80000000)) + + def testDiv( self ): + self.assertEqual( 1, intBase(2) / 2 ) + self.assertEqual( 2, 5 / intBase(2) ) + self.assertEqual( -1, 2 / intBase(-2) ) + self.assertEqual( 1, -2 / intBase(-2) ) + + try: + -2 / intBase(0) + self.assertTrue( False ) + except ZeroDivisionError: + self.assertTrue( True ) + + try: + intBase(2)/0 + self.assertTrue( False ) + except ZeroDivisionError: + self.assertTrue( True ) + + def testMod( self ): + self.assertEqual( 1, intBase(3) % 2 ) + self.assertEqual( 0, intBase(3) % 3 ) + self.assertEqual( 1, 3 % intBase(2) ) + self.assertEqual( 0, 3 % intBase(3) ) + + def testShift( self ): + self.assertEqual( 0xFFFFFFFF >> 8, intBase(0xFFFFFFFF) >> 8 ) + self.assertEqual( 0x00FFFFFF << 8, intBase(0x00FFFFFF) << 8 ) + self.assertEqual( 0xFFFFFFFF >> 8, 0xFFFFFFFF >> intBase(8) ) + self.assertEqual( 0x00FFFFFF << 8, 0x00FFFFFF << intBase(8) ) + + def testAnd( self ): + self.assertEqual( 0xFFFFFFFF & 0xFFFF, intBase(0xFFFFFFFF) & 0xFFFF ) + self.assertEqual( 0xFFFFFFFF & 0xFFFF, 0xFFFFFFFF & intBase(0xFFFF) ) + self.assertEqual( -0xFFFFFFFF & 0xFFFF, intBase(-0xFFFFFFFF) & 0xFFFF ) + self.assertEqual( -0xFFFFFFFF & 0xFFFF, -0xFFFFFFFF & intBase(0xFFFF) ) + + def testOr( self ): + self.assertEqual( 0xFFFF0000 | 0xFFFF, intBase(0xFFFF0000) | 0xFFFF ) + self.assertEqual( 0xFFFF0000 | 0xFFFF, 0xFFFF0000 | intBase(0xFFFF) ) + self.assertEqual( -0xFFFF0000 | 0xFFFF, intBase(-0xFFFF0000) | 0xFFFF ) + self.assertEqual( -0xFFFF0000 | 0xFFFF, -0xFFFF0000 | intBase(0xFFFF) ) + + def testXor( self ): + self.assertEqual( 0xFFFFFFFF ^ 0xFFFF, intBase(0xFFFFFFFF) ^ 0xFFFF ) + self.assertEqual( 0xFFFFFFFF ^ 0xFFFF, 0xFFFFFFFF ^ intBase(0xFFFF) ) + self.assertEqual( -0xFFFFFFFF ^ 0xFFFF, intBase(-0xFFFFFFFF) ^ 0xFFFF ) + self.assertEqual( -0xFFFFFFFF ^ 0xFFFF, -0xFFFFFFFF ^ intBase(0xFFFF) ) + + def testUnary( self ): + self.assertEqual( -0xFFFFFFFF, -intBase(0xFFFFFFFF) ) + self.assertEqual( 0xFFFFFFFF, +intBase(0xFFFFFFFF) ) + self.assertEqual( 0, ~intBase(0xFFFFFFFF) ) + + \ No newline at end of file diff --git a/test/scripts/pykdtest.py b/test/scripts/pykdtest.py index 916c3f6..23536fb 100644 --- a/test/scripts/pykdtest.py +++ b/test/scripts/pykdtest.py @@ -21,6 +21,7 @@ import clienttest import eventtest import typedvar import memtest +import intbase def getTestSuite( singleName = "" ): if singleName == "": @@ -34,6 +35,7 @@ def getTestSuite( singleName = "" ): unittest.TestLoader().loadTestsFromTestCase( clienttest.DbgClientTest ), unittest.TestLoader().loadTestsFromTestCase( eventtest.EventTest ), unittest.TestLoader().loadTestsFromTestCase( memtest.MemoryTest ), + unittest.TestLoader().loadTestsFromTestCase( intbase.IntBaseTest ), ] ) else: return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) ) @@ -52,7 +54,7 @@ if __name__ == "__main__": target.module.reload(); suite = getTestSuite() - #suite = getTestSuite( "typedvar.TypedVarTest" ) + #suite = getTestSuite( "typedvar.TypedVarTest.testStruct" ) unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( suite ) diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index f268673..ab8f151 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -52,14 +52,14 @@ class TypedVarTest( unittest.TestCase ): self.assertEqual( 0, tv.m_arrayField[0] ) self.assertEqual( 2, tv.m_arrayField[1] ) self.assertEqual( 3, tv.m_noArrayField ) - self.assertNotEqual( -1, long(tv.m_arrayField[0]) ) + self.assertNotEqual( -1, tv.m_arrayField[0] ) self.assertNotEqual( 0, tv.m_noArrayField ) def testGlobalVar(self): self.assertEqual( 4, target.module.typedVar( "g_ulongValue" ) ) self.assertEqual( 0x80000000, target.module.typedVar( "ulongArray" )[3] ) self.assertEqual( 0x8000000000000000, target.module.typedVar( "ulonglongArray" )[3] ) - self.assertEqual( -100000, int(target.module.typedVar( "longArray" )[3]) ) - self.assertEqual( -10000000000, long(target.module.typedVar( "longlongArray" )[4]) ) + self.assertEqual( -100000, target.module.typedVar( "longArray" )[3]) + self.assertEqual( -10000000000, target.module.typedVar( "longlongArray" )[4]) self.assertEqual( target.module.g_structTest, target.module.typedVar( "g_structTestPtr" ) ) \ No newline at end of file