classification
Title: test_hashlib failure on Ubuntu 16.04
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Sachin Kumar, christian.heimes, martin.panter, xiang.zhang
Priority: normal Keywords:

Created on 2017-02-11 21:27 by Sachin Kumar, last changed 2017-02-15 17:59 by christian.heimes. This issue is now closed.

Files
File name Uploaded Description Edit
blake2b.txt Sachin Kumar, 2017-02-15 17:52
Messages (5)
msg287626 - (view) Author: Sachin Kumar (Sachin Kumar) Date: 2017-02-11 21:27
When executing 
./python -m test -v test_hashlib
on Python 3.7, the test fails.

This is the complete traceback:

CPython 3.7.0a0 (default, Feb 8 2017, 03:10:42) [GCC 5.4.0 20160609]
==   Linux-4.4.0-62-generic-x86_64-with-debian-stretch-sid little-endian
==   hash algorithm: siphash24 64bit
==  cwd: /XXX/build/test_python_14437
==  encodings: locale=UTF-8, FS=utf-8
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
Run tests sequentially
0:00:00 [1/1] test_hashlib
test_algorithms_available (test.test_hashlib.HashLibTestCase) ... ok
test_algorithms_guaranteed (test.test_hashlib.HashLibTestCase) ... ok
test_blake2b (test.test_hashlib.HashLibTestCase) ... ok
test_blake2b_vectors (test.test_hashlib.HashLibTestCase) ... ERROR
test_blake2s (test.test_hashlib.HashLibTestCase) ... ok
test_blake2s_vectors (test.test_hashlib.HashLibTestCase) ... ERROR
test_blocksize_name (test.test_hashlib.HashLibTestCase) ... ok
test_blocksize_name_blake2 (test.test_hashlib.HashLibTestCase) ... ok
test_blocksize_name_sha3 (test.test_hashlib.HashLibTestCase) ... ok
test_case_blake2b_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_blake2b_1 (test.test_hashlib.HashLibTestCase) ... ok
test_case_blake2s_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_blake2s_1 (test.test_hashlib.HashLibTestCase) ... ok
test_case_md5_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_md5_1 (test.test_hashlib.HashLibTestCase) ... ok
test_case_md5_2 (test.test_hashlib.HashLibTestCase) ... ok
test_case_md5_huge (test.test_hashlib.HashLibTestCase) ... skipped 'not enough memory: 4.0G minimum needed'
test_case_md5_uintmax (test.test_hashlib.HashLibTestCase) ... skipped 'not enough memory: 4.0G minimum needed'
test_case_sha1_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha1_1 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha1_2 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha1_3 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha224_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha224_1 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha224_2 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha224_3 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha256_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha256_1 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha256_2 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha256_3 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha384_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha384_1 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha384_2 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha384_3 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha3_224_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha3_224_vector (test.test_hashlib.HashLibTestCase) ... ERROR
test_case_sha3_256_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha3_256_vector (test.test_hashlib.HashLibTestCase) ... ERROR
test_case_sha3_384_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha3_384_vector (test.test_hashlib.HashLibTestCase) ... ERROR
test_case_sha3_512_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha3_512_vector (test.test_hashlib.HashLibTestCase) ... ERROR
test_case_sha512_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha512_1 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha512_2 (test.test_hashlib.HashLibTestCase) ... ok
test_case_sha512_3 (test.test_hashlib.HashLibTestCase) ... ok
test_case_shake128_vector (test.test_hashlib.HashLibTestCase) ... ERROR
test_case_shake256_vector (test.test_hashlib.HashLibTestCase) ... ERROR
test_case_shake_128_0 (test.test_hashlib.HashLibTestCase) ... ok
test_case_shake_256_0 (test.test_hashlib.HashLibTestCase) ... ok
test_extra_sha3 (test.test_hashlib.HashLibTestCase) ... ok
test_get_builtin_constructor (test.test_hashlib.HashLibTestCase) ... ok
test_gil (test.test_hashlib.HashLibTestCase) ... ok
test_hash_array (test.test_hashlib.HashLibTestCase) ... ok
test_hexdigest (test.test_hashlib.HashLibTestCase) ... ok
test_large_update (test.test_hashlib.HashLibTestCase) ... ok
test_name_attribute (test.test_hashlib.HashLibTestCase) ... ok
test_no_unicode (test.test_hashlib.HashLibTestCase) ... ok
test_no_unicode_blake2 (test.test_hashlib.HashLibTestCase) ... ok
test_no_unicode_sha3 (test.test_hashlib.HashLibTestCase) ... ok
test_threaded_hashing (test.test_hashlib.HashLibTestCase) ... ok
test_unknown_hash (test.test_hashlib.HashLibTestCase) ... ok
test_pbkdf2_hmac_c (test.test_hashlib.KDFTests) ... ok
test_pbkdf2_hmac_py (test.test_hashlib.KDFTests) ... ok
test_scrypt (test.test_hashlib.KDFTests) ... skipped '   test requires OpenSSL > 1.1'

======================================================================
ERROR: test_blake2b_vectors (test.test_hashlib.HashLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/XXX/Lib/test/test_hashlib.py", line 623, in test_blake2b_vectors
    for msg, key, md in read_vectors('blake2b'):
  File "/XXX/Lib/test/test_hashlib.py", line 69, in read_vectors
    parts[0] = bytes.fromhex(parts[0])
ValueError: non-hexadecimal number found in fromhex() arg at position 0

======================================================================
ERROR: test_blake2s_vectors (test.test_hashlib.HashLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/XXX/Lib/test/test_hashlib.py", line 648, in test_blake2s_vectors
    for msg, key, md in read_vectors('blake2s'):
  File "/XXX/Lib/test/test_hashlib.py", line 69, in read_vectors
    parts[0] = bytes.fromhex(parts[0])
ValueError: non-hexadecimal number found in fromhex() arg at position 0

======================================================================
ERROR: test_case_sha3_224_vector (test.test_hashlib.HashLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/XXX/Lib/test/test_hashlib.py", line 659, in test_case_sha3_224_vector
    for msg, md in read_vectors('sha3_224'):
  File "/XXX/Lib/test/test_hashlib.py", line 69, in read_vectors
    parts[0] = bytes.fromhex(parts[0])
ValueError: non-hexadecimal number found in fromhex() arg at position 0

======================================================================
ERROR: test_case_sha3_256_vector (test.test_hashlib.HashLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/XXX/Lib/test/test_hashlib.py", line 669, in test_case_sha3_256_vector
    for msg, md in read_vectors('sha3_256'):
  File "/XXX/Lib/test/test_hashlib.py", line 69, in read_vectors
    parts[0] = bytes.fromhex(parts[0])
ValueError: non-hexadecimal number found in fromhex() arg at position 0

======================================================================
ERROR: test_case_sha3_384_vector (test.test_hashlib.HashLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/XXX/Lib/test/test_hashlib.py", line 680, in test_case_sha3_384_vector
    for msg, md in read_vectors('sha3_384'):
  File "/XXX/Lib/test/test_hashlib.py", line 69, in read_vectors
    parts[0] = bytes.fromhex(parts[0])
ValueError: non-hexadecimal number found in fromhex() arg at position 0

======================================================================
ERROR: test_case_sha3_512_vector (test.test_hashlib.HashLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/XXX/Lib/test/test_hashlib.py", line 691, in test_case_sha3_512_vector
    for msg, md in read_vectors('sha3_512'):
  File "/XXX/Lib/test/test_hashlib.py", line 69, in read_vectors
    parts[0] = bytes.fromhex(parts[0])
ValueError: non-hexadecimal number found in fromhex() arg at position 0

======================================================================
ERROR: test_case_shake128_vector (test.test_hashlib.HashLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/XXX/Lib/test/test_hashlib.py", line 703, in test_case_shake128_vector
    for msg, md in read_vectors('shake_128'):
  File "/XXX/Lib/test/test_hashlib.py", line 69, in read_vectors
    parts[0] = bytes.fromhex(parts[0])
ValueError: non-hexadecimal number found in fromhex() arg at position 0

======================================================================
ERROR: test_case_shake256_vector (test.test_hashlib.HashLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/XXX/Lib/test/test_hashlib.py", line 715, in test_case_shake256_vector
    for msg, md in read_vectors('shake_256'):
  File "/XXX/Lib/test/test_hashlib.py", line 69, in read_vectors
    parts[0] = bytes.fromhex(parts[0])
ValueError: non-hexadecimal number found in fromhex() arg at position 0

----------------------------------------------------------------------
Ran 65 tests in 0.877s

FAILED (errors=8, skipped=3)
test test_hashlib failed
test_hashlib failed

1 test failed:
    test_hashlib

Total duration: 1 sec
Tests result: FAILURE
msg287815 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-02-15 04:02
I am using 16.10 but I can't reproduce the failures. Sachin can you reliably reproduce the failures? And one thing interesting is that all the failed test cases need the network source to be enabled but your command doesn't do that, it's better to use ./python -m test -uall -v test_hashlib.
msg287825 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-02-15 08:09
Looks like the tests should run if the data is already downloaded. First run needs -u urlfetch. My guess is your data is somehow corrupted. Check out your copy of the files in Lib/test/data/, compare them to e.g. <http://www.pythontest.net/hashlib/blake2b.txt>. If you delete the files and re-run the test, you should get a fresh copy.

If my theory is correct, I wonder how the data got corrupted.
msg287874 - (view) Author: Sachin Kumar (Sachin Kumar) Date: 2017-02-15 17:52
@Xiang
I tried that command earlier but that returned around 8 failed test cases. I think it is due to a fault with my connection. Although I can replicate this error every time. I've tried over 5 times already.


@Martin
I compared the data. My file has been attached. Deleting the files fixed the issue. Can all the test files be deleted safely, since some other tests are failing too?
msg287876 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2017-02-15 17:59
Yeah, somehow you ended up with a broken vector file. Your file contains HTTP with JavaScript redirect. Did you attempt to download test data from a hotel or airport wifi?

You can safely remove Lib/test/data and start over.
History
Date User Action Args
2017-02-15 17:59:11christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg287876

resolution: not a bug
stage: resolved
2017-02-15 17:52:27Sachin Kumarsetfiles: + blake2b.txt

messages: + msg287874
2017-02-15 08:09:49martin.pantersetnosy: + martin.panter
messages: + msg287825
2017-02-15 04:02:43xiang.zhangsetnosy: + xiang.zhang
messages: + msg287815
2017-02-11 21:27:48Sachin Kumarcreate