blob: 9d1b7764e56735ca118e7cc4f2eb8db31ca55897 [file] [log] [blame]
Chris Craikca2bf812013-07-29 15:28:30 -07001#!/bin/sh
2#
3# Usage:
4#
Matt Sarett9b1fe632015-11-25 10:21:17 -05005# tests/pngstest gamma alpha
Chris Craikca2bf812013-07-29 15:28:30 -07006#
Matt Sarett9b1fe632015-11-25 10:21:17 -05007# Run ./pngstest on the PNG files in $srcdir/contrib/testpngs which have the
8# given gamma and opacity:
Chris Craikca2bf812013-07-29 15:28:30 -07009#
Matt Sarett9b1fe632015-11-25 10:21:17 -050010# gamma: one of; linear, 1.8, sRGB, none.
11# alpha: one of; opaque, tRNS, alpha, none. 'none' is equivalent to !alpha
12#
13# NOTE: the temporary files pngstest generates have the base name gamma-alpha to
14# avoid issues with make -j
15#
16gamma="$1"
Chris Craikca2bf812013-07-29 15:28:30 -070017shift
Matt Sarett9b1fe632015-11-25 10:21:17 -050018alpha="$1"
19shift
Matt Sarett11466862016-02-19 13:41:30 -050020args=
21LC_ALL="C" # fix glob sort order to ASCII:
22for f in "${srcdir}/contrib/testpngs/"*.png
23do
24 g=
25 case "$f" in
26 *-linear[.-]*)
27 test "$gamma" = "linear" && g="$f";;
Matt Sarett9b1fe632015-11-25 10:21:17 -050028
Matt Sarett11466862016-02-19 13:41:30 -050029 *-sRGB[.-]*)
30 test "$gamma" = "sRGB" && g="$f";;
Matt Sarett9b1fe632015-11-25 10:21:17 -050031
Matt Sarett11466862016-02-19 13:41:30 -050032 *-1.8[.-]*)
33 test "$gamma" = "1.8" && g="$f";;
Matt Sarett9b1fe632015-11-25 10:21:17 -050034
Matt Sarett11466862016-02-19 13:41:30 -050035 *)
36 test "$gamma" = "none" && g="$f";;
37 esac
Matt Sarett9b1fe632015-11-25 10:21:17 -050038
Matt Sarett11466862016-02-19 13:41:30 -050039 case "$g" in
40 "")
41 :;;
Matt Sarett9b1fe632015-11-25 10:21:17 -050042
Matt Sarett11466862016-02-19 13:41:30 -050043 *-alpha[-.]*)
44 test "$alpha" = "alpha" && args="$args $g";;
Matt Sarett9b1fe632015-11-25 10:21:17 -050045
Matt Sarett11466862016-02-19 13:41:30 -050046 *-tRNS[-.]*)
47 test "$alpha" = "tRNS" -o "$alpha" = "none" && args="$args $g";;
Matt Sarett9b1fe632015-11-25 10:21:17 -050048
Matt Sarett11466862016-02-19 13:41:30 -050049 *)
50 test "$alpha" = "opaque" -o "$alpha" = "none" && args="$args $g";;
51 esac
52done
53# This only works if the arguments don't contain spaces; they don't.
54exec ./pngstest --tmpfile "${gamma}-${alpha}-" --log ${1+"$@"} $args