Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cc5a225

Browse filesBrowse files
authored
gh-125041: test_zlib: For s390x HW acceleration, only skip checking the compressed bytes (#125042)
1 parent fcef3fc commit cc5a225
Copy full SHA for cc5a225

File tree

Expand file treeCollapse file tree

3 files changed

+22
-12
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+22
-12
lines changed

‎Lib/test/support/__init__.py

Copy file name to clipboardExpand all lines: Lib/test/support/__init__.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,9 +2625,9 @@ def exceeds_recursion_limit():
26252625
return get_c_recursion_limit() * 3
26262626

26272627

2628-
#Windows doesn't have os.uname() but it doesn't support s390x.
2629-
skip_on_s390x = unittest.skipIf(hasattr(os, 'uname') and os.uname().machine == 's390x',
2630-
'skipped on s390x')
2628+
# Windows doesn't have os.uname() but it doesn't support s390x.
2629+
is_s390x = hasattr(os, 'uname') and os.uname().machine == 's390x'
2630+
skip_on_s390x = unittest.skipIf(is_s390x, 'skipped on s390x')
26312631

26322632
Py_TRACE_REFS = hasattr(sys, 'getobjects')
26332633

‎Lib/test/test_zlib.py

Copy file name to clipboardExpand all lines: Lib/test/test_zlib.py
+16-9Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pickle
77
import random
88
import sys
9-
from test.support import bigmemtest, _1G, _4G, skip_on_s390x
9+
from test.support import bigmemtest, _1G, _4G, is_s390x
1010

1111

1212
zlib = import_helper.import_module('zlib')
@@ -33,8 +33,9 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
3333
ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple()
3434

3535

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+
# bpo-46623: When a hardware accelerator is used (currently only on s390x),
37+
# using different ways to compress data with zlib can produce different
38+
# compressed data.
3839
# Simplified test_pair() code:
3940
#
4041
# def func1(data):
@@ -57,8 +58,10 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
5758
#
5859
# zlib.decompress(func1(data)) == zlib.decompress(func2(data)) == data
5960
#
60-
# Make the assumption that s390x always has an accelerator to simplify the skip
61-
# condition.
61+
# To simplify the skip condition, make the assumption that s390x always has an
62+
# accelerator, and nothing else has it.
63+
HW_ACCELERATED = is_s390x
64+
6265

6366
class VersionTestCase(unittest.TestCase):
6467

@@ -223,12 +226,14 @@ def test_keywords(self):
223226
bufsize=zlib.DEF_BUF_SIZE),
224227
HAMLET_SCENE)
225228

226-
@skip_on_s390x
227229
def test_speech128(self):
228230
# compress more data
229231
data = HAMLET_SCENE * 128
230232
x = zlib.compress(data)
231-
self.assertEqual(zlib.compress(bytearray(data)), x)
233+
# With hardware acceleration, the compressed bytes
234+
# might not be identical.
235+
if not HW_ACCELERATED:
236+
self.assertEqual(zlib.compress(bytearray(data)), x)
232237
for ob in x, bytearray(x):
233238
self.assertEqual(zlib.decompress(ob), data)
234239

@@ -275,7 +280,6 @@ def test_64bit_compress(self, size):
275280

276281
class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
277282
# Test compression object
278-
@skip_on_s390x
279283
def test_pair(self):
280284
# straightforward compress/decompress objects
281285
datasrc = HAMLET_SCENE * 128
@@ -286,7 +290,10 @@ def test_pair(self):
286290
x1 = co.compress(data)
287291
x2 = co.flush()
288292
self.assertRaises(zlib.error, co.flush) # second flush should not work
289-
self.assertEqual(x1 + x2, datazip)
293+
# With hardware acceleration, the compressed bytes might not
294+
# be identical.
295+
if not HW_ACCELERATED:
296+
self.assertEqual(x1 + x2, datazip)
290297
for v1, v2 in ((x1, x2), (bytearray(x1), bytearray(x2))):
291298
dco = zlib.decompressobj()
292299
y1 = dco.decompress(v1 + v2)
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Re-enable skipped tests for :mod:`zlib` on the s390x architecture: only skip
2+
checks of the compressed bytes, which can be different between zlib's
3+
software implementation and the hardware-accelerated implementation.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.