Python-SIP/sip

Tests are failing on architectures where char is unsigned

mitya57 opened this issue · 2 comments

In Debian, some of the supported architectures, most notably ARM, have char type unsigned (unless you explicitly use signed char or pass -fsigned-char flag to GCC). See this page for details: https://wiki.debian.org/ArchitectureSpecificsMemo.

And on these architectures SIP tests are failing with the following errors:

======================================================================
ERROR: test_char_set_upper_valid (int_convertors.test_int_convertors.IntConvertorsTestCase.test_char_set_upper_valid)
char function argument upper bound.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/autopkgtest-lxc.oer9uxry/downtmp/autopkgtest_tmp/build/test/int_convertors/test_int_convertors.py", line 303, in test_char_set_upper_valid
    self.valid_upper_fixture.char_set(self.CHAR_UPPER)
OverflowError: argument 1 overflowed: value must be in the range -128 to 127

======================================================================
FAIL: test_char_get_lower_overflow (int_convertors.test_int_convertors.IntConvertorsTestCase.test_char_get_lower_overflow)
char virtual result lower bound.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/autopkgtest-lxc.oer9uxry/downtmp/autopkgtest_tmp/build/test/int_convertors/test_int_convertors.py", line 803, in test_char_get_lower_overflow
    with self.assertRaises(OverflowError):
AssertionError: OverflowError not raised

======================================================================
FAIL: test_char_get_upper_valid (int_convertors.test_int_convertors.IntConvertorsTestCase.test_char_get_upper_valid)
char virtual result upper bound.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/autopkgtest-lxc.oer9uxry/downtmp/autopkgtest_tmp/build/test/int_convertors/test_int_convertors.py", line 293, in test_char_get_upper_valid
    self.assertEqual(self.valid_upper_fixture.char_get(), self.CHAR_UPPER)
AssertionError: 0 != 255

======================================================================
FAIL: test_char_set_lower_overflow (int_convertors.test_int_convertors.IntConvertorsTestCase.test_char_set_lower_overflow)
char function argument lower bound.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/autopkgtest-lxc.oer9uxry/downtmp/autopkgtest_tmp/build/test/int_convertors/test_int_convertors.py", line 819, in test_char_set_lower_overflow
    with self.assertRaises(OverflowError):
AssertionError: OverflowError not raised

----------------------------------------------------------------------
Ran 170 tests in 14.613s

FAILED (failures=3, errors=1)

The assumption that char is signed was embedded in the code - there was even a comment to this effect. Now fixed.

Thank you Phil! With the new release the tests are passing on all our architectures.