Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitbbe8756

Browse files
authored
[3.9]gh-125041:gh-90781: test_zlib: For s390x HW acceleration, skip checking the compressed bytes (GH-125042) (#125587)
This backports two commits:-GH-31096 skipped the tests unconditionally-GH-125042 skips only the possibly-failing assertion(cherry picked from commit d522856)
1 parenteb16397 commitbbe8756

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

‎Lib/test/test_zlib.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
fromtestimportsupport
33
importbinascii
44
importcopy
5+
importos
56
importpickle
67
importrandom
78
importsys
@@ -30,6 +31,16 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
3031
ZLIB_RUNTIME_VERSION_TUPLE=_zlib_runtime_version_tuple()
3132

3233

34+
# bpo-46623: When a hardware accelerator is used (currently only on s390x),
35+
# using different ways to compress data with zlib can produce different
36+
# compressed data.
37+
#
38+
# To simplify the skip condition, make the assumption that s390x always has an
39+
# accelerator, and nothing else has it.
40+
# Windows doesn't have os.uname() but it doesn't support s390x.
41+
HW_ACCELERATED=hasattr(os,'uname')andos.uname().machine=='s390x'
42+
43+
3344
classVersionTestCase(unittest.TestCase):
3445

3546
deftest_library_version(self):
@@ -191,7 +202,10 @@ def test_speech128(self):
191202
# compress more data
192203
data=HAMLET_SCENE*128
193204
x=zlib.compress(data)
194-
self.assertEqual(zlib.compress(bytearray(data)),x)
205+
# With hardware acceleration, the compressed bytes
206+
# might not be identical.
207+
ifnotHW_ACCELERATED:
208+
self.assertEqual(zlib.compress(bytearray(data)),x)
195209
forobinx,bytearray(x):
196210
self.assertEqual(zlib.decompress(ob),data)
197211

@@ -248,7 +262,10 @@ def test_pair(self):
248262
x1=co.compress(data)
249263
x2=co.flush()
250264
self.assertRaises(zlib.error,co.flush)# second flush should not work
251-
self.assertEqual(x1+x2,datazip)
265+
# With hardware acceleration, the compressed bytes might not
266+
# be identical.
267+
ifnotHW_ACCELERATED:
268+
self.assertEqual(x1+x2,datazip)
252269
forv1,v2in ((x1,x2), (bytearray(x1),bytearray(x2))):
253270
dco=zlib.decompressobj()
254271
y1=dco.decompress(v1+v2)
Lines 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)

[8]ページ先頭

©2009-2025 Movatter.jp