test.patch revision 5484
4892N/A
2719N/AThe testsuite makes some incorrect assumptions:
2719N/A
4892N/A - Don't use the -pthread flag for compilation; as Studio doesn't have any
2719N/A clue what to do with it, and we don't need it on Solaris, anyway.
2719N/A
4892N/A - We need to not assume "a standard gcc", so replace the -Werror flag
4892N/A with -errwarn to turn on the warnings are expected to cause compilation
4892N/A to fail. Also, there is no equivalent for -Wconversion in Studio, so turn
4892N/A off testing for conversion errors.
2719N/A
2719N/A - don't assume that enums can be unsigned or are the same size as long:
2719N/A
2719N/A https://bitbucket.org/cffi/cffi/issue/143/test_enum_size-makes-invalid-assumptions
2719N/A
4892N/A - There is one test helper in test_recompiler where we suddenly try to do C++
4892N/A but without changing the compiler executable. This works in gcc but not with
5484N/A Studio.
5484N/A
5484N/A - test_recompiler has some test cases work in gcc or clang but not with Studio:
5484N/A test_some_float_type and test_some_float_invalid_3 raise an error "non-constant
5484N/A initializer involving a cast".
5484N/A test_restrict_fields uses the __restrict keyword, which seems to require gcc.
2719N/A
4892N/A - Don't force the use of gcc when compiling a test shared object; get
4892N/A that passed in from the makefile.
4892N/A
4892N/A
4892N/A--- cffi-1.1.2/testing/cffi0/callback_in_thread.py 2015-06-09 03:04:07.000000000 -0700
4892N/A+++ cffi-1.1.2/testing/cffi0/callback_in_thread.py 2015-08-11 10:56:22.822161292 -0700
2719N/A@@ -22,7 +22,7 @@
2719N/A pthread_create(&thread, NULL, my_wait_function, (void*)mycb);
2719N/A return 0;
2719N/A }
2719N/A- """, extra_compile_args=['-pthread'])
2719N/A+ """)
2719N/A seen = []
2719N/A @ffi.callback('int(*)(int,int)')
2719N/A def mycallback(x, y):
4892N/A--- cffi-1.1.2/testing/cffi0/test_verify.py 2015-06-09 03:04:07.000000000 -0700
4892N/A+++ cffi-1.1.2/testing/cffi0/test_verify.py 2015-08-12 14:17:18.300215250 -0700
4892N/A@@ -18,6 +18,9 @@
4892N/A extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
4892N/A # special things for clang
4892N/A extra_compile_args.append('-Qunused-arguments')
4892N/A+ elif (sys.platform == 'sunos5'):
4892N/A+ extra_compile_args = ["-errtags=yes",
4892N/A+ "-errwarn=E_ASSIGNMENT_TYPE_MISMATCH,E_RETURN_VALUE_TYPE_MISMATCH"]
4892N/A else:
4892N/A # assume a standard gcc
4892N/A extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
4892N/A@@ -95,6 +98,11 @@
4892N/A py.test.skip("needs GCC or Clang")
2719N/A ffi = FFI()
4892N/A ffi.cdef(cdef)
4892N/A+
4892N/A+ if sys.platform == 'sunos5':
4892N/A+ lib = ffi.verify(source, **kargs)
4892N/A+ return lib
4892N/A+
4892N/A py.test.raises(VerificationError, ffi.verify, source, **kargs)
4892N/A extra_compile_args_orig = extra_compile_args[:]
4892N/A extra_compile_args.remove('-Wconversion')
4892N/A@@ -1737,13 +1745,13 @@
2719N/A ('-123', 4, -1),
2719N/A ('-2147483647-1', 4, -1),
2719N/A ]
2719N/A- if FFI().sizeof("long") == 8:
2719N/A+ if FFI().sizeof("long") == 8 and sys.platform != 'sunos5':
2719N/A cases += [('4294967296L', 8, 2**64-1),
2719N/A ('%dUL' % (2**64-1), 8, 2**64-1),
2719N/A ('-2147483649L', 8, -1),
2719N/A ('%dL-1L' % (1-2**63), 8, -1)]
2719N/A for hidden_value, expected_size, expected_minus1 in cases:
2719N/A- if sys.platform == 'win32' and 'U' in hidden_value:
2719N/A+ if sys.platform in ('win32', 'sunos5') and 'U' in hidden_value:
2719N/A continue # skipped on Windows
2719N/A ffi = FFI()
2719N/A ffi.cdef("enum foo_e { AA, BB, ... };")
4892N/A@@ -1768,7 +1776,7 @@
2719N/A (maxulong, -1, ''),
2719N/A (-1, 0xffffffff, 'U'),
2719N/A (-1, maxulong, 'UL')]:
2719N/A- if c2c and sys.platform == 'win32':
2719N/A+ if c2c and sys.platform in ('win32', 'sunos5'):
2719N/A continue # enums may always be signed with MSVC
2719N/A ffi = FFI()
2719N/A ffi.cdef("enum foo_e { AA=%s };" % c1)
4892N/A--- cffi-1.1.2/testing/cffi1/test_new_ffi_1.py 2015-06-09 03:04:07.000000000 -0700
4892N/A+++ cffi-1.1.2/testing/cffi1/test_new_ffi_1.py 2015-08-12 15:18:12.105387245 -0700
4892N/A@@ -81,6 +81,10 @@
4892N/A DEFS = DEFS.replace('data[0]', 'data[1]') # not supported
4892N/A CCODE = (DEFS + "\n#pragma pack(push,1)\n" + DEFS_PACKED +
4892N/A "\n#pragma pack(pop)\n")
4892N/A+ elif sys.platform == "sunos5":
4892N/A+ DEFS = DEFS.replace('data[0]', 'data[1]') # not supported
4892N/A+ CCODE = (DEFS +
4892N/A+ DEFS_PACKED.replace('/*here*/', '__attribute__((packed))'))
4892N/A else:
4892N/A CCODE = (DEFS +
4892N/A DEFS_PACKED.replace('/*here*/', '__attribute__((packed))'))
4892N/A@@ -893,9 +897,9 @@
4892N/A assert ffi.cast("enum foq", 0) != ffi.cast("enum bar", 0)
4892N/A assert ffi.cast("enum bar", 0) != ffi.cast("int", 0)
4892N/A assert repr(ffi.cast("enum bar", -1)) == "<cdata 'enum bar' -1: CC1>"
4892N/A- assert repr(ffi.cast("enum foq", -1)) == ( # enums are unsigned, if
4892N/A- "<cdata 'enum foq' 4294967295>") or ( # they contain no neg value
4892N/A- sys.platform == "win32") # (but not on msvc)
4892N/A+ assert repr(ffi.cast("enum foq", -1)) == ( # enums are unsigned, if
4892N/A+ "<cdata 'enum foq' 4294967295>") or ( # they contain no neg value
4892N/A+ sys.platform in ("win32", "sunos5")) # (but not on msvc or SS)
4892N/A # enum baz { A2=0x1000, B2=0x2000 };
4892N/A assert ffi.string(ffi.cast("enum baz", 0x1000)) == "A2"
4892N/A assert ffi.string(ffi.cast("enum baz", 0x2000)) == "B2"
4892N/A@@ -1011,7 +1015,7 @@
4892N/A def test_bitfield_enum(self):
4892N/A # typedef enum { AA1, BB1, CC1 } foo_e_t;
4892N/A # typedef struct { foo_e_t f:2; } bfenum_t;
4892N/A- if sys.platform == "win32":
4892N/A+ if sys.platform in ("win32", "sunos5"):
4892N/A py.test.skip("enums are not unsigned")
4892N/A s = ffi.new("bfenum_t *")
4892N/A s.f = 2
4892N/A@@ -1211,7 +1215,7 @@
4892N/A assert repr(p.a).startswith("<cdata 'int[2]' 0x")
4892N/A
4892N/A def test_struct_containing_array_varsize_workaround(self):
4892N/A- if sys.platform == "win32":
4892N/A+ if sys.platform in ("win32", "sunos5"):
4892N/A py.test.skip("array of length 0 not supported")
4892N/A # struct array0 { int len; short data[0]; };
4892N/A p = ffi.new("char[]", ffi.sizeof("struct array0") + 7 * SIZE_OF_SHORT)
4892N/A--- cffi-1.1.2/testing/cffi1/test_recompiler.py 2015-06-09 03:04:10.000000000 -0700
4892N/A+++ cffi-1.1.2/testing/cffi1/test_recompiler.py 2015-08-11 11:08:16.757848317 -0700
5484N/A@@ -22,10 +22,14 @@
4892N/A kwds.setdefault('undef_macros', ['NDEBUG'])
4892N/A module_name = '_CFFI_' + module_name
4892N/A ffi.set_source(module_name, source)
5484N/A- if not os.environ.get('NO_CPP'): # test the .cpp mode too
5484N/A+ if sys.platform == 'sunos5':
5484N/A+ kwds['extra_compile_args'] = (kwds.get('extra_compile_args', []) +
5484N/A+ ["-errtags=yes", "-errwarn=E_ASSIGNMENT_TYPE_MISMATCH,"
5484N/A+ "E_RETURN_VALUE_TYPE_MISMATCH"])
5484N/A+ elif not os.environ.get('NO_CPP'): # test the .cpp mode too
4892N/A kwds.setdefault('source_extension', '.cpp')
4892N/A source = 'extern "C" {\n%s\n}' % (source,)
5484N/A else:
5484N/A kwds['extra_compile_args'] = (kwds.get('extra_compile_args', []) +
5484N/A ['-Werror'])
4892N/A return recompiler._verify(ffi, module_name, source, *args, **kwds)
5484N/A@@ -1076,2 +1076,3 @@
5484N/A def test_some_float_type():
5484N/A+ py.test.skip("needs GCC or Clang")
5484N/A ffi = FFI()
5484N/A@@ -1111,2 +1111,3 @@
5484N/A def test_some_float_invalid_3():
5484N/A+ py.test.skip("needs GCC or Clang")
5484N/A ffi = FFI()
5484N/A@@ -1225,2 +1225,3 @@
5484N/A def test_restrict_fields():
5484N/A+ py.test.skip("needs GCC or Clang")
5484N/A ffi = FFI()
4892N/A--- cffi-1.1.2/testing/cffi1/test_verify1.py 2015-06-09 03:04:07.000000000 -0700
4892N/A+++ cffi-1.1.2/testing/cffi1/test_verify1.py 2015-08-12 15:02:07.774160223 -0700
4892N/A@@ -18,6 +18,9 @@
4892N/A extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
4892N/A # special things for clang
4892N/A extra_compile_args.append('-Qunused-arguments')
4892N/A+ elif (sys.platform == 'sunos5'):
4892N/A+ extra_compile_args = ["-errtags=yes",
5484N/A+ "-errwarn=E_ASSIGNMENT_TYPE_MISMATCH,E_RETURN_VALUE_TYPE_MISMATCH"]
4892N/A else:
4892N/A # assume a standard gcc
4892N/A extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
4892N/A@@ -75,6 +77,10 @@
4892N/A py.test.skip("needs GCC or Clang")
2719N/A ffi = FFI()
4892N/A ffi.cdef(cdef)
4892N/A+ if sys.platform == 'sunos5':
4892N/A+ lib = ffi.verify(source, **kargs)
4892N/A+ return lib
4892N/A+
4892N/A py.test.raises(VerificationError, ffi.verify, source, **kargs)
4892N/A extra_compile_args_orig = extra_compile_args[:]
4892N/A extra_compile_args.remove('-Wconversion')
4892N/A@@ -1726,13 +1732,13 @@
4892N/A ('-123', 4, -1),
4892N/A ('-2147483647-1', 4, -1),
4892N/A ]
4892N/A- if FFI().sizeof("long") == 8:
4892N/A+ if FFI().sizeof("long") == 8 and sys.platform != 'sunos5':
4892N/A cases += [('4294967296L', 8, 2**64-1),
4892N/A ('%dUL' % (2**64-1), 8, 2**64-1),
4892N/A ('-2147483649L', 8, -1),
4892N/A ('%dL-1L' % (1-2**63), 8, -1)]
4892N/A for hidden_value, expected_size, expected_minus1 in cases:
4892N/A- if sys.platform == 'win32' and 'U' in hidden_value:
4892N/A+ if sys.platform in ('win32', 'sunos5') and 'U' in hidden_value:
4892N/A continue # skipped on Windows
4892N/A ffi = FFI()
4892N/A ffi.cdef("enum foo_e { AA, BB, ... };")
4892N/A@@ -1740,7 +1746,7 @@
4892N/A assert lib.AA == 0
4892N/A assert lib.BB == eval(hidden_value.replace('U', '').replace('L', ''))
4892N/A assert ffi.sizeof("enum foo_e") == expected_size
4892N/A- if sys.platform != 'win32':
4892N/A+ if sys.platform not in ('win32', 'sunos5'):
4892N/A assert int(ffi.cast("enum foo_e", -1)) == expected_minus1
4892N/A # test with the large value hidden:
4892N/A # disabled so far, doesn't work
4892N/A@@ -1759,7 +1765,7 @@
4892N/A (0xffffffff, 'U'),
4892N/A (maxulong, 'UL'),
4892N/A (-int(maxulong / 3), 'L')]:
4892N/A- if c2c and sys.platform == 'win32':
4892N/A+ if c2c and sys.platform in ('win32', 'sunos5'):
4892N/A continue # enums may always be signed with MSVC
4892N/A ffi = FFI()
4892N/A ffi.cdef("enum foo_e { AA };")
4892N/A--- cffi-1.1.2/testing/cffi0/test_ownlib.py 2015-06-09 03:04:07.000000000 -0700
4892N/A+++ cffi-1.1.2/testing/cffi0/test_ownlib.py 2015-08-12 13:55:21.239982926 -0700
4892N/A@@ -1,4 +1,4 @@
4892N/A-import py, sys
4892N/A+import os, py, sys
4892N/A import subprocess, weakref
4892N/A from cffi import FFI
4892N/A from cffi.backend_ctypes import CTypesBackend
4892N/A@@ -102,7 +102,6 @@
4892N/A from testing.udir import udir
4892N/A udir.join('testownlib.c').write(SOURCE)
4892N/A if sys.platform == 'win32':
4892N/A- import os
4892N/A # did we already build it?
4892N/A if os.path.exists(str(udir.join('testownlib.dll'))):
4892N/A cls.module = str(udir.join('testownlib.dll'))
4892N/A@@ -129,7 +128,7 @@
4892N/A cls.module = str(udir.join('testownlib.dll'))
4892N/A else:
4892N/A subprocess.check_call(
4892N/A- 'gcc testownlib.c -shared -fPIC -o testownlib.so',
4892N/A+ os.getenv('TESTOWNLIB_CC') % ('testownlib.c', 'testownlib.so'),
4892N/A cwd=str(udir), shell=True)
4892N/A cls.module = str(udir.join('testownlib.so'))
4892N/A