@@ -34,8 +34,9 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
34
34
ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple ()
35
35
36
36
37
- # bpo-46623: On s390x, when a hardware accelerator is used, using different
38
- # ways to compress data with zlib can produce different compressed data.
37
+ # bpo-46623: When a hardware accelerator is used (currently only on s390x),
38
+ # using different ways to compress data with zlib can produce different
39
+ # compressed data.
39
40
# Simplified test_pair() code:
40
41
#
41
42
# def func1(data):
@@ -58,10 +59,10 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
58
59
#
59
60
# zlib.decompress(func1(data)) == zlib.decompress(func2(data)) == data
60
61
#
61
- # Make the assumption that s390x always has an accelerator to simplify the skip
62
- # condition. Windows doesn't have os.uname() but it doesn't support s390x .
63
- skip_on_s390x = unittest . skipIf ( hasattr ( os , 'uname' ) and os .uname (). machine == ' s390x' ,
64
- 'skipped on s390x')
62
+ # To simplify the skip condition, make the assumption that s390x always has an
63
+ # accelerator, and nothing else has it .
64
+ # Windows doesn't have os.uname() but it doesn't support s390x.
65
+ HW_ACCELERATED = hasattr ( os , 'uname' ) and os . uname (). machine == ' s390x'
65
66
66
67
67
68
class VersionTestCase (unittest .TestCase ):
@@ -227,12 +228,14 @@ def test_keywords(self):
227
228
bufsize = zlib .DEF_BUF_SIZE ),
228
229
HAMLET_SCENE )
229
230
230
- @skip_on_s390x
231
231
def test_speech128 (self ):
232
232
# compress more data
233
233
data = HAMLET_SCENE * 128
234
234
x = zlib .compress (data )
235
- self .assertEqual (zlib .compress (bytearray (data )), x )
235
+ # With hardware acceleration, the compressed bytes
236
+ # might not be identical.
237
+ if not HW_ACCELERATED :
238
+ self .assertEqual (zlib .compress (bytearray (data )), x )
236
239
for ob in x , bytearray (x ):
237
240
self .assertEqual (zlib .decompress (ob ), data )
238
241
@@ -279,7 +282,6 @@ def test_64bit_compress(self, size):
279
282
280
283
class CompressObjectTestCase (BaseCompressTestCase , unittest .TestCase ):
281
284
# Test compression object
282
- @skip_on_s390x
283
285
def test_pair (self ):
284
286
# straightforward compress/decompress objects
285
287
datasrc = HAMLET_SCENE * 128
@@ -290,7 +292,10 @@ def test_pair(self):
290
292
x1 = co .compress (data )
291
293
x2 = co .flush ()
292
294
self .assertRaises (zlib .error , co .flush ) # second flush should not work
293
- self .assertEqual (x1 + x2 , datazip )
295
+ # With hardware acceleration, the compressed bytes might not
296
+ # be identical.
297
+ if not HW_ACCELERATED :
298
+ self .assertEqual (x1 + x2 , datazip )
294
299
for v1 , v2 in ((x1 , x2 ), (bytearray (x1 ), bytearray (x2 ))):
295
300
dco = zlib .decompressobj ()
296
301
y1 = dco .decompress (v1 + v2 )
0 commit comments