libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

tooling_test.sh (1506B)


      1 #!/bin/bash
      2 # Copyright (c) the JPEG XL Project Authors. All rights reserved.
      3 #
      4 # Use of this source code is governed by a BSD-style
      5 # license that can be found in the LICENSE file.
      6 
      7 # Conformance test tooling test. This is not the JPEG XL conformance test
      8 # runner. This test that the tooling to generate the conformance test and the
      9 # conformance test runner work together.
     10 
     11 MYDIR=$(dirname $(realpath "$0"))
     12 
     13 if [[ $# -eq 2 ]]; then
     14     JPEGXL_TEST_DATA_PATH="$2"
     15 else
     16     JPEGXL_TEST_DATA_PATH="${MYDIR}/../../testdata"
     17 fi
     18 
     19 set -eux
     20 
     21 # Temporary files cleanup hooks.
     22 CLEANUP_FILES=()
     23 cleanup() {
     24   if [[ ${#CLEANUP_FILES[@]} -ne 0 ]]; then
     25     rm -rf "${CLEANUP_FILES[@]}"
     26   fi
     27 }
     28 trap 'retcode=$?; { set +x; } 2>/dev/null; cleanup' INT TERM EXIT
     29 
     30 main() {
     31   local tmpdir=$(mktemp -d)
     32   CLEANUP_FILES+=("${tmpdir}")
     33 
     34   if ! python3 -c 'import numpy'; then
     35     echo "Missing numpy, skipping test." >&2
     36     exit 254  # Signals ctest that we should mark this test as skipped.
     37   fi
     38 
     39   local build_dir="${1:-}"
     40   if [[ -z "${build_dir}" ]]; then
     41     build_dir=$(realpath "${MYDIR}/../../build")
     42   fi
     43 
     44   local decoder="${build_dir}/tools/djxl"
     45   "${MYDIR}/generator.py" \
     46     --decoder="${decoder}" \
     47     --output="${tmpdir}" \
     48     --peak_error=0.001 \
     49     --rmse=0.001 \
     50     "${JPEGXL_TEST_DATA_PATH}/jxl/blending/cropped_traffic_light.jxl"
     51 
     52   # List the contents of the corpus dir.
     53   tree "${tmpdir}" || true
     54 
     55   "${MYDIR}/conformance.py" \
     56     --decoder="${decoder}" \
     57     --corpus="${tmpdir}"
     58 }
     59 
     60 main "$@"