2015-03-16 17:56:10 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
from __future__ import print_function
|
2015-05-07 20:43:01 +02:00
|
|
|
import glob
|
2015-03-16 17:56:10 +00:00
|
|
|
import sys
|
|
|
|
|
import os
|
2015-03-23 12:09:42 +00:00
|
|
|
from subprocess import check_call
|
2015-03-16 17:56:10 +00:00
|
|
|
|
2015-04-22 17:54:56 +01:00
|
|
|
from test_utils import PYTHON, BRO, TEST_ENV, diff_q
|
2015-03-16 17:56:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
os.chdir(os.path.abspath("../../tests"))
|
2015-05-07 20:43:01 +02:00
|
|
|
for filename in glob.glob("testdata/*.compressed*"):
|
2015-03-16 17:56:10 +00:00
|
|
|
filename = os.path.abspath(filename)
|
|
|
|
|
print('Testing decompression of file "%s"' % os.path.basename(filename))
|
2015-05-08 10:06:18 +01:00
|
|
|
expected = filename.split(".compressed")[0]
|
2015-05-07 20:43:01 +02:00
|
|
|
uncompressed = expected + ".uncompressed"
|
2015-04-22 16:49:00 +01:00
|
|
|
check_call([PYTHON, BRO, "-f", "-d", "-i", filename, "-o", uncompressed],
|
|
|
|
|
env=TEST_ENV)
|
2015-03-16 17:56:10 +00:00
|
|
|
if diff_q(uncompressed, expected) != 0:
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
# Test the streaming version
|
2015-03-23 12:09:42 +00:00
|
|
|
with open(filename, "rb") as infile, open(uncompressed, "wb") as outfile:
|
2015-04-22 16:49:00 +01:00
|
|
|
check_call([PYTHON, BRO, '-d'], stdin=infile, stdout=outfile,
|
|
|
|
|
env=TEST_ENV)
|
2015-03-16 17:56:10 +00:00
|
|
|
if diff_q(uncompressed, expected) != 0:
|
|
|
|
|
sys.exit(1)
|
2016-04-10 20:51:10 +01:00
|
|
|
try:
|
|
|
|
|
os.unlink(uncompressed)
|
|
|
|
|
except OSError:
|
|
|
|
|
pass
|