Example #1
0
testdata/quickfox.compressed
testdata/ukkonooa.compressed
testdata/monkey.compressed
testdata/backward65536.compressed
testdata/zeros.compressed
testdata/quickfox_repeated.compressed
testdata/compressed_file.compressed
testdata/compressed_repeated.compressed
testdata/alice29.txt.compressed
testdata/asyoulik.txt.compressed
testdata/lcet10.txt.compressed
testdata/plrabn12.txt.compressed
"""

os.chdir(os.path.abspath("../../tests"))
for filename in INPUTS.splitlines():
    filename = os.path.abspath(filename)
    print('Testing decompression of file "%s"' % os.path.basename(filename))
    uncompressed = os.path.splitext(filename)[0] + ".uncompressed"
    expected = os.path.splitext(filename)[0]
    check_call([PYTHON, BRO, "-f", "-d", "-i", filename, "-o", uncompressed],
               env=TEST_ENV)
    if diff_q(uncompressed, expected) != 0:
        sys.exit(1)
    # Test the streaming version
    with open(filename, "rb") as infile, open(uncompressed, "wb") as outfile:
        check_call([PYTHON, BRO, '-d'], stdin=infile, stdout=outfile,
                   env=TEST_ENV)
    if diff_q(uncompressed, expected) != 0:
        sys.exit(1)
""" % BRO

os.chdir(os.path.abspath("../../tests"))
for filename in INPUTS.splitlines():
    for quality in (1, 6, 9, 11):
        for lgwin in (10, 15, 20, 24):
            filename = os.path.abspath(filename)
            print(
                'Roundtrip testing file "%s" at quality %d with lg(win)=%d and auto-custom-dictionary'
                % (os.path.basename(filename), quality, lgwin))
            compressed = os.path.splitext(filename)[0] + ".custom_bro"
            uncompressed = os.path.splitext(filename)[0] + ".custom_unbro"
            check_call([
                PYTHON, BRO, "-f", "-q",
                str(quality), "-i", filename, "-o", compressed, "--lgwin",
                str(lgwin), "--custom-dictionary", filename
            ],
                       env=TEST_ENV)
            check_call([
                PYTHON, BRO, "-f", "-d", "-i", compressed, "-o", uncompressed,
                "--custom-dictionary", filename
            ],
                       env=TEST_ENV)
            if diff_q(filename, uncompressed) != 0:
                sys.exit(1)
            try:
                os.unlink(compressed)
                os.unlink(uncompressed)
            except OSError:
                pass
Example #3
0
%s
""" % LZCOMP


start = time.time()
for filename in INPUTS.splitlines():
    print('Roundtrip testing of file "%s"' % os.path.basename(filename))
    compressed = os.path.splitext(filename)[0] + ".comp"
    uncompressed = os.path.splitext(filename)[0] + ".decomp"
    comp_start = time.time()
    check_call([PYTHON, LZCOMP, "-f", "-i", filename, "-o", compressed],
               env=TEST_ENV)
    print("--- compression: %s seconds ---" % (time.time() - comp_start))
    decomp_start = time.time()
    check_call([PYTHON, LZCOMP, "-f", "-d", "-i", compressed, "-o",
                uncompressed], env=TEST_ENV)
    print("--- decompression: %s seconds ---" % (time.time() - decomp_start))
    if diff_q(filename, uncompressed) != 0:
        sys.exit(1)
    # Test the streaming version
    with open(filename, "rb") as infile, open(uncompressed, "wb") as outfile:
        p = Popen([PYTHON, LZCOMP], stdin=infile, stdout=PIPE, env=TEST_ENV)
        check_call([PYTHON, LZCOMP, "-d"], stdin=p.stdout, stdout=outfile,
                   env=TEST_ENV)
    if diff_q(filename, uncompressed) != 0:
        sys.exit(1)
    # clean up
    os.remove(compressed)
    os.remove(uncompressed)
print("--- TOTAL: %s seconds ---\n" % (time.time() - start))
Example #4
0
#!/usr/bin/env python
from __future__ import print_function
import glob
import sys
import os
from subprocess import check_call

from test_utils import PYTHON, BRO, TEST_ENV, diff_q

os.chdir(os.path.abspath("../../tests"))
for filename in glob.glob("testdata/*.compressed*"):
    filename = os.path.abspath(filename)
    print('Testing decompression of file "%s"' % os.path.basename(filename))
    expected = filename.split(".compressed")[0]
    uncompressed = expected + ".uncompressed"
    check_call([PYTHON, BRO, "-f", "-d", "-i", filename, "-o", uncompressed],
               env=TEST_ENV)
    if diff_q(uncompressed, expected) != 0:
        sys.exit(1)
    # Test the streaming version
    with open(filename, "rb") as infile, open(uncompressed, "wb") as outfile:
        check_call([PYTHON, BRO, '-d'],
                   stdin=infile,
                   stdout=outfile,
                   env=TEST_ENV)
    if diff_q(uncompressed, expected) != 0:
        sys.exit(1)
    os.unlink(uncompressed)