[1/2] framework/tests: Add tests for recompressing results

Submitted by Dylan Baker on Aug. 21, 2015, 8:08 p.m.

Details

Message ID 1440187684-13391-1-git-send-email-baker.dylan.c@gmail.com
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Dylan Baker Aug. 21, 2015, 8:08 p.m.
These tests demonstrate a bug that hasn't yet been exposed to users, but
will be exposed if the json version is ever bumped.

The bug results in a compression suffix being added to a result file
that already has a compression suffix, even one with the same suffix.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
---
 framework/tests/compressed_backend_tests.py | 33 +++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Patch hide | download patch | download mbox

diff --git a/framework/tests/compressed_backend_tests.py b/framework/tests/compressed_backend_tests.py
index b345ef2..e7cf2cb 100644
--- a/framework/tests/compressed_backend_tests.py
+++ b/framework/tests/compressed_backend_tests.py
@@ -247,3 +247,36 @@  def test_xz_shell_override():
 
     with compression.COMPRESSORS['xz']('foo.json') as f:
         f.write('foobar')
+
+
+@utils.set_piglit_conf(('core', 'compression', 'bz2'))
+def test_write_compressed_one_suffix_bz2():
+    """backends.abstract.write_compressed: Does not duplicate compression suffixes
+    """
+    with utils.tempdir() as d:
+        with abstract.write_compressed(os.path.join(d, 'results.txt.bz2')) as f:
+            f.write('foo')
+
+        nt.eq_(os.listdir(d)[0], 'results.txt.bz2')
+
+
+@utils.set_piglit_conf(('core', 'compression', 'gz'))
+def test_write_compressed_one_suffix_gz():
+    """backends.abstract.write_compressed: Does not duplicate compression suffixes
+    """
+    with utils.tempdir() as d:
+        with abstract.write_compressed(os.path.join(d, 'results.txt.gz')) as f:
+            f.write('foo')
+
+        nt.eq_(os.listdir(d)[0], 'results.txt.gz')
+
+
+@utils.set_piglit_conf(('core', 'compression', 'gz'))
+def test_write_compressed_one_suffix_mixed():
+    """backends.abstract.write_compressed: Does not duplicate compression suffixes
+    """
+    with utils.tempdir() as d:
+        with abstract.write_compressed(os.path.join(d, 'results.txt.bz2')) as f:
+            f.write('foo')
+
+        nt.eq_(os.listdir(d)[0], 'results.txt.gz')