[pypy-svn] r54771 - pypy/dist/pypy/module/_rawffi/test

afa at codespeak.net afa at codespeak.net
Fri May 16 01:34:06 CEST 2008


Author: afa
Date: Fri May 16 01:34:05 2008
New Revision: 54771

Modified:
   pypy/dist/pypy/module/_rawffi/test/test__rawffi.py
Log:
This test works by pure luck on linux, and fails on win32 which has a different qsort implementation.

See how we sort the array by comparing pointers instead of numbers...

IMO the callback should be called with all its arguments dereferenced.


Modified: pypy/dist/pypy/module/_rawffi/test/test__rawffi.py
==============================================================================
--- pypy/dist/pypy/module/_rawffi/test/test__rawffi.py	(original)
+++ pypy/dist/pypy/module/_rawffi/test/test__rawffi.py	Fri May 16 01:34:05 2008
@@ -449,6 +449,7 @@
         arg1.free()
     
     def test_callback(self):
+        skip("FIXME: compare actually receives a pair of int**")
         import _rawffi
         import struct
         libc = _rawffi.CDLL(self.libc_name)
@@ -457,9 +458,13 @@
             ll_to_sort[i] = 4-i
         qsort = libc.ptr('qsort', ['P', 'i', 'i', 'P'], None)
         resarray = _rawffi.Array('i')(1)
+        bogus_args = False
         def compare(a, b):
             a1 = _rawffi.Array('i').fromaddress(a, 1)
             a2 = _rawffi.Array('i').fromaddress(b, 1)
+            if a1[0] not in [1,2,3,4] or a2[0] not in [1,2,3,4]:
+                print "comparing", a1[0], "with", a2[0]
+                bogus_args = True
             if a1[0] > a2[0]:
                 res = -1
             res = 1
@@ -474,6 +479,7 @@
         qsort(a1, a2, a3, a4)
         res = [ll_to_sort[i] for i in range(len(ll_to_sort))]
         assert res == [1,2,3,4]
+        assert not bogus_args
         a1.free()
         a2.free()
         a3.free()



More information about the Pypy-commit mailing list