Skip to content

bpo-46623: Skip two test_zlib tests on s390x #31096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Lib/test/test_zlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from test.support import import_helper
import binascii
import copy
import os
import pickle
import random
import sys
Expand All @@ -18,6 +19,35 @@
hasattr(zlib.decompressobj(), "copy"),
'requires Decompress.copy()')

# bpo-46623: On s390x, when a hardware accelerator is used, using different
# ways to compress data with zlib can produce different compressed data.
# Simplified test_pair() code:
#
# def func1(data):
# return zlib.compress(data)
#
# def func2(data)
# co = zlib.compressobj()
# x1 = co.compress(data)
# x2 = co.flush()
# return x1 + x2
#
# On s390x if zlib uses a hardware accelerator, func1() creates a single
# "final" compressed block whereas func2() produces 3 compressed blocks (the
# last one is a final block). On other platforms with no accelerator, func1()
# and func2() produce the same compressed data made of a single (final)
# compressed block.
#
# Only the compressed data is different, the decompression returns the original
# data:
#
# zlib.decompress(func1(data)) == zlib.decompress(func2(data)) == data
#
# Make the assumption that s390x always has an accelerator to simplify the skip
# condition. Windows doesn't have os.uname() but it doesn't support s390x.
skip_on_s390x = unittest.skipIf(hasattr(os, 'uname') and os.uname().machine == 's390x',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To implementing Petr's comment suggestion:

Suggested change
skip_on_s390x = unittest.skipIf(hasattr(os, 'uname') and os.uname().machine == 's390x',
def not_s390x():
return not (hasattr(os, 'uname') and os.uname().machine == 's390x')

and replace @skip...s below with if not_s390x: on asserts.

'skipped on s390x')


class VersionTestCase(unittest.TestCase):

Expand Down Expand Up @@ -182,6 +212,7 @@ def test_keywords(self):
bufsize=zlib.DEF_BUF_SIZE),
HAMLET_SCENE)

@skip_on_s390x
def test_speech128(self):
# compress more data
data = HAMLET_SCENE * 128
Expand Down Expand Up @@ -233,6 +264,7 @@ def test_64bit_compress(self, size):

class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
# Test compression object
@skip_on_s390x
def test_pair(self):
# straightforward compress/decompress objects
datasrc = HAMLET_SCENE * 128
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Skip test_pair() and test_speech128() of test_zlib on s390x since they fail
if zlib uses the s390x hardware accelerator. Patch by Victor Stinner.