[Piglit] [PATCH v3 3/3] framework: add support for bz2 compression.

Ilia Mirkin imirkin at alum.mit.edu
Mon Jun 29 16:34:46 PDT 2015


Seems easy enough to just add a generic "run shell command X"
compressor/decompressor... I always xz -9 piglit files, it gets
*great* compression.

On Mon, Jun 29, 2015 at 7:27 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> This adds bzip2 compression support to piglit. This produces a file that
> is ~5% the size of the original uncompressed json file.
>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>  framework/backends/compression.py           |  9 +++++++--
>  framework/tests/compressed_backend_tests.py | 11 +++++++++++
>  piglit.conf.example                         |  8 ++++----
>  3 files changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/framework/backends/compression.py b/framework/backends/compression.py
> index 1bda991..71e4716 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 4a7db75..d2ed20f 100644
> --- a/framework/tests/compressed_backend_tests.py
> +++ b/framework/tests/compressed_backend_tests.py
> @@ -77,3 +77,14 @@ def test_compress_gz():
>  def test_decompress_gz():
>      """framework.backends.compression: can decompress from 'gz'"""
>      _test_decompressor('gz')
> +
> +
> + at 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')
> 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.3
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list