7
7
import pickle
8
8
import random
9
9
import sys
10
- from test .support import bigmemtest , _1G , _4G , skip_on_s390x
10
+ from test .support import bigmemtest , _1G , _4G , is_s390x
11
11
12
12
13
13
zlib = import_helper .import_module ('zlib' )
@@ -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,8 +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.
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
+
63
66
64
67
class VersionTestCase (unittest .TestCase ):
65
68
@@ -224,12 +227,14 @@ def test_keywords(self):
224
227
bufsize = zlib .DEF_BUF_SIZE ),
225
228
HAMLET_SCENE )
226
229
227
- @skip_on_s390x
228
230
def test_speech128 (self ):
229
231
# compress more data
230
232
data = HAMLET_SCENE * 128
231
233
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 )
233
238
for ob in x , bytearray (x ):
234
239
self .assertEqual (zlib .decompress (ob ), data )
235
240
@@ -276,7 +281,6 @@ def test_64bit_compress(self, size):
276
281
277
282
class CompressObjectTestCase (BaseCompressTestCase , unittest .TestCase ):
278
283
# Test compression object
279
- @skip_on_s390x
280
284
def test_pair (self ):
281
285
# straightforward compress/decompress objects
282
286
datasrc = HAMLET_SCENE * 128
@@ -287,7 +291,10 @@ def test_pair(self):
287
291
x1 = co .compress (data )
288
292
x2 = co .flush ()
289
293
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 )
291
298
for v1 , v2 in ((x1 , x2 ), (bytearray (x1 ), bytearray (x2 ))):
292
299
dco = zlib .decompressobj ()
293
300
y1 = dco .decompress (v1 + v2 )
0 commit comments