summaryrefslogtreecommitdiff
path: root/src/testpattern/run-testpattern-2.in
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2017-06-19 08:38:07 +0200
committerDidier Raboud <odyx@debian.org>2017-06-19 08:38:07 +0200
commitaedf3e93e811c6c9d504274172861d266e1c5c97 (patch)
tree95e525108c5b6bd2ea3fa689cf11bfe4a5b982a9 /src/testpattern/run-testpattern-2.in
parent7bd83d89975d166521a0b326b64b4cad80117750 (diff)
New upstream version 5.2.13~pre1
Diffstat (limited to 'src/testpattern/run-testpattern-2.in')
-rw-r--r--src/testpattern/run-testpattern-2.in131
1 files changed, 104 insertions, 27 deletions
diff --git a/src/testpattern/run-testpattern-2.in b/src/testpattern/run-testpattern-2.in
index 00608ff..17555a4 100644
--- a/src/testpattern/run-testpattern-2.in
+++ b/src/testpattern/run-testpattern-2.in
@@ -1,5 +1,24 @@
#!@PERL@
+# Featureful driver for test pattern generator
+#
+# Copyright 2006-2017 Robert Krawitz (rlk@alum.mit.edu) and other
+# members of the Gutenprint project.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
use Getopt::Long;
Getopt::Long::Configure("bundling", "no_ignore_case", "pass_through");
@@ -25,7 +44,23 @@ my @special_options = ();
my $include_pattern = '';
my $exclude_pattern = '';
my %exclude_list = ();
-my @standard_options = qw(InkType InkSet,RawChannels DitherAlgorithm Duplex MediaType InputSlot ColorCorrection ImageType FullBleed Quality UseGloss Weave PrintingDirection Density CyanDensity Orientation LabelSeparator);
+my @standard_options = ("InkType",
+ "InkSet,RawChannels",
+ "DitherAlgorithm",
+ "Duplex",
+ "MediaType",
+ "InputSlot",
+ "ColorCorrection",
+ "ImageType",
+ "FullBleed",
+ "Quality",
+ "UseGloss",
+ "Weave",
+ "PrintingDirection",
+ "Density",
+ "CyanDensity",
+ "Orientation",
+ "LabelSeparator");
my $global_status = 1;
my $run_installed = 0;
my $use_min_res = 0;
@@ -500,7 +535,10 @@ sub do_output($) {
my $outbase = "${outkey}.prn";
my $outfile = "$output/$outbase";
if (defined $csum_file) {
- $checksum_cmd = "${csum_type}sum -b | sed 's/-/$outbase/' >> '$csum_file'";
+ $checksum_cmd = "${csum_type}sum -b | sed 's/-/$outbase/'";
+ if ($csum_file ne '' && $csum_file ne '-') {
+ $checksum_cmd .= " >> '$csum_file'";
+ }
} elsif (defined $csum_dir) {
my $checksum_dir = $csum_dir;
if (defined $csum_dir && $csum_dir eq "") {
@@ -522,18 +560,34 @@ sub do_output($) {
}
}
-sub build_list($$) {
- my ($keys, $printer) = @_;
+sub build_list($$$$) {
+ my ($keys, $printer, $min_res, $max_res) = @_;
my (@keys) = split (/,/, $keys);
my ($key) = $keys[0];
my ($rest);
my (@stuff);
if ($#keys > 0) {
$rest = join ",", @keys[1..$#keys];
- @stuff = build_list($rest, $printer);
+ @stuff = build_list($rest, $printer, $min_res, $max_res);
}
my (@tmp);
- if ($param_types{$printer}{$key} == 3) {
+ if ($key =~ /=/) {
+ my (@values);
+ my ($vlist);
+ ($key, $vlist) = split(/=/, $key);
+ @tmp = split(/;/, $vlist);
+ if ($key eq 'Resolution') {
+ @tmp = map {
+ if ($_ eq 'MIN') {
+ $min_res;
+ } elsif ($_ eq 'MAX') {
+ $max_res;
+ } else {
+ $_
+ }
+ } @tmp;
+ }
+ } elsif ($param_types{$printer}{$key} == 3) {
my ($minv) = $stp_float_values{$printer}{'MINVAL'}{$key};
my ($defv) = $stp_float_values{$printer}{'DEFVAL'}{$key};
my ($maxv) = $stp_float_values{$printer}{'MAXVAL'}{$key};
@@ -571,7 +625,7 @@ sub build_list($$) {
sub build_key($$) {
my ($keys, $printer) = @_;
my (@keys) = split (/,/, $keys);
- my (@answer) = grep { defined $param_types{$printer}{$_} } @keys;
+ my (@answer) = grep { defined $param_types{$printer}{$_} || /=/ } @keys;
return join ",", @answer;
}
@@ -580,6 +634,8 @@ sub do_printer($$) {
my $tmp;
my $min_res_name;
my $min_res_value = 0;
+ my $max_res_name;
+ my $max_res_value = 0;
my $first_time = 1;
my $key;
my $skip_resolutions_local = $skip_resolutions;
@@ -600,25 +656,30 @@ sub do_printer($$) {
}
}
+ foreach $tmp (sort @resolutions) {
+ my $res_value = ($stpdata{$printer}{'x_resolution'}{$tmp} *
+ $stpdata{$printer}{'y_resolution'}{$tmp});
+ if ($min_res_value == 0 || $res_value < $min_res_value) {
+ $min_res_value = $res_value;
+ $min_res_name = $tmp;
+ }
+ if ($res_value > $min_res_value) {
+ $max_res_value = $res_value;
+ $max_res_name = $tmp;
+ }
+ }
foreach $key (@special_options) {
- my (@subkeys) = split(/,/, $key);
+ my (@subkeys) = (split(/,/, $key));
if (grep { /^Resolution$/ } @subkeys) {
$skip_resolutions_local = 1;
}
my $nkey = build_key($key, $printer);
if ($nkey ne "") {
- my (@vals) = build_list($nkey, $printer);
+ my (@vals) = build_list($nkey, $printer, $min_res_name, $max_res_name);
+ $nkey =~ s/=[^,]*//g;
$opt_vals{$nkey} = \@vals;
}
}
- foreach $tmp (sort @resolutions) {
- my $res_value = ($stpdata{$printer}{'x_resolution'}{$tmp} *
- $stpdata{$printer}{'y_resolution'}{$tmp});
- if ($min_res_value == 0 || $res_value < $min_res_value) {
- $min_res_value = $res_value;
- $min_res_name = $tmp;
- }
- }
if ($use_min_res > 1) {
@resolutions = ($min_res_name);
}
@@ -799,7 +860,7 @@ sub stopit {
}
}
-if ($list_options) {
+sub list_options() {
if ($#printer_list > 0) {
die "-L must be used with one printer\n";
}
@@ -835,15 +896,16 @@ if ($list_options) {
}
}
}
-} elsif ($dontrun) {
- map { do_printer($_, \*STDOUT) } @printer_list;
- exit 0;
-} else {
+}
+
+sub runit() {
my $valgrind_command;
my $valopts;
if ($gdb_attach) {
$proc_count = 1;
}
+
+ # V A L G R I N D #
if ($callgrind) {
$valopts = '--tool=callgrind --dump-instr=yes --trace-jump=yes';
$valgrind = 4;
@@ -863,6 +925,7 @@ if ($list_options) {
$valgrind_command = "valgrind $valopts";
}
+ # O U T P U T #
if (defined $output && $output ne "" && ! -d $output) {
mkdir $output || die "Can't create directory $output: $!\n";
}
@@ -876,14 +939,12 @@ if ($list_options) {
system "touch $csum_file";
}
- my $status = 1;
+ # # # # # # # #
my ($suppress);
if (! defined $output && ! defined $csum_dir &&
! defined $csum_file) {
$suppress = '-n';
}
- my ($qopt) = $quiet ? "-q" : "";
- my ($Hopt) = $halt_on_error ? "-H" : "";
my (@children);
my ($child_no);
my ($kid);
@@ -896,6 +957,8 @@ if ($list_options) {
push @children, $kid;
}
}
+
+ # Child: select the printers to print, round-robin.
if ($kid == 0) {
my (@xprinter_list);
foreach my $i (0..$#printer_list) {
@@ -906,7 +969,10 @@ if ($list_options) {
@printer_list = @xprinter_list;
}
}
+
+ my $status = 1;
if ($proc_count > 1 && $kid > 0) {
+ # Parent in parallel case
while ($proc_count > 0 && $kid > 0) {
$kid = waitpid(-1, 0);
if ($kid > 0 && $? > 0) {
@@ -914,6 +980,8 @@ if ($list_options) {
}
}
} else {
+ my ($qopt) = $quiet ? "-q" : "";
+ my ($Hopt) = $halt_on_error ? "-H" : "";
$testpattern_command = "$valgrind_command ./testpattern -y $suppress $qopt $Hopt";
if ($single > 1) {
$SIG{TERM} = sub() { stopit() };
@@ -941,7 +1009,7 @@ if ($list_options) {
print STDERR "\n";
}
if ($status && ! $error) {
- exit 0;
+ return 0;
} else {
if ($error) {
if ($single > 1) {
@@ -951,6 +1019,15 @@ if ($list_options) {
print STDERR "*** $error CRASH${plural} NOTED***\n";
}
}
- exit 1;
+ return 1;
}
}
+
+
+if ($list_options) {
+ list_options();
+} elsif ($dontrun) {
+ map { do_printer($_, \*STDOUT) } @printer_list;
+} else {
+ exit(runit());
+}