diff options
author | Roger Leigh <rleigh@debian.org> | 2008-10-26 16:17:32 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2008-10-26 16:17:32 +0000 |
commit | cda0fb3b8a7cb56045b24fd0af0ed36591b5d7eb (patch) | |
tree | 31ef197ec5c98ac9ac08714a2440a787c065d8c7 /src/testpattern/run-testpattern-2.in | |
parent | 92b02ddce00dec2787514568fa9d644d4f0350e9 (diff) |
Imported Upstream version 5.0.1
Diffstat (limited to 'src/testpattern/run-testpattern-2.in')
-rw-r--r-- | src/testpattern/run-testpattern-2.in | 122 |
1 files changed, 85 insertions, 37 deletions
diff --git a/src/testpattern/run-testpattern-2.in b/src/testpattern/run-testpattern-2.in index daba8db..9f0fd5c 100644 --- a/src/testpattern/run-testpattern-2.in +++ b/src/testpattern/run-testpattern-2.in @@ -8,9 +8,14 @@ use strict; my $valgrind = 0; my $cachegrind = 0; my $gdb_attach = 0; +my $calc_md5 = 0; my $dontrun = 0; my $retval = 0; +my $testpattern_command; my @printer_list = (); +my @special_options = (); +my @standard_options = qw(InkType); +my $global_status = 1; my @extras = (); my @messages = (); @@ -24,7 +29,13 @@ GetOptions("v+" => \$valgrind, "c" => \$cachegrind, "g" => \$gdb_attach, "n" => \$dontrun, - "s!" => \$skip_duplicate_printers); + "s!" => \$skip_duplicate_printers, + "o=s" => \@special_options, + "m" => \$calc_md5); + +if (! @special_options) { + @special_options = @standard_options; +} my $pwd = `pwd`; chomp $pwd; @@ -110,15 +121,10 @@ EOF return $stuff; } -open PIPE, "./printer_options|" or die "Cannot run printer_options: $!\n"; -while(<PIPE>) { - next if m!^#!; - eval $_; -} -close PIPE or die "Cannot run printer_options: $!\n"; - +my $extra_arg = ""; if ($#ARGV >= 0) { @printer_list = @ARGV; + $extra_arg = join " ", @printer_list; } else { open PIPE, "./printers|" or die "Cannot run printers: $!\n"; while(<PIPE>) { @@ -129,24 +135,55 @@ if ($#ARGV >= 0) { close PIPE; } -sub do_printer($$) { +open PIPE, "./printer_options $extra_arg|" or die "Cannot run printer_options: $!\n"; +while(<PIPE>) { + next if m!^#!; + eval $_; +} +close PIPE or die "Cannot run printer_options: $!\n"; + +sub do_print { + my ($output, $fh) = @_; + if ($dontrun) { + print $output; + } elsif ($calc_md5) { + open TESTPATTERN, "|$testpattern_command" or + die "Can't run $testpattern_command: $!\n"; + print TESTPATTERN $output; + my $status = close TESTPATTERN; + if (! $status) { + $global_status = 0; + } + } else { + print $fh $output; + } +} + + +sub do_printer { my ($printer, $fh) = @_; - my $tmp = $stpdata{$printer}{'Resolution'}; + my $tmp; my $min_res_name; my $min_res_value = 0; my $first_time = 1; my $model_id = $models{$printer}; my $family_id = $families{$printer}; + my $key; + my %opt_vals = {}; if ($skip_duplicate_printers && $models_found{$family_id}{$model_id}) { return; } else { $models_found{$family_id}{$model_id} = 1; } + $tmp = $stpdata{$printer}{'Resolution'}; my (@resolutions) = grep {$_ ne 'None' } keys %$tmp; $tmp = $stpdata{$printer}{'PrintingMode'}; my (@printing_modes) = grep {$_ ne 'None' } keys %$tmp; - $tmp = $stpdata{$printer}{'InkType'}; - my (@ink_types) = grep {$_ ne 'None' } keys %$tmp; + foreach $key (@special_options) { + $tmp = $stpdata{$printer}{$key}; + my (@tmp) = grep {$_ ne 'None' } keys %$tmp; + $opt_vals{$key} = \@tmp; + } foreach $tmp (sort @resolutions) { my $res_value = ($stpdata{$printer}{'x_resolution'}{$tmp} * $stpdata{$printer}{'y_resolution'}{$tmp}); @@ -159,7 +196,7 @@ sub do_printer($$) { # We don't need to do both resolutions and ink types. my $pmode; foreach $pmode (@printing_modes) { - my ($resolution, $ink_type); + my ($resolution); foreach $resolution (@resolutions) { @extras = (); @messages = (); @@ -173,24 +210,29 @@ sub do_printer($$) { set_opt("ColorCorrection", "Raw"); set_message(" ${pmode}+${resolution}"); my $output = print_one_testpattern($printer); - print $fh $output; + do_print( $output, $fh ); } - if ($#ink_types >= 1) { - foreach $ink_type (@ink_types) { - @extras = (); - @messages = (); - if ($first_time) { - set_message("$printer\n"); - $first_time = 0; + foreach $key (@special_options) { + $tmp = $opt_vals{$key}; + my (@opts) = @$tmp; + if ($#opts >= 1) { + my $opt; + foreach $opt (@opts) { + @extras = (); + @messages = (); + if ($first_time) { + set_message("$printer\n"); + $first_time = 0; + } + set_opt("PrintingMode", $pmode); + set_opt("Resolution", $min_res_name); + set_opt($key, $opt); + set_opt("DitherAlgorithm", "Fast"); + set_opt("ColorCorrection", "Raw"); + set_message(" ${key}=${opt}+${pmode}+${min_res_name}"); + my $output = print_one_testpattern($printer); + do_print( $output, $fh ); } - set_opt("PrintingMode", $pmode); - set_opt("Resolution", $min_res_name); - set_opt("InkType", $ink_type); - set_opt("DitherAlgorithm", "Fast"); - set_opt("ColorCorrection", "Raw"); - set_message(" ${ink_type}+${pmode}+${min_res_name}"); - my $output = print_one_testpattern($printer); - print $fh $output; } } } @@ -200,7 +242,6 @@ if ($dontrun) { map { do_printer($_, \*STDOUT) } @printer_list; exit 0; } else { - my $testpattern_command; my $valgrind_command; my $valopts; if ($cachegrind) { @@ -215,19 +256,26 @@ if ($dontrun) { if ($valgrind == 1) { $valgrind_command = "valgrind $valopts -q --num-callers=100 --error-limit=no --leak-check=yes"; } elsif ($valgrind == 2) { - $valgrind_command = "valgrind $valopts --num-callers=100 --error-limit=no --show-reachable=yes --leak-resolution=high --leak-check=yes"; + $valgrind_command = "valgrind $valopts --num-callers=100 --error-limit=no --leak-resolution=high --leak-check=yes"; } elsif ($valgrind == 3) { $valgrind_command = "valgrind $valopts --error-limit=no --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes"; } elsif ($valgrind == 4) { $valgrind_command = "valgrind $valopts"; } - $testpattern_command = "$valgrind_command ./testpattern -n"; - - open TESTPATTERN, "|$testpattern_command" or - die "Can't run $testpattern_command: $!\n"; - map { do_printer($_, \*TESTPATTERN) } @printer_list; - my $status = close TESTPATTERN; + my $status = 1; + if ($calc_md5) { + $testpattern_command = "./testpattern > out.prn; a=\$? ; md5sum out.prn; exit \$a"; + map { do_printer($_) } @printer_list; + $status = $global_status; + } else { + $testpattern_command = "$valgrind_command ./testpattern -n"; + open TESTPATTERN, "|$testpattern_command" or + die "Can't run $testpattern_command: $!\n"; + $testpattern_command = "$valgrind_command ./testpattern -n"; + map { do_printer($_, \*TESTPATTERN) } @printer_list; + $status = close TESTPATTERN; + } if ($status) { exit 0; } else { |