xref: /aosp_15_r20/external/zlib/contrib/bench/check.sh (revision 86ee64e75fa5f8bce2c8c356138035642429cd05)
1#!/bin/bash
2#
3# Copyright 2022 The Chromium Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the chromium source repository LICENSE file.
6#
7# Given a zlib_bench executable and some data files, run zlib_bench --check
8# over those data files, for all zlib types (gzip|zlib|raw) and compression
9# levels 1..9 for each type. Example:
10#
11#  check.sh ./out/Release/zlib_bench [--check-binary] ~/snappy/testdata/*
12#
13# The --check-binary option modifies --check output: the compressed data is
14# also written to the program output.
15
16ZLIB_BENCH="$1" && shift
17
18CHECK_TYPE="--check"
19if [[ "${1}" == "--check-binary" ]]; then
20  CHECK_TYPE="$1" && shift  # output compressed data too
21fi
22
23DATA_FILES="$*"
24
25echo ${ZLIB_BENCH} | grep -E "/(zlib_bench|a.out)$" > /dev/null
26if [[ $? != 0 ]] || [[ -z "${DATA_FILES}" ]]; then
27  echo "usage: check.sh zlib_bench [--check-binary] files ..." >&2
28  exit 1;
29fi
30
31for type in gzip zlib raw; do
32  for level in $(seq 1 9); do
33    ${ZLIB_BENCH} $type --compression $level ${CHECK_TYPE} ${DATA_FILES}
34  done
35done
36