summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_zlib.py')
-rw-r--r--Lib/test/test_zlib.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index ef02c64..8b4bb87 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -6,7 +6,7 @@ import copy
import pickle
import random
import sys
-from test.support import bigmemtest, _1G, _4G, skip_on_s390x
+from test.support import bigmemtest, _1G, _4G, is_s390x
zlib = import_helper.import_module('zlib')
@@ -33,8 +33,9 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple()
-# bpo-46623: On s390x, when a hardware accelerator is used, using different
-# ways to compress data with zlib can produce different compressed data.
+# bpo-46623: When a hardware accelerator is used (currently only on s390x),
+# using different ways to compress data with zlib can produce different
+# compressed data.
# Simplified test_pair() code:
#
# def func1(data):
@@ -57,8 +58,10 @@ ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple()
#
# zlib.decompress(func1(data)) == zlib.decompress(func2(data)) == data
#
-# Make the assumption that s390x always has an accelerator to simplify the skip
-# condition.
+# To simplify the skip condition, make the assumption that s390x always has an
+# accelerator, and nothing else has it.
+HW_ACCELERATED = is_s390x
+
class VersionTestCase(unittest.TestCase):
@@ -223,12 +226,14 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
bufsize=zlib.DEF_BUF_SIZE),
HAMLET_SCENE)
- @skip_on_s390x
def test_speech128(self):
# compress more data
data = HAMLET_SCENE * 128
x = zlib.compress(data)
- self.assertEqual(zlib.compress(bytearray(data)), x)
+ # With hardware acceleration, the compressed bytes
+ # might not be identical.
+ if not HW_ACCELERATED:
+ self.assertEqual(zlib.compress(bytearray(data)), x)
for ob in x, bytearray(x):
self.assertEqual(zlib.decompress(ob), data)
@@ -275,7 +280,6 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
# Test compression object
- @skip_on_s390x
def test_pair(self):
# straightforward compress/decompress objects
datasrc = HAMLET_SCENE * 128
@@ -286,7 +290,10 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
x1 = co.compress(data)
x2 = co.flush()
self.assertRaises(zlib.error, co.flush) # second flush should not work
- self.assertEqual(x1 + x2, datazip)
+ # With hardware acceleration, the compressed bytes might not
+ # be identical.
+ if not HW_ACCELERATED:
+ self.assertEqual(x1 + x2, datazip)
for v1, v2 in ((x1, x2), (bytearray(x1), bytearray(x2))):
dco = zlib.decompressobj()
y1 = dco.decompress(v1 + v2)