ICRAR / crc32c

A python package implementing the crc32c algorithm in hardware and software
GNU Lesser General Public License v2.1
41 stars 25 forks source link

Tests fail on big-endian #22

Closed stefanor closed 4 years ago

stefanor commented 4 years ago

From Debian build logs, we can see that tests are failing across all big-endian archs:

e.g. on s390x:

======================================================================
FAIL: test_all (test.test_crc32c.TestLongPhrase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/test/test_crc32c.py", line 113, in test_all
    self.assertEqual(self.checksum, crc32c.crc32c(self.val))
AssertionError: 4239873882 != 4025908388

======================================================================
FAIL: test_msvc_examples (test.test_crc32c.TestMisc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/test/test_crc32c.py", line 96, in test_msvc_examples
    assert_msvc_vals(ulonglong_as_bytes(0x88889999EEEE3333), 0x5555AAAA, 0x16F57621)
  File "/<<PKGBUILDDIR>>/test/test_crc32c.py", line 92, in assert_msvc_vals
    self.assertEqual(expected_crc ^ max32, crc32c.crc32c(b, crc ^ max32))
AssertionError: 3909781982 != 4070212859

======================================================================
FAIL: test_all (test.test_crc32c.TestNumbers1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/test/test_crc32c.py", line 113, in test_all
    self.assertEqual(self.checksum, crc32c.crc32c(self.val))
AssertionError: 3808858755 != 268849953

======================================================================
FAIL: test_all (test.test_crc32c.TestNumbers2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/test/test_crc32c.py", line 113, in test_all
    self.assertEqual(self.checksum, crc32c.crc32c(self.val))
AssertionError: 3219729027 != 1827003070

======================================================================
FAIL: test_all (test.test_crc32c.TestNumbers3)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/test/test_crc32c.py", line 113, in test_all
    self.assertEqual(self.checksum, crc32c.crc32c(self.val))
AssertionError: 4091270398 != 2958561646

======================================================================
FAIL: test_all (test.test_crc32c.TestPhrase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/test/test_crc32c.py", line 113, in test_all
    self.assertEqual(self.checksum, crc32c.crc32c(self.val))
AssertionError: 576848900 != 1074876099

----------------------------------------------------------------------
Ran 13 tests in 0.001s

FAILED (failures=6)
Test failed: <unittest.runner.TextTestResult run=13 errors=0 failures=6>
rtobar commented 4 years ago

Thanks @stefanor for reporting these, I think I had never tried running on a big endian architecture before so this is much appreciated.

The tests were failing because there was no proper big endian support in the code to begin with. I've fixed that, plus I added an s390x target on our Travis build matrix, and now the tests run correctly. All changes are in the master branch. I'll be doing a release soon with these fixes and those merged from #21.

rtobar commented 4 years ago

A new version 2.2 has been released containing the fix.