• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2
3# Make a set of test PNG files, MAKEPNG is the name of the makepng executable
4# built from contrib/libtests/makepng.c
5
6# Copyright (c) 2015 John Cunningham Bowler
7
8# This code is released under the libpng license.
9# For conditions of distribution and use, see the disclaimer
10# and license in png.h
11
12# The arguments say whether to build all the files or whether just to build the
13# ones that extend the code-coverage of libpng from the existing test files in
14# contrib/pngsuite.
15test -n "$MAKEPNG" || MAKEPNG=./makepng
16opts=
17
18mp(){
19   ${MAKEPNG} $opts $1 "$3" "$4" "$3-$4$2.png"
20}
21
22mpg(){
23   if test "$1" = "none"
24   then
25      mp "" "" "$2" "$3"
26   else
27      mp "--$1" "-$1" "$2" "$3"
28   fi
29}
30
31mptrans(){
32   if test "$1" = "none"
33   then
34      mp "--tRNS" "-tRNS" "$2" "$3"
35   else
36      mp "--tRNS --$1" "-$1-tRNS" "$2" "$3"
37   fi
38}
39
40case "$1" in
41   --small)
42      opts="--small";;&
43
44   --all|--small)
45      for g in none sRGB linear 1.8
46      do
47         for c in gray palette
48         do
49            for b in 1 2 4
50            do
51               mpg "$g" "$c" "$b"
52               mptrans "$g" "$c" "$b"
53            done
54         done
55
56         mpg "$g" palette 8
57         mptrans "$g" palette 8
58
59         for b in 8 16
60         do
61            for c in gray gray-alpha rgb rgb-alpha
62            do
63               mpg "$g" "$c" "$b"
64            done
65            for c in gray rgb
66            do
67               mptrans "$g" "$c" "$b"
68            done
69         done
70      done;;
71
72   --coverage)
73      # Comments below indicate cases known to be required and not duplicated
74      # in other (required) cases; the aim is to get a minimal set that gives
75      # the maximum code coverage.
76      mpg none gray-alpha 8 # required: code coverage, sRGB opaque component
77      mpg none palette 8 # required: basic palette read
78      mpg 1.8 gray 2 # required: tests gamma threshold code
79      mpg 1.8 palette 2 # required: code coverage
80      mpg 1.8 palette 4 # required: code coverage
81      mpg 1.8 palette 8 # error limits only
82      mpg linear palette 8 # error limits only
83      mpg linear rgb-alpha 16 # error limits only
84      mpg sRGB palette 1 # required: code coverage
85      mpg sRGB rgb-alpha 16 # required: code coverage: pngread.c:2422 untested
86      :;;
87
88   *)
89      echo "$0 $1: unknown argument, usage:" >&2
90      echo "  $0 [--all|--coverage|--small]" >&2
91      exit 1
92esac
93