| 1 |
#!@SHELL@ |
| 2 |
|
| 3 |
# Driver for test pattern generator |
| 4 |
# |
| 5 |
# Copyright 2003-2008 Robert Krawitz ([email protected]) |
| 6 |
# |
| 7 |
# This program is free software; you can redistribute it and/or modify it |
| 8 |
# under the terms of the GNU General Public License as published by the Free |
| 9 |
# Software Foundation; either version 2 of the License, or (at your option) |
| 10 |
# any later version. |
| 11 |
# |
| 12 |
# This program is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 |
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 |
# for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
retval=0; |
| 21 |
|
| 22 |
if [ -z "$srcdir" -o "$srcdir" = "." ] ; then |
| 23 |
sdir=`pwd` |
| 24 |
elif [ -n "`echo $srcdir |grep '^/'`" ] ; then |
| 25 |
sdir="$srcdir" |
| 26 |
else |
| 27 |
sdir="`pwd`/$srcdir" |
| 28 |
fi |
| 29 |
|
| 30 |
if [ -z "$STP_DATA_PATH" ] ; then |
| 31 |
STP_DATA_PATH="$sdir/../xml" |
| 32 |
export STP_DATA_PATH |
| 33 |
fi |
| 34 |
|
| 35 |
if [ -z "$STP_MODULE_PATH" ] ; then |
| 36 |
STP_MODULE_PATH="$sdir/../main:$sdir/../main/.libs" |
| 37 |
export STP_MODULE_PATH |
| 38 |
fi |
| 39 |
|
| 40 |
valgrind=0 |
| 41 |
valopts='' |
| 42 |
extra='' |
| 43 |
dontrun= |
| 44 |
output='' |
| 45 |
|
| 46 |
set_opt() { |
| 47 |
opt=`echo $1 | awk -F= '{print $1}'` |
| 48 |
val=`echo $1 | awk -F= '{print $2}'` |
| 49 |
extra="`printf '%s\nparameter \"%s\" \"%s\";' \"$extra\" $opt $val`" |
| 50 |
} |
| 51 |
|
| 52 |
set_message() { |
| 53 |
the_message="`printf '%s\nmessage \"%s\";' \"$the_message\" \"$@\"`" |
| 54 |
} |
| 55 |
|
| 56 |
usage() { |
| 57 |
echo "Usage: run-testpattern [-v|--valgrind]" |
| 58 |
echo " [-p|--parameter parameter=value]" |
| 59 |
echo " [-n|--dontrun]" |
| 60 |
echo " [-O|--output]" |
| 61 |
echo " [--] [printers...]" |
| 62 |
exit 0; |
| 63 |
} |
| 64 |
|
| 65 |
set_args() { |
| 66 |
while true ; do |
| 67 |
case "$1" in |
| 68 |
-h*|--h*) usage ;; |
| 69 |
-v|--valgrind) valopts='--tool=memcheck' ; valgrind=`expr $valgrind + 1` ;; |
| 70 |
-c|--cachegrind) valopts='--tool=cachegrind'; valgrind=4 ;; |
| 71 |
-g|--gdb-attach) valopts='--gdb-attach=yes' ;; |
| 72 |
-p|--parameter) shift; set_opt "$1" ;; |
| 73 |
-O|--output) shift; output="$1" ;; |
| 74 |
-n|--dontrun) dontrun=1 ;; |
| 75 |
--) shift; args="$@"; return ;; |
| 76 |
*) return ;; |
| 77 |
esac |
| 78 |
shift |
| 79 |
done |
| 80 |
} |
| 81 |
|
| 82 |
print_one_testpattern() { |
| 83 |
printer=$1 |
| 84 |
shift |
| 85 |
stuff="$@" |
| 86 |
cat <<EOF |
| 87 |
printer "$printer"; |
| 88 |
$stuff |
| 89 |
hsize 0.1; |
| 90 |
vsize 0.1; |
| 91 |
left 0.15; |
| 92 |
top 0.15; |
| 93 |
blackline 0; |
| 94 |
steps 16; |
| 95 |
mode rgb 8; |
| 96 |
pattern 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 ; |
| 97 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0; |
| 98 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0; |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.0 0.0 0.0 1.0 0.0 0.0 1.0; |
| 112 |
pattern 0.1 0.999 -2.0 -2.0 -2.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0; |
| 113 |
pattern 0.3 0.999 -2.0 -2.0 -2.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0; |
| 114 |
pattern 0.5 0.999 -2.0 -2.0 -2.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0; |
| 115 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0 1.0; |
| 116 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.25 1.0 0.0 0.0 1.0 0.0 0.75 1.0 0.0 0.75 1.0; |
| 117 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.25 1.0 0.0 0.0 1.0 0.0 0.75 1.0 0.0 0.75 1.0; |
| 118 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.5 1.0 0.0 0.0 1.0 0.0 0.5 1.0 0.0 0.5 1.0; |
| 119 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.5 1.0 0.0 0.0 1.0 0.0 0.5 1.0 0.0 0.5 1.0; |
| 120 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.75 1.0 0.0 0.0 1.0 0.0 0.25 1.0 0.0 0.25 1.0; |
| 121 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.75 1.0 0.0 0.0 1.0 0.0 0.25 1.0 0.0 0.25 1.0; |
| 122 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.9 1.0 0.0 0.0 1.0 0.0 0.1 1.0 0.0 0.1 1.0; |
| 123 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.9 1.0 0.0 0.0 1.0 0.0 0.1 1.0 0.0 0.1 1.0; |
| 124 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0; |
| 125 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.25 1.0 0.0 0.75 1.0 0.0 0.0 1.0 0.0 0.75 1.0; |
| 126 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.25 1.0 0.0 0.75 1.0 0.0 0.0 1.0 0.0 0.75 1.0; |
| 127 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.5 1.0 0.0 0.5 1.0 0.0 0.0 1.0 0.0 0.5 1.0; |
| 128 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.5 1.0 0.0 0.5 1.0 0.0 0.0 1.0 0.0 0.5 1.0; |
| 129 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.75 1.0 0.0 0.25 1.0 0.0 0.0 1.0 0.0 0.25 1.0; |
| 130 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.75 1.0 0.0 0.25 1.0 0.0 0.0 1.0 0.0 0.25 1.0; |
| 131 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.9 1.0 0.0 0.1 1.0 0.0 0.0 1.0 0.0 0.1 1.0; |
| 132 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.9 1.0 0.0 0.1 1.0 0.0 0.0 1.0 0.0 0.1 1.0; |
| 133 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0 1.0 0.0 0.0 1.0; |
| 134 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.25 1.0 0.0 0.75 1.0 0.0 0.75 1.0 0.0 0.0 1.0; |
| 135 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.25 1.0 0.0 0.75 1.0 0.0 0.75 1.0 0.0 0.0 1.0; |
| 136 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.5 1.0 0.0 0.5 1.0 0.0 0.5 1.0 0.0 0.0 1.0; |
| 137 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.5 1.0 0.0 0.5 1.0 0.0 0.5 1.0 0.0 0.0 1.0; |
| 138 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.75 1.0 0.0 0.25 1.0 0.0 0.25 1.0 0.0 0.0 1.0; |
| 139 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.75 1.0 0.0 0.25 1.0 0.0 0.25 1.0 0.0 0.0 1.0; |
| 140 |
pattern 1.0 1.0 1.0 1.0 1.0 0.0 0.9 1.0 0.0 0.1 1.0 0.0 0.1 1.0 0.0 0.0 1.0; |
| 141 |
pattern 0.0 0.0 1.0 1.0 1.0 0.0 0.9 1.0 0.0 0.1 1.0 0.0 0.1 1.0 0.0 0.0 1.0; |
| 142 |
end; |
| 143 |
EOF |
| 144 |
} |
| 145 |
|
| 146 |
run_testpattern() { |
| 147 |
suppress=-n |
| 148 |
if [ -n "$output" ] ; then |
| 149 |
suppress='' |
| 150 |
fi |
| 151 |
case "$valgrind" in |
| 152 |
1) libtool --mode=execute valgrind $valopts -q --num-callers=100 --leak-check=yes --error-limit=no ./testpattern $suppress ;; |
| 153 |
2) libtool --mode=execute valgrind $valopts --num-callers=100 --leak-resolution=high --leak-check=yes --error-limit=no ./testpattern $suppress ;; |
| 154 |
3) libtool --mode=execute valgrind $valopts --error-limit=no --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes ./testpattern $suppress ;; |
| 155 |
4) libtool --mode=execute valgrind $valopts ./testpattern $suppress ;; |
| 156 |
*) ./testpattern $suppress ;; |
| 157 |
esac |
| 158 |
if [ $? -ne 0 ] ; then |
| 159 |
retval=1 |
| 160 |
fi |
| 161 |
exit $retval |
| 162 |
} |
| 163 |
|
| 164 |
set_args `getopt hgvp:ncO: "$@"` |
| 165 |
|
| 166 |
if [ -z "$args" ] ; then |
| 167 |
args=`./printers` |
| 168 |
fi |
| 169 |
|
| 170 |
#StandardDithers="EvenTone HybridEvenTone UniTone HybridUniTone Adaptive Ordered Fast VeryFast Floyd Predithered" |
| 171 |
|
| 172 |
StandardDithers="EvenTone HybridEvenTone Adaptive Ordered OrderedNew Fast VeryFast Floyd Predithered Segmented SegmentedNew" |
| 173 |
|
| 174 |
the_message='' |
| 175 |
|
| 176 |
if [ -z "$dontrun" -a -n "$output" -a ! -d "$output" ] ; then |
| 177 |
mkdir "$output" |
| 178 |
if [ "$?" -ne 0 ] ; then |
| 179 |
echo "Cannot create directory '$output'" |
| 180 |
exit 1 |
| 181 |
fi |
| 182 |
fi |
| 183 |
|
| 184 |
print_all_testpatterns() { |
| 185 |
if [ -z "`echo $extra |grep DitherAlgorithm`" ] ; then |
| 186 |
for p in $args ; do |
| 187 |
set_message "$p |
| 188 |
" |
| 189 |
for d in $StandardDithers ; do |
| 190 |
if [ -n "$output" ] ; then |
| 191 |
outstuff="`printf '\n%s\n' \"output \\\"$output/${p}_${d}\\\";\"`" |
| 192 |
fi |
| 193 |
set_message " $d" |
| 194 |
print_one_testpattern "$p" "`printf '%s\n' \"parameter \\\"DitherAlgorithm\\\" \\\"$d\\\";\"`" "$extra" "$the_message" "$outstuff" |
| 195 |
the_message='' |
| 196 |
done |
| 197 |
done |
| 198 |
else |
| 199 |
for p in $args ; do |
| 200 |
the_message='' |
| 201 |
set_message "$p" |
| 202 |
print_one_testpattern "$p" "$extra" "$the_message" |
| 203 |
done |
| 204 |
fi |
| 205 |
} |
| 206 |
|
| 207 |
if [ -z "$dontrun" ] ; then |
| 208 |
print_all_testpatterns | run_testpattern 2>&1 |
| 209 |
else |
| 210 |
print_all_testpatterns |
| 211 |
fi |
| 212 |
|
| 213 |
exit $? |