components/python/cffi/patches/test.patch
branchs11-update
changeset 3113 49fd14223e17
child 4894 7219201c1b0d
child 7085 cad8ee01213d
equal deleted inserted replaced
3112:a014dcb790bf 3113:49fd14223e17
       
     1 The testsuite makes some incorrect assumptions:
       
     2 
       
     3   - we need to not assume "a standard gcc", so replace the -Werror flag
       
     4     with -errwarn to turn on the warnings are expected to cause compilation
       
     5     to fail.
       
     6 
       
     7   - don't use the -pthread flag for compilation; as Studio doesn't have any
       
     8     clue what to do with it, and we don't need it on Solaris, anyway.
       
     9 
       
    10   - don't force the use of gcc when compiling a test shared object; get
       
    11     that passed in from the makefile.
       
    12 
       
    13   - don't assume that stdin/stdout/stderr are changeable:
       
    14 
       
    15         https://bitbucket.org/cffi/cffi/issue/145/solaris-stdout-and-stderr-not-in-libc-not
       
    16 
       
    17     fixed in
       
    18 
       
    19         https://bitbucket.org/cffi/cffi/commits/237031079adc
       
    20 
       
    21   - don't assume that enums can be unsigned or are the same size as long:
       
    22 
       
    23     https://bitbucket.org/cffi/cffi/issue/143/test_enum_size-makes-invalid-assumptions
       
    24 
       
    25 Also fix a problem with some assignments to void*:
       
    26 
       
    27     https://bitbucket.org/cffi/cffi/issue/146/incorrect-type-for-c_callback-variable
       
    28 
       
    29 fixed in
       
    30 
       
    31     https://bitbucket.org/cffi/cffi/commits/51d87933eb4b
       
    32 
       
    33 --- cffi-0.8.2/testing/test_verify.py	Thu Mar  6 22:51:56 2014
       
    34 +++ cffi-0.8.2/testing/test_verify.py	Thu Mar 20 18:39:01 2014
       
    35 @@ -18,8 +18,10 @@
       
    36          extra_compile_args = [
       
    37              '-Werror', '-Qunused-arguments', '-Wno-error=shorten-64-to-32']
       
    38      else:
       
    39 -        # assume a standard gcc
       
    40 -        extra_compile_args = ['-Werror']
       
    41 +        extra_compile_args = [
       
    42 +          '-errtags=yes',
       
    43 +          '-errwarn=E_ASSIGNMENT_TYPE_MISMATCH,E_RETURN_VALUE_TYPE_MISMATCH'
       
    44 +        ]
       
    45  
       
    46      class FFI(FFI):
       
    47          def verify(self, *args, **kwds):
       
    48 --- cffi-0.8.2/testing/callback_in_thread.py	Fri Mar 21 15:58:21 2014
       
    49 +++ cffi-0.8.2/testing/callback_in_thread.py	Fri Mar 21 15:58:30 2014
       
    50 @@ -22,7 +22,7 @@
       
    51              pthread_create(&thread, NULL, my_wait_function, (void*)mycb);
       
    52              return 0;
       
    53          }
       
    54 -    """, extra_compile_args=['-pthread'])
       
    55 +    """)
       
    56      seen = []
       
    57      @ffi.callback('int(*)(int,int)')
       
    58      def mycallback(x, y):
       
    59 --- cffi-0.8.2/testing/test_ownlib.py	Tue Oct  9 02:10:04 2012
       
    60 +++ cffi-0.8.2/testing/test_ownlib.py	Tue Mar 25 15:39:35 2014
       
    61 @@ -1,4 +1,4 @@
       
    62 -import py, sys
       
    63 +import os, py, sys
       
    64  import subprocess, weakref
       
    65  from cffi import FFI
       
    66  from cffi.backend_ctypes import CTypesBackend
       
    67 @@ -28,7 +28,7 @@
       
    68          from testing.udir import udir
       
    69          udir.join('testownlib.c').write(SOURCE)
       
    70          subprocess.check_call(
       
    71 -            'gcc testownlib.c -shared -fPIC -o testownlib.so',
       
    72 +            os.getenv('TESTOWNLIB_CC') % ('testownlib.c', 'testownlib.so'),
       
    73              cwd=str(udir), shell=True)
       
    74          cls.module = str(udir.join('testownlib.so'))
       
    75  
       
    76 --- cffi-0.8.2/c/test_c.py	Thu Mar  6 22:51:56 2014
       
    77 +++ cffi-0.8.2/c/test_c.py	Mon Mar 24 14:53:27 2014
       
    78 @@ -1102,7 +1102,7 @@
       
    79  def test_read_variable():
       
    80      ## FIXME: this test assumes glibc specific behavior, it's not compliant with C standard
       
    81      ## https://bugs.pypy.org/issue1643
       
    82 -    if sys.platform == 'win32' or sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
       
    83 +    if not sys.platform.startswith("linux"):
       
    84          py.test.skip("untested")
       
    85      BVoidP = new_pointer_type(new_void_type())
       
    86      ll = find_and_load_library('c')
       
    87 @@ -1112,7 +1112,7 @@
       
    88  def test_read_variable_as_unknown_length_array():
       
    89      ## FIXME: this test assumes glibc specific behavior, it's not compliant with C standard
       
    90      ## https://bugs.pypy.org/issue1643
       
    91 -    if sys.platform == 'win32' or sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
       
    92 +    if not sys.platform.startswith("linux"):
       
    93          py.test.skip("untested")
       
    94      BCharP = new_pointer_type(new_primitive_type("char"))
       
    95      BArray = new_array_type(BCharP, None)
       
    96 @@ -1124,7 +1124,7 @@
       
    97  def test_write_variable():
       
    98      ## FIXME: this test assumes glibc specific behavior, it's not compliant with C standard
       
    99      ## https://bugs.pypy.org/issue1643
       
   100 -    if sys.platform == 'win32' or sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
       
   101 +    if not sys.platform.startswith("linux"):
       
   102          py.test.skip("untested")
       
   103      BVoidP = new_pointer_type(new_void_type())
       
   104      ll = find_and_load_library('c')
       
   105 --- cffi-0.8.2/testing/test_verify.py	Thu Mar  6 22:51:56 2014
       
   106 +++ cffi-0.8.2/testing/test_verify.py	Mon Mar 24 15:03:49 2014
       
   107 @@ -1472,8 +1474,8 @@
       
   108      assert func() == 42
       
   109  
       
   110  def test_FILE_stored_in_stdout():
       
   111 -    if sys.platform == 'win32':
       
   112 -        py.test.skip("MSVC: cannot assign to stdout")
       
   113 +    if not sys.platform.startswith("linux"):
       
   114 +        py.test.skip("likely, we cannot assign to stdout")
       
   115      ffi = FFI()
       
   116      ffi.cdef("int printf(const char *, ...); FILE *setstdout(FILE *);")
       
   117      lib = ffi.verify("""
       
   118 --- cffi-0.8.2/testing/test_verify.py	Thu Mar  6 22:51:56 2014
       
   119 +++ cffi-0.8.2/testing/test_verify.py	Mon Mar 24 15:06:23 2014
       
   120 @@ -1598,13 +1598,13 @@
       
   121               ('-123',          4, -1),
       
   122               ('-2147483647-1', 4, -1),
       
   123               ]
       
   124 -    if FFI().sizeof("long") == 8:
       
   125 +    if FFI().sizeof("long") == 8 and sys.platform != 'sunos5':
       
   126          cases += [('4294967296L',        8, 2**64-1),
       
   127                    ('%dUL' % (2**64-1),   8, 2**64-1),
       
   128                    ('-2147483649L',       8, -1),
       
   129                    ('%dL-1L' % (1-2**63), 8, -1)]
       
   130      for hidden_value, expected_size, expected_minus1 in cases:
       
   131 -        if sys.platform == 'win32' and 'U' in hidden_value:
       
   132 +        if sys.platform in ('win32', 'sunos5') and 'U' in hidden_value:
       
   133              continue   # skipped on Windows
       
   134          ffi = FFI()
       
   135          ffi.cdef("enum foo_e { AA, BB, ... };")
       
   136 @@ -1629,7 +1627,7 @@
       
   137                          (maxulong, -1, ''),
       
   138                          (-1, 0xffffffff, 'U'),
       
   139                          (-1, maxulong, 'UL')]:
       
   140 -        if c2c and sys.platform == 'win32':
       
   141 +        if c2c and sys.platform in ('win32', 'sunos5'):
       
   142              continue     # enums may always be signed with MSVC
       
   143          ffi = FFI()
       
   144          ffi.cdef("enum foo_e { AA=%s };" % c1)
       
   145 --- a/testing/test_verify.py
       
   146 +++ b/testing/test_verify.py
       
   147 @@ -1656,8 +1656,8 @@
       
   148      ffi = FFI()
       
   149      ffi.cdef("""
       
   150          int (*python_callback)(int how_many, int *values);
       
   151 -        void *const c_callback;   /* pass this ptr to C routines */
       
   152 -        int some_c_function(void *cb);
       
   153 +        int (*const c_callback)(int,...);   /* pass this ptr to C routines */
       
   154 +        int some_c_function(int(*cb)(int,...));
       
   155      """)
       
   156      lib = ffi.verify("""
       
   157          #include <stdarg.h>