77import pickle
88import random
99import sys
10- from test .support import bigmemtest , _1G , _4G , skip_on_s390x
10+ from test .support import bigmemtest , _1G , _4G , is_s390x
1111
1212
1313zlib = import_helper .import_module ('zlib' )
@@ -34,8 +34,9 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
3434ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple ()
3535
3636
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.
3940# Simplified test_pair() code:
4041#
4142# def func1(data):
@@ -58,8 +59,10 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
5859#
5960# zlib.decompress(func1(data)) == zlib.decompress(func2(data)) == data
6061#
61- # Make the assumption that s390x always has an accelerator to simplify the skip
62- # condition.
62+ # To simplify the skip condition, make the assumption that s390x always has an
63+ # accelerator, and nothing else has it.
64+ HW_ACCELERATED = is_s390x
65+
6366
6467class VersionTestCase (unittest .TestCase ):
6568
@@ -224,12 +227,14 @@ def test_keywords(self):
224227 bufsize = zlib .DEF_BUF_SIZE ),
225228 HAMLET_SCENE )
226229
227- @skip_on_s390x
228230 def test_speech128 (self ):
229231 # compress more data
230232 data = HAMLET_SCENE * 128
231233 x = zlib .compress (data )
232- self .assertEqual (zlib .compress (bytearray (data )), x )
234+ # With hardware acceleration, the compressed bytes
235+ # might not be identical.
236+ if not HW_ACCELERATED :
237+ self .assertEqual (zlib .compress (bytearray (data )), x )
233238 for ob in x , bytearray (x ):
234239 self .assertEqual (zlib .decompress (ob ), data )
235240
@@ -276,7 +281,6 @@ def test_64bit_compress(self, size):
276281
277282class CompressObjectTestCase (BaseCompressTestCase , unittest .TestCase ):
278283 # Test compression object
279- @skip_on_s390x
280284 def test_pair (self ):
281285 # straightforward compress/decompress objects
282286 datasrc = HAMLET_SCENE * 128
@@ -287,7 +291,10 @@ def test_pair(self):
287291 x1 = co .compress (data )
288292 x2 = co .flush ()
289293 self .assertRaises (zlib .error , co .flush ) # second flush should not work
290- self .assertEqual (x1 + x2 , datazip )
294+ # With hardware acceleration, the compressed bytes might not
295+ # be identical.
296+ if not HW_ACCELERATED :
297+ self .assertEqual (x1 + x2 , datazip )
291298 for v1 , v2 in ((x1 , x2 ), (bytearray (x1 ), bytearray (x2 ))):
292299 dco = zlib .decompressobj ()
293300 y1 = dco .decompress (v1 + v2 )
0 commit comments