• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  if [ -f $file ]; then
24    for quality in 1 6 9 11; do
25      echo "Roundtrip testing $file at quality $quality"
26      compressed=${TMP_DIR}/${file##*/}.br
27      uncompressed=${TMP_DIR}/${file##*/}.unbr
28      $BROTLI -fq $quality $file -o $compressed
29      $BROTLI $compressed -fdo $uncompressed
30      diff -q $file $uncompressed
31      # Test the streaming version
32      cat $file | $BROTLI -cq $quality | $BROTLI -cd >$uncompressed
33      diff -q $file $uncompressed
34    done
35  fi
36done
37