6
6
import pickle
7
7
import random
8
8
import sys
9
- from test .support import bigmemtest , _1G , _4G , skip_on_s390x
9
+ from test .support import bigmemtest , _1G , _4G , is_s390x
10
10
11
11
12
12
zlib = import_helper .import_module ('zlib' )
@@ -33,8 +33,10 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
33
33
ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple ()
34
34
35
35
36
- # bpo-46623: On s390x, when a hardware accelerator is used, using different
37
- # ways to compress data with zlib can produce different compressed data.
36
+
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.
38
40
# Simplified test_pair() code:
39
41
#
40
42
# def func1(data):
@@ -57,8 +59,10 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
57
59
#
58
60
# zlib.decompress(func1(data)) == zlib.decompress(func2(data)) == data
59
61
#
60
- # Make the assumption that s390x always has an accelerator to simplify the skip
61
- # 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
+
62
66
63
67
class VersionTestCase (unittest .TestCase ):
64
68
@@ -223,12 +227,14 @@ def test_keywords(self):
223
227
bufsize = zlib .DEF_BUF_SIZE ),
224
228
HAMLET_SCENE )
225
229
226
- @skip_on_s390x
227
230
def test_speech128 (self ):
228
231
# compress more data
229
232
data = HAMLET_SCENE * 128
230
233
x = zlib .compress (data )
231
- self .assertEqual (zlib .compress (bytearray (data )), x )
234
+ if not HW_ACCELERATED :
235
+ # With hardware acceleration, the compressed bytes
236
+ # might not be identical.
237
+ self .assertEqual (zlib .compress (bytearray (data )), x )
232
238
for ob in x , bytearray (x ):
233
239
self .assertEqual (zlib .decompress (ob ), data )
234
240
@@ -275,7 +281,6 @@ def test_64bit_compress(self, size):
275
281
276
282
class CompressObjectTestCase (BaseCompressTestCase , unittest .TestCase ):
277
283
# Test compression object
278
- @skip_on_s390x
279
284
def test_pair (self ):
280
285
# straightforward compress/decompress objects
281
286
datasrc = HAMLET_SCENE * 128
@@ -286,7 +291,10 @@ def test_pair(self):
286
291
x1 = co .compress (data )
287
292
x2 = co .flush ()
288
293
self .assertRaises (zlib .error , co .flush ) # second flush should not work
289
- self .assertEqual (x1 + x2 , datazip )
294
+ if not HW_ACCELERATED :
295
+ # With hardware acceleration, the compressed bytes might not
296
+ # be identical.
297
+ self .assertEqual (x1 + x2 , datazip )
290
298
for v1 , v2 in ((x1 , x2 ), (bytearray (x1 ), bytearray (x2 ))):
291
299
dco = zlib .decompressobj ()
292
300
y1 = dco .decompress (v1 + v2 )
0 commit comments