This adds bzip2 compression support to piglit. This produces a file that is ~5% the size of the original uncompressed json file.
v4: - add more tests Signed-off-by: Dylan Baker <dylanx.c.ba...@intel.com> --- framework/backends/compression.py | 9 +++++++-- framework/tests/compressed_backend_tests.py | 17 +++++++++++++++++ piglit.conf.example | 8 ++++---- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/framework/backends/compression.py b/framework/backends/compression.py index 44b8b9e..153dc94 100644 --- a/framework/backends/compression.py +++ b/framework/backends/compression.py @@ -42,6 +42,7 @@ they're passing unicode and not bytes. """ from __future__ import print_function, absolute_import, division +import bz2 import functools import gzip import os @@ -49,16 +50,20 @@ import os from framework import exceptions from framework.core import PIGLIT_CONFIG -COMPRESSION_SUFFIXES = ['.gz'] +# TODO: in python3 the bz2 module has an open function -DEFAULT = 'gz' +COMPRESSION_SUFFIXES = ['.gz', '.bz2'] + +DEFAULT = 'bz2' COMPRESSORS = { + 'bz2': functools.partial(bz2.BZ2File, mode='w'), 'gz': functools.partial(gzip.open, mode='w'), 'none': functools.partial(open, mode='w'), } DECOMPRESSORS = { + 'bz2': functools.partial(bz2.BZ2File, mode='r'), 'gz': functools.partial(gzip.open, mode='r'), 'none': functools.partial(open, mode='r'), } diff --git a/framework/tests/compressed_backend_tests.py b/framework/tests/compressed_backend_tests.py index 897a154..7af633d 100644 --- a/framework/tests/compressed_backend_tests.py +++ b/framework/tests/compressed_backend_tests.py @@ -201,3 +201,20 @@ def test_decompress_gz(): def test_gz_output(): """framework.backends: when using gz compression a gz file is created""" nt.eq_(_test_extension(), '.gz') + + +@utils.no_error +def test_compress_bz2(): + """framework.backends.compression: can compress to 'bz2'""" + _test_compressor('bz2') + + +def test_decompress_bz2(): + """framework.backends.compression: can decompress from 'bz2'""" + _test_decompressor('bz2') + + +@_set_compression_mode('bz2') +def test_bz2_output(): + """framework.backends: when using bz2 compression a bz2 file is created""" + nt.eq_(_test_extension(), '.bz2') diff --git a/piglit.conf.example b/piglit.conf.example index baf8108..3888fc6 100644 --- a/piglit.conf.example +++ b/piglit.conf.example @@ -110,10 +110,10 @@ run_test=./%(test_name)s ; -b/--backend ;backend=json -; Set the default compression method to use, -; May be one of: 'none', 'gz' -; Default: 'gz' -;compression=gz +; Set the default compression method to use for results +; May be one of: 'none', 'gz', 'bz2' +; Default: 'bz2' +;compression=bz2 [expected-failures] ; Provide a list of test names that are expected to fail. These tests -- 2.4.5 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit