components/python/cffi/patches/test.patch
branchs11u3-sru
changeset 7085 cad8ee01213d
parent 3113 49fd14223e17
equal deleted inserted replaced
7076:332c44bd55bf 7085:cad8ee01213d
       
     1 
     1 The testsuite makes some incorrect assumptions:
     2 The testsuite makes some incorrect assumptions:
     2 
     3 
     3   - we need to not assume "a standard gcc", so replace the -Werror flag
     4   - Don't use the -pthread flag for compilation; as Studio doesn't have any
       
     5     clue what to do with it, and we don't need it on Solaris, anyway.
       
     6 
       
     7   - 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
     8     with -errwarn to turn on the warnings are expected to cause compilation
     5     to fail.
     9     to fail. Also, there is no equivalent for -Wconversion in Studio, so turn
     6 
    10     off testing for conversion errors.
     7   - don't use the -pthread flag for compilation; as Studio doesn't have any
    11 
     8     clue what to do with it, and we don't need it on Solaris, anyway.
    12   - don't assume that enums can be unsigned or are the same size as long:
     9 
    13 
    10   - don't force the use of gcc when compiling a test shared object; get
    14     https://bitbucket.org/cffi/cffi/issue/143/test_enum_size-makes-invalid-assumptions
       
    15 
       
    16   - There is one test helper in test_recompiler where we suddenly try to do C++
       
    17     but without changing the compiler executable. This works in gcc but not with
       
    18     Studio.
       
    19 
       
    20   - test_recompiler has some test cases work in gcc or clang but not with Studio:
       
    21     test_some_float_type and test_some_float_invalid_3 raise an error "non-constant
       
    22     initializer involving a cast".
       
    23     test_restrict_fields uses the __restrict keyword, which seems to require gcc.
       
    24 
       
    25   - Don't force the use of gcc when compiling a test shared object; get
    11     that passed in from the makefile.
    26     that passed in from the makefile.
    12 
    27 
    13   - don't assume that stdin/stdout/stderr are changeable:
    28 
    14 
    29 --- cffi-1.1.2/testing/cffi0/callback_in_thread.py	2015-06-09 03:04:07.000000000 -0700
    15         https://bitbucket.org/cffi/cffi/issue/145/solaris-stdout-and-stderr-not-in-libc-not
    30 +++ cffi-1.1.2/testing/cffi0/callback_in_thread.py	2015-08-11 10:56:22.822161292 -0700
    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 @@
    31 @@ -22,7 +22,7 @@
    51              pthread_create(&thread, NULL, my_wait_function, (void*)mycb);
    32              pthread_create(&thread, NULL, my_wait_function, (void*)mycb);
    52              return 0;
    33              return 0;
    53          }
    34          }
    54 -    """, extra_compile_args=['-pthread'])
    35 -    """, extra_compile_args=['-pthread'])
    55 +    """)
    36 +    """)
    56      seen = []
    37      seen = []
    57      @ffi.callback('int(*)(int,int)')
    38      @ffi.callback('int(*)(int,int)')
    58      def mycallback(x, y):
    39      def mycallback(x, y):
    59 --- cffi-0.8.2/testing/test_ownlib.py	Tue Oct  9 02:10:04 2012
    40 --- cffi-1.1.2/testing/cffi0/test_verify.py	2015-06-09 03:04:07.000000000 -0700
    60 +++ cffi-0.8.2/testing/test_ownlib.py	Tue Mar 25 15:39:35 2014
    41 +++ cffi-1.1.2/testing/cffi0/test_verify.py	2015-08-12 14:17:18.300215250 -0700
    61 @@ -1,4 +1,4 @@
    42 @@ -18,6 +18,9 @@
    62 -import py, sys
    43          extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
    63 +import os, py, sys
    44          # special things for clang
    64  import subprocess, weakref
    45          extra_compile_args.append('-Qunused-arguments')
    65  from cffi import FFI
    46 +    elif (sys.platform == 'sunos5'):
    66  from cffi.backend_ctypes import CTypesBackend
    47 +        extra_compile_args = ["-errtags=yes",
    67 @@ -28,7 +28,7 @@
    48 +            "-errwarn=E_ASSIGNMENT_TYPE_MISMATCH,E_RETURN_VALUE_TYPE_MISMATCH"]
    68          from testing.udir import udir
    49      else:
    69          udir.join('testownlib.c').write(SOURCE)
    50          # assume a standard gcc
    70          subprocess.check_call(
    51          extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
    71 -            'gcc testownlib.c -shared -fPIC -o testownlib.so',
    52 @@ -95,6 +98,11 @@
    72 +            os.getenv('TESTOWNLIB_CC') % ('testownlib.c', 'testownlib.so'),
    53          py.test.skip("needs GCC or Clang")
    73              cwd=str(udir), shell=True)
    54      ffi = FFI()
    74          cls.module = str(udir.join('testownlib.so'))
    55      ffi.cdef(cdef)
    75  
    56 +
    76 --- cffi-0.8.2/c/test_c.py	Thu Mar  6 22:51:56 2014
    57 +    if sys.platform == 'sunos5':
    77 +++ cffi-0.8.2/c/test_c.py	Mon Mar 24 14:53:27 2014
    58 +        lib = ffi.verify(source, **kargs)
    78 @@ -1102,7 +1102,7 @@
    59 +        return lib
    79  def test_read_variable():
    60 +
    80      ## FIXME: this test assumes glibc specific behavior, it's not compliant with C standard
    61      py.test.raises(VerificationError, ffi.verify, source, **kargs)
    81      ## https://bugs.pypy.org/issue1643
    62      extra_compile_args_orig = extra_compile_args[:]
    82 -    if sys.platform == 'win32' or sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
    63      extra_compile_args.remove('-Wconversion')
    83 +    if not sys.platform.startswith("linux"):
    64 @@ -1737,13 +1745,13 @@
    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),
    65               ('-123',          4, -1),
   122               ('-2147483647-1', 4, -1),
    66               ('-2147483647-1', 4, -1),
   123               ]
    67               ]
   124 -    if FFI().sizeof("long") == 8:
    68 -    if FFI().sizeof("long") == 8:
   125 +    if FFI().sizeof("long") == 8 and sys.platform != 'sunos5':
    69 +    if FFI().sizeof("long") == 8 and sys.platform != 'sunos5':
   131 -        if sys.platform == 'win32' and 'U' in hidden_value:
    75 -        if sys.platform == 'win32' and 'U' in hidden_value:
   132 +        if sys.platform in ('win32', 'sunos5') and 'U' in hidden_value:
    76 +        if sys.platform in ('win32', 'sunos5') and 'U' in hidden_value:
   133              continue   # skipped on Windows
    77              continue   # skipped on Windows
   134          ffi = FFI()
    78          ffi = FFI()
   135          ffi.cdef("enum foo_e { AA, BB, ... };")
    79          ffi.cdef("enum foo_e { AA, BB, ... };")
   136 @@ -1629,7 +1627,7 @@
    80 @@ -1768,7 +1776,7 @@
   137                          (maxulong, -1, ''),
    81                          (maxulong, -1, ''),
   138                          (-1, 0xffffffff, 'U'),
    82                          (-1, 0xffffffff, 'U'),
   139                          (-1, maxulong, 'UL')]:
    83                          (-1, maxulong, 'UL')]:
   140 -        if c2c and sys.platform == 'win32':
    84 -        if c2c and sys.platform == 'win32':
   141 +        if c2c and sys.platform in ('win32', 'sunos5'):
    85 +        if c2c and sys.platform in ('win32', 'sunos5'):
   142              continue     # enums may always be signed with MSVC
    86              continue     # enums may always be signed with MSVC
   143          ffi = FFI()
    87          ffi = FFI()
   144          ffi.cdef("enum foo_e { AA=%s };" % c1)
    88          ffi.cdef("enum foo_e { AA=%s };" % c1)
   145 --- a/testing/test_verify.py
    89 --- cffi-1.1.2/testing/cffi1/test_new_ffi_1.py	2015-06-09 03:04:07.000000000 -0700
   146 +++ b/testing/test_verify.py
    90 +++ cffi-1.1.2/testing/cffi1/test_new_ffi_1.py	2015-08-12 15:18:12.105387245 -0700
   147 @@ -1656,8 +1656,8 @@
    91 @@ -81,6 +81,10 @@
   148      ffi = FFI()
    92          DEFS = DEFS.replace('data[0]', 'data[1]')   # not supported
   149      ffi.cdef("""
    93          CCODE = (DEFS + "\n#pragma pack(push,1)\n" + DEFS_PACKED +
   150          int (*python_callback)(int how_many, int *values);
    94                   "\n#pragma pack(pop)\n")
   151 -        void *const c_callback;   /* pass this ptr to C routines */
    95 +    elif sys.platform == "sunos5":
   152 -        int some_c_function(void *cb);
    96 +        DEFS = DEFS.replace('data[0]', 'data[1]')   # not supported
   153 +        int (*const c_callback)(int,...);   /* pass this ptr to C routines */
    97 +        CCODE = (DEFS +
   154 +        int some_c_function(int(*cb)(int,...));
    98 +                 DEFS_PACKED.replace('/*here*/', '__attribute__((packed))'))
   155      """)
    99      else:
   156      lib = ffi.verify("""
   100          CCODE = (DEFS +
   157          #include <stdarg.h>
   101                   DEFS_PACKED.replace('/*here*/', '__attribute__((packed))'))
       
   102 @@ -893,9 +897,9 @@
       
   103          assert ffi.cast("enum foq", 0) != ffi.cast("enum bar", 0)
       
   104          assert ffi.cast("enum bar", 0) != ffi.cast("int", 0)
       
   105          assert repr(ffi.cast("enum bar", -1)) == "<cdata 'enum bar' -1: CC1>"
       
   106 -        assert repr(ffi.cast("enum foq", -1)) == (  # enums are unsigned, if
       
   107 -            "<cdata 'enum foq' 4294967295>") or (   # they contain no neg value
       
   108 -                sys.platform == "win32")            # (but not on msvc)
       
   109 +        assert repr(ffi.cast("enum foq", -1)) == (   # enums are unsigned, if
       
   110 +            "<cdata 'enum foq' 4294967295>") or (    # they contain no neg value
       
   111 +                sys.platform in ("win32", "sunos5")) # (but not on msvc or SS)
       
   112          # enum baz { A2=0x1000, B2=0x2000 };
       
   113          assert ffi.string(ffi.cast("enum baz", 0x1000)) == "A2"
       
   114          assert ffi.string(ffi.cast("enum baz", 0x2000)) == "B2"
       
   115 @@ -1011,7 +1015,7 @@
       
   116      def test_bitfield_enum(self):
       
   117          # typedef enum { AA1, BB1, CC1 } foo_e_t;
       
   118          # typedef struct { foo_e_t f:2; } bfenum_t;
       
   119 -        if sys.platform == "win32":
       
   120 +        if sys.platform in ("win32", "sunos5"):
       
   121              py.test.skip("enums are not unsigned")
       
   122          s = ffi.new("bfenum_t *")
       
   123          s.f = 2
       
   124 @@ -1211,7 +1215,7 @@
       
   125          assert repr(p.a).startswith("<cdata 'int[2]' 0x")
       
   126  
       
   127      def test_struct_containing_array_varsize_workaround(self):
       
   128 -        if sys.platform == "win32":
       
   129 +        if sys.platform in ("win32", "sunos5"):
       
   130              py.test.skip("array of length 0 not supported")
       
   131          # struct array0 { int len; short data[0]; };
       
   132          p = ffi.new("char[]", ffi.sizeof("struct array0") + 7 * SIZE_OF_SHORT)
       
   133 --- cffi-1.1.2/testing/cffi1/test_recompiler.py	2015-06-09 03:04:10.000000000 -0700
       
   134 +++ cffi-1.1.2/testing/cffi1/test_recompiler.py	2015-08-11 11:08:16.757848317 -0700
       
   135 @@ -22,10 +22,14 @@
       
   136      kwds.setdefault('undef_macros', ['NDEBUG'])
       
   137      module_name = '_CFFI_' + module_name
       
   138      ffi.set_source(module_name, source)
       
   139 -    if not os.environ.get('NO_CPP'):     # test the .cpp mode too
       
   140 +    if sys.platform == 'sunos5':
       
   141 +        kwds['extra_compile_args'] = (kwds.get('extra_compile_args', []) +
       
   142 +            ["-errtags=yes", "-errwarn=E_ASSIGNMENT_TYPE_MISMATCH,"
       
   143 +            "E_RETURN_VALUE_TYPE_MISMATCH"])
       
   144 +    elif not os.environ.get('NO_CPP'):     # test the .cpp mode too
       
   145          kwds.setdefault('source_extension', '.cpp')
       
   146          source = 'extern "C" {\n%s\n}' % (source,)
       
   147      else:
       
   148          kwds['extra_compile_args'] = (kwds.get('extra_compile_args', []) +
       
   149                                        ['-Werror'])
       
   150      return recompiler._verify(ffi, module_name, source, *args, **kwds)
       
   151 @@ -1076,2 +1076,3 @@
       
   152  def test_some_float_type():
       
   153 +    py.test.skip("needs GCC or Clang")
       
   154      ffi = FFI()
       
   155 @@ -1111,2 +1111,3 @@
       
   156  def test_some_float_invalid_3():
       
   157 +    py.test.skip("needs GCC or Clang")
       
   158      ffi = FFI()
       
   159 @@ -1225,2 +1225,3 @@
       
   160  def test_restrict_fields():
       
   161 +    py.test.skip("needs GCC or Clang")
       
   162      ffi = FFI()
       
   163 --- cffi-1.1.2/testing/cffi1/test_verify1.py	2015-06-09 03:04:07.000000000 -0700
       
   164 +++ cffi-1.1.2/testing/cffi1/test_verify1.py	2015-08-12 15:02:07.774160223 -0700
       
   165 @@ -18,6 +18,9 @@
       
   166          extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
       
   167          # special things for clang
       
   168          extra_compile_args.append('-Qunused-arguments')
       
   169 +    elif (sys.platform == 'sunos5'):
       
   170 +        extra_compile_args = ["-errtags=yes",
       
   171 +            "-errwarn=E_ASSIGNMENT_TYPE_MISMATCH,E_RETURN_VALUE_TYPE_MISMATCH"]
       
   172      else:
       
   173          # assume a standard gcc
       
   174          extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
       
   175 @@ -75,6 +77,10 @@
       
   176          py.test.skip("needs GCC or Clang")
       
   177      ffi = FFI()
       
   178      ffi.cdef(cdef)
       
   179 +    if sys.platform == 'sunos5':
       
   180 +        lib = ffi.verify(source, **kargs)
       
   181 +        return lib
       
   182 +
       
   183      py.test.raises(VerificationError, ffi.verify, source, **kargs)
       
   184      extra_compile_args_orig = extra_compile_args[:]
       
   185      extra_compile_args.remove('-Wconversion')
       
   186 @@ -1726,13 +1732,13 @@
       
   187               ('-123',          4, -1),
       
   188               ('-2147483647-1', 4, -1),
       
   189               ]
       
   190 -    if FFI().sizeof("long") == 8:
       
   191 +    if FFI().sizeof("long") == 8 and sys.platform != 'sunos5':
       
   192          cases += [('4294967296L',        8, 2**64-1),
       
   193                    ('%dUL' % (2**64-1),   8, 2**64-1),
       
   194                    ('-2147483649L',       8, -1),
       
   195                    ('%dL-1L' % (1-2**63), 8, -1)]
       
   196      for hidden_value, expected_size, expected_minus1 in cases:
       
   197 -        if sys.platform == 'win32' and 'U' in hidden_value:
       
   198 +        if sys.platform in ('win32', 'sunos5') and 'U' in hidden_value:
       
   199              continue   # skipped on Windows
       
   200          ffi = FFI()
       
   201          ffi.cdef("enum foo_e { AA, BB, ... };")
       
   202 @@ -1740,7 +1746,7 @@
       
   203          assert lib.AA == 0
       
   204          assert lib.BB == eval(hidden_value.replace('U', '').replace('L', ''))
       
   205          assert ffi.sizeof("enum foo_e") == expected_size
       
   206 -        if sys.platform != 'win32':
       
   207 +        if sys.platform not in  ('win32', 'sunos5'):
       
   208              assert int(ffi.cast("enum foo_e", -1)) == expected_minus1
       
   209      # test with the large value hidden:
       
   210      # disabled so far, doesn't work
       
   211 @@ -1759,7 +1765,7 @@
       
   212                      (0xffffffff, 'U'),
       
   213                      (maxulong, 'UL'),
       
   214                      (-int(maxulong / 3), 'L')]:
       
   215 -        if c2c and sys.platform == 'win32':
       
   216 +        if c2c and sys.platform in ('win32', 'sunos5'):
       
   217              continue     # enums may always be signed with MSVC
       
   218          ffi = FFI()
       
   219          ffi.cdef("enum foo_e { AA };")
       
   220 --- cffi-1.1.2/testing/cffi0/test_ownlib.py	2015-06-09 03:04:07.000000000 -0700
       
   221 +++ cffi-1.1.2/testing/cffi0/test_ownlib.py	2015-08-12 13:55:21.239982926 -0700
       
   222 @@ -1,4 +1,4 @@
       
   223 -import py, sys
       
   224 +import os, py, sys
       
   225  import subprocess, weakref
       
   226  from cffi import FFI
       
   227  from cffi.backend_ctypes import CTypesBackend
       
   228 @@ -102,7 +102,6 @@
       
   229          from testing.udir import udir
       
   230          udir.join('testownlib.c').write(SOURCE)
       
   231          if sys.platform == 'win32':
       
   232 -            import os
       
   233              # did we already build it?
       
   234              if os.path.exists(str(udir.join('testownlib.dll'))):
       
   235                  cls.module = str(udir.join('testownlib.dll'))
       
   236 @@ -129,7 +128,7 @@
       
   237                  cls.module = str(udir.join('testownlib.dll'))
       
   238          else:
       
   239              subprocess.check_call(
       
   240 -                'gcc testownlib.c -shared -fPIC -o testownlib.so',
       
   241 +                os.getenv('TESTOWNLIB_CC') % ('testownlib.c', 'testownlib.so'),
       
   242                  cwd=str(udir), shell=True)
       
   243              cls.module = str(udir.join('testownlib.so'))
       
   244