Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failure in test_hash_equal on py2.6 windows #21

Closed
agroszer opened this issue Apr 9, 2015 · 12 comments · Fixed by #22 or #23
Closed

Test failure in test_hash_equal on py2.6 windows #21

agroszer opened this issue Apr 9, 2015 · 12 comments · Fixed by #22 or #23

Comments

@agroszer
Copy link
Contributor

agroszer commented Apr 9, 2015

Commit 2a8313c breaks tests on winbot

see here:

http://winbot.zope.org/builders/persistent_py_265_32/builds/971/steps/test/logs/stdio

@agroszer
Copy link
Contributor Author

agroszer commented Apr 9, 2015

@jamadden ^

@mgedmin
Copy link
Member

mgedmin commented Apr 9, 2015

I have a feeling this is because the tests run on a 32-bit build rather than because it's Windows or because it's Python 2.6.

Note that hash('a string') will differ on 32- and 64-bit platforms (and also different Python versions may compute different hashes):

>>> hash('a string')  # Python 2.6.5, Linux, 32-bit
1827144452
>>> hash('a string')  # Python 2.6.9, Linux, 64-bit
-8411828025894108412
>>> hash('a string')  # Python 3.4.2, Linux, 64-bit
-8227545103199816438

@mgedmin
Copy link
Member

mgedmin commented Apr 9, 2015

At some point Travis CI might allow us to test both 32- and 64-bit builds in the build matrix: travis-ci/travis-ci#986

@mgedmin
Copy link
Member

mgedmin commented Apr 9, 2015

Okay, string hashes are irrelevant for this issue:

static long
TimeStamp_hash(TimeStamp *self)
{
register unsigned char *p = (unsigned char *)self->data;
register int len = 8;
register long x = *p << 7;
while (--len >= 0)
x = (1000003*x) ^ *p++;
x ^= 8;
if (x == -1)
x = -2;
return x;
}

@mgedmin
Copy link
Member

mgedmin commented Apr 9, 2015

Perhaps it would be sufficient to replace ctypes.c_int64 with ctypes.c_long in pyTimeStamp.hash?

@mgedmin mgedmin changed the title 2a8313ccad80cbc01f5153a55788ab8b5412bc04 breaks py2.6 windows tests Test failure in test_hash_equal on py2.6 windows Apr 9, 2015
@mgedmin
Copy link
Member

mgedmin commented Apr 10, 2015

Unfortunately the test still fails: http://winbot.zope.org/builders/persistent_py_265_32/builds/972/steps/test/logs/stdio

Failure in test test_hash_equal_constants (persistent.tests.test_timestamp.PyAndCComparisonTests)
Traceback (most recent call last):
  File "c:\Python26_32\lib\unittest.py", line 279, in run
    testMethod()
  File "c:\buildslave\persistent\build\persistent\tests\test_timestamp.py", line 302, in test_hash_equal_constants
    self.assertEqual(hash(c), 1000006000001)
  File "c:\Python26_32\lib\unittest.py", line 350, in failUnlessEqual
    (msg or '%r != %r' % (first, second))
AssertionError: -721379967 != 1000006000001L
Failure in test test_py_hash_32_64_bit (persistent.tests.test_timestamp.PyAndCComparisonTests)
Traceback (most recent call last):
  File "c:\Python26_32\lib\unittest.py", line 279, in run
    testMethod()
  File "c:\buildslave\persistent\build\persistent\tests\test_timestamp.py", line 275, in test_py_hash_32_64_bit
    self.assertEqual(hash(py), bit_64_hash)
  File "c:\Python26_32\lib\unittest.py", line 350, in failUnlessEqual
    (msg or '%r != %r' % (first, second))
AssertionError: 1979033151 != -3850693964765720575L

@mgedmin mgedmin reopened this Apr 10, 2015
@mgedmin
Copy link
Member

mgedmin commented Apr 10, 2015

The 1st failure (test_hash_equal_constants) is the same as before. The failure in test_hash_equal is gone. The failure in test_py_hash_32_64_bit is new.

@jamadden
Copy link
Member

In test_py_hash_32_64_bit, I probably need to directly call __hash__ to avoid the interpreter's built-in truncating of the 64-bit value.

As for the constants, sorry I missed those the first time around. I obviously calculated those based on a 64-bit platform. What if we skip that test on a 32-bit platform?

@jamadden
Copy link
Member

By the way, these failures don't go to the "zope-dev" mailing list, like, for example, the zope.toolkit failures do. Is there some other list they go to so I could catch them earlier?

@jamadden
Copy link
Member

I found a 32-bit Python to test on, so hopefully PR #23 should really do it.

@mgedmin
Copy link
Member

mgedmin commented Apr 10, 2015

The failures go to zope-tests@zope.org, and then a daily summary is sent to zope-dev@zope.org (but it's basically delayed by a whole day). I use this script to analyze the daily summaries in a non-painful way.

@jamadden
Copy link
Member

Thank you.

fabiomaggio pushed a commit to fabiomaggio/persistent that referenced this issue Feb 20, 2017
fabiomaggio pushed a commit to fabiomaggio/persistent that referenced this issue Feb 20, 2017
fabiomaggio pushed a commit to fabiomaggio/persistent that referenced this issue Feb 20, 2017
fabiomaggio pushed a commit to fabiomaggio/persistent that referenced this issue Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants