[ctypes-commit] ctypes/ctypes/test test_unaligned_structures.py,1.1.2.3,1.1.2.4 test_byteswap.py,1.7
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2006-03-19 11:06:21
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15067/ctypes/test Modified Files: Tag: unaligned_branch test_unaligned_structures.py test_byteswap.py Log Message: unaligned acces works on sparc solaris now Index: test_unaligned_structures.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_unaligned_structures.py,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** test_unaligned_structures.py 18 Mar 2006 20:09:20 -0000 1.1.2.3 --- test_unaligned_structures.py 19 Mar 2006 11:06:16 -0000 1.1.2.4 *************** *** 36,40 **** def test_swapped(self): for typ in byteswapped_structures: ! print typ.value self.failUnlessEqual(typ.value.offset, 1) o = typ() --- 36,40 ---- def test_swapped(self): for typ in byteswapped_structures: ! ## print >> sys.stderr, typ.value self.failUnlessEqual(typ.value.offset, 1) o = typ() Index: test_byteswap.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_byteswap.py,v retrieving revision 1.7.2.1 retrieving revision 1.7.2.2 diff -C2 -d -r1.7.2.1 -r1.7.2.2 *** test_byteswap.py 18 Mar 2006 17:21:34 -0000 1.7.2.1 --- test_byteswap.py 19 Mar 2006 11:06:16 -0000 1.7.2.2 *************** *** 3,7 **** from ctypes import * - from ctypes.test import is_resource_enabled def bin(s): --- 3,6 ---- *************** *** 17,21 **** class Test(unittest.TestCase): def X_test(self): ! print sys.byteorder for i in range(32): bits = BITS() --- 16,20 ---- class Test(unittest.TestCase): def X_test(self): ! print >> sys.stderr, sys.byteorder for i in range(32): bits = BITS() *************** *** 223,290 **** self.failUnlessEqual(bin(s1), bin(s2)) ! if is_resource_enabled("unaligned_access"): ! ! def test_unaligned_nonnative_struct_fields(self): ! if sys.byteorder == "little": ! base = BigEndianStructure ! fmt = ">b h xi xd" ! else: ! base = LittleEndianStructure ! fmt = "<b h xi xd" ! class S(base): ! _pack_ = 1 ! _fields_ = [("b", c_byte), ! ("h", c_short), ! ("_1", c_byte), ! ("i", c_int), ! ("_2", c_byte), ! ("d", c_double)] ! s1 = S() ! print "SET b" ! s1.b = 0x12 ! print "SET h" ! s1.h = 0x1234 ! print "SET i" ! s1.i = 0x12345678 ! print "SET d" ! s1.d = 3.14 ! s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14) ! self.failUnlessEqual(bin(s1), bin(s2)) ! def test_unaligned_native_struct_fields(self): ! if sys.byteorder == "little": ! fmt = "<b h xi xd" ! else: ! base = LittleEndianStructure ! fmt = ">b h xi xd" ! class S(Structure): ! _pack_ = 1 ! _fields_ = [("b", c_byte), ! ("h", c_short), ! ("_1", c_byte), ! ("i", c_int), ! ("_2", c_byte), ! ("d", c_double)] ! s1 = S() ! print "SET b" ! s1.b = 0x12 ! print "SET h" ! s1.h = 0x1234 ! print "SET i" ! s1.i = 0x12345678 ! print "SET d" ! s1.d = 3.14 ! s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14) ! self.failUnlessEqual(bin(s1), bin(s2)) if __name__ == "__main__": --- 222,279 ---- self.failUnlessEqual(bin(s1), bin(s2)) ! def test_unaligned_nonnative_struct_fields(self): ! if sys.byteorder == "little": ! base = BigEndianStructure ! fmt = ">b h xi xd" ! else: ! base = LittleEndianStructure ! fmt = "<b h xi xd" ! class S(base): ! _pack_ = 1 ! _fields_ = [("b", c_byte), ! ("h", c_short), ! ("_1", c_byte), ! ("i", c_int), ! ("_2", c_byte), ! ("d", c_double)] ! s1 = S() ! s1.b = 0x12 ! s1.h = 0x1234 ! s1.i = 0x12345678 ! s1.d = 3.14 ! s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14) ! self.failUnlessEqual(bin(s1), bin(s2)) ! def test_unaligned_native_struct_fields(self): ! if sys.byteorder == "little": ! fmt = "<b h xi xd" ! else: ! base = LittleEndianStructure ! fmt = ">b h xi xd" ! class S(Structure): ! _pack_ = 1 ! _fields_ = [("b", c_byte), ! ("h", c_short), ! ("_1", c_byte), ! ("i", c_int), ! ("_2", c_byte), ! ("d", c_double)] ! s1 = S() ! s1.b = 0x12 ! s1.h = 0x1234 ! s1.i = 0x12345678 ! s1.d = 3.14 ! s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14) ! self.failUnlessEqual(bin(s1), bin(s2)) if __name__ == "__main__": |