brotli/tests/roundtrip_test.sh

37 lines
921 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2014-10-30 12:59:37 +00:00
#
# Roundtrip test for the brotli command-line tool.
#
# The first argument may be a wrapper for brotli, such as 'qemu-arm'.
2014-10-30 12:59:37 +00:00
set -o errexit
BROTLI_WRAPPER=$1
BROTLI="${BROTLI_WRAPPER} bin/brotli"
2016-06-24 13:32:51 +00:00
TMP_DIR=bin/tmp
2014-10-30 12:59:37 +00:00
INPUTS="""
2016-06-24 13:32:51 +00:00
tests/testdata/alice29.txt
tests/testdata/asyoulik.txt
tests/testdata/lcet10.txt
tests/testdata/plrabn12.txt
c/enc/encode.c
c/common/dictionary.h
c/dec/decode.c
2014-10-30 12:59:37 +00:00
"""
for file in $INPUTS; do
2020-08-26 15:13:31 +00:00
if [ -f $file ]; then
for quality in 1 6 9 11; do
echo "Roundtrip testing $file at quality $quality"
compressed=${TMP_DIR}/${file##*/}.br
uncompressed=${TMP_DIR}/${file##*/}.unbr
$BROTLI -fq $quality $file -o $compressed
$BROTLI $compressed -fdo $uncompressed
diff -q $file $uncompressed
# Test the streaming version
cat $file | $BROTLI -cq $quality | $BROTLI -cd >$uncompressed
diff -q $file $uncompressed
done
fi
2014-10-30 12:59:37 +00:00
done