1#!/usr/bin/env bash
2#
3# Roundtrip test for the brotli command-line tool.
4#
5# The first argument may be a wrapper for brotli, such as 'qemu-arm'.
6
7set -o errexit
8
9BROTLI_WRAPPER=$1
10BROTLI="${BROTLI_WRAPPER} bin/brotli"
11TMP_DIR=bin/tmp
12INPUTS="""
13tests/testdata/alice29.txt
14tests/testdata/asyoulik.txt
15tests/testdata/lcet10.txt
16tests/testdata/plrabn12.txt
17c/enc/encode.c
18c/common/dictionary.h
19c/dec/decode.c
20"""
21
22for file in $INPUTS; do
23  for quality in 1 6 9 11; do
24    echo "Roundtrip testing $file at quality $quality"
25    compressed=${TMP_DIR}/${file##*/}.br
26    uncompressed=${TMP_DIR}/${file##*/}.unbr
27    $BROTLI -fq $quality $file -o $compressed
28    $BROTLI $compressed -fdo $uncompressed
29    diff -q $file $uncompressed
30    # Test the streaming version
31    cat $file | $BROTLI -cq $quality | $BROTLI -cd >$uncompressed
32    diff -q $file $uncompressed
33  done
34done
35