Commit 2590bb82 authored by Dylan Baker's avatar Dylan Baker
Browse files

framework: add support for bz2 compression.

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: default avatarDylan Baker <>
parent 54bf9304
......@@ -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
# TODO: in python3 the bz2 module has an open function
DEFAULT = 'gz'
COMPRESSION_SUFFIXES = ['.gz', '.bz2']
DEFAULT = 'bz2'
'bz2': functools.partial(bz2.BZ2File, mode='w'),
'gz': functools.partial(, mode='w'),
'none': functools.partial(open, mode='w'),
'bz2': functools.partial(bz2.BZ2File, mode='r'),
'gz': functools.partial(, mode='r'),
'none': functools.partial(open, mode='r'),
......@@ -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')
def test_compress_bz2():
"""framework.backends.compression: can compress to 'bz2'"""
def test_decompress_bz2():
"""framework.backends.compression: can decompress from 'bz2'"""
def test_bz2_output():
"""framework.backends: when using bz2 compression a bz2 file is created"""
nt.eq_(_test_extension(), '.bz2')
......@@ -110,10 +110,10 @@ run_test=./%(test_name)s
; -b/--backend
; Set the default compression method to use,
; May be one of: 'none', 'gz'
; Default: 'gz'
; Set the default compression method to use for results
; May be one of: 'none', 'gz', 'bz2'
; Default: 'bz2'
; Provide a list of test names that are expected to fail. These tests
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment