Skip to content

Commit d16c9c7

Browse files
committed
skip two test_zlib tests failing on s390x
Code is originally from gh#python/cpython!31096, it was released upstream in 3.11.0. Fixes: gh#python#90781 Fixes: bpo-46623 Patch: bpo-46623-skip-zlib-s390x.patch
1 parent 938ff8a commit d16c9c7

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Lib/test/test_zlib.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22
from test import support
33
import binascii
4+
import os
45
import pickle
56
import random
67
import sys
@@ -15,6 +16,37 @@
1516
hasattr(zlib.decompressobj(), "copy"),
1617
'requires Decompress.copy()')
1718

19+
# bpo-46623: On s390x, when a hardware accelerator is used, using different
20+
# ways to compress data with zlib can produce different compressed data.
21+
# Simplified test_pair() code:
22+
#
23+
# def func1(data):
24+
# return zlib.compress(data)
25+
#
26+
# def func2(data)
27+
# co = zlib.compressobj()
28+
# x1 = co.compress(data)
29+
# x2 = co.flush()
30+
# return x1 + x2
31+
#
32+
# On s390x if zlib uses a hardware accelerator, func1() creates a single
33+
# "final" compressed block whereas func2() produces 3 compressed blocks (the
34+
# last one is a final block). On other platforms with no accelerator, func1()
35+
# and func2() produce the same compressed data made of a single (final)
36+
# compressed block.
37+
#
38+
# Only the compressed data is different, the decompression returns the original
39+
# data:
40+
#
41+
# zlib.decompress(func1(data)) == zlib.decompress(func2(data)) == data
42+
#
43+
# Make the assumption that s390x always has an accelerator to simplify the skip
44+
# condition. Windows doesn't have os.uname() but it doesn't support s390x.
45+
skip_on_s390x = unittest.skipIf(
46+
hasattr(os, 'uname') and
47+
os.uname().machine in ['s390x', 's390'],
48+
'skipped on s390x')
49+
1850

1951
class VersionTestCase(unittest.TestCase):
2052

@@ -174,6 +206,7 @@ def test_keywords(self):
174206
bufsize=zlib.DEF_BUF_SIZE),
175207
HAMLET_SCENE)
176208

209+
@skip_on_s390x
177210
def test_speech128(self):
178211
# compress more data
179212
data = HAMLET_SCENE * 128
@@ -225,6 +258,7 @@ def test_64bit_compress(self, size):
225258

226259
class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
227260
# Test compression object
261+
@skip_on_s390x
228262
def test_pair(self):
229263
# straightforward compress/decompress objects
230264
datasrc = HAMLET_SCENE * 128
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Skip test_pair() and test_speech128() of test_zlib on s390x since they fail
2+
if zlib uses the s390x hardware accelerator. Patch by Victor Stinner.

0 commit comments

Comments
 (0)