diff options
author | Roger Leigh <rleigh@debian.org> | 2008-10-26 16:18:09 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2008-10-26 16:18:09 +0000 |
commit | f9238b191d14686b9beba78893dff0a8dff9c087 (patch) | |
tree | f563eacc3307021378e7c50d4c1ee4797a2392dc /src/testpattern/run-testpattern-2.in | |
parent | cda0fb3b8a7cb56045b24fd0af0ed36591b5d7eb (diff) |
Imported Upstream version 5.0.2
Diffstat (limited to 'src/testpattern/run-testpattern-2.in')
-rw-r--r-- | src/testpattern/run-testpattern-2.in | 146 |
1 files changed, 115 insertions, 31 deletions
diff --git a/src/testpattern/run-testpattern-2.in b/src/testpattern/run-testpattern-2.in index 9f0fd5c..065d8f4 100644 --- a/src/testpattern/run-testpattern-2.in +++ b/src/testpattern/run-testpattern-2.in @@ -14,29 +14,54 @@ my $retval = 0; my $testpattern_command; my @printer_list = (); my @special_options = (); -my @standard_options = qw(InkType); +my @standard_options = qw(InkType DitherAlgorithm Duplex); my $global_status = 1; +my $output = undef; my @extras = (); my @messages = (); +my @global_messages = (); my %stpdata = (); my %models_found = (); my %models; my %families; my $skip_duplicate_printers = 0; +my $std_pages = 1; + +my @default_options = (); +my %base_settings = ("DitherAlgorithm" => "Fast", + "ColorCorrection" => "Raw"); GetOptions("v+" => \$valgrind, "c" => \$cachegrind, "g" => \$gdb_attach, "n" => \$dontrun, + "p:i" => \$std_pages, "s!" => \$skip_duplicate_printers, "o=s" => \@special_options, - "m" => \$calc_md5); + "O=s" => \$output, + "d=s" => \@default_options, + "m:s" => \$calc_md5); + +my $pages = $std_pages; + +if (defined $calc_md5 && $calc_md5 eq "0") { + $calc_md5 = undef; +} if (! @special_options) { @special_options = @standard_options; } +foreach my $opt (@default_options) { + my ($option, $value) = split(/=/, $opt); + if (! $value) { + delete $base_settings{$option}; + } else { + $base_settings{$option} = $value; + } +} + my $pwd = `pwd`; chomp $pwd; @@ -58,11 +83,22 @@ sub set_message($) { push @messages, "message \"$message\";\n"; } +sub set_global_message($) { + my ($message) = @_; + push @global_messages, "message \"$message\";\n"; +} + sub print_one_testpattern($) { my ($printer) = @_; - my $stuff = "printer \"$printer\";\n"; - $stuff .= join "", @extras, @messages; - $stuff .= << 'EOF'; + my $stuff = join "", @global_messages; + foreach my $page (0..$pages - 1) { + $stuff .= "printer \"$printer\";\n"; + $stuff .= join "", @extras, @messages; + if ($pages > 1) { + $stuff .= "message \"(page $page)\";\n"; + } + $stuff .= "parameter_int \"PageNumber\" $page;\n"; + $stuff .= << 'EOF'; hsize 0.1; vsize 0.1; left 0.15; @@ -118,6 +154,7 @@ 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; 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; end; EOF + } return $stuff; } @@ -146,14 +183,6 @@ 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; } @@ -197,17 +226,38 @@ sub do_printer { my $pmode; foreach $pmode (@printing_modes) { my ($resolution); + $pages = $std_pages; foreach $resolution (@resolutions) { @extras = (); @messages = (); + @global_messages = (); if ($first_time) { - set_message("$printer\n"); + set_global_message("$printer\n"); $first_time = 0; } set_opt("PrintingMode", $pmode); set_opt("Resolution", $resolution); - set_opt("DitherAlgorithm", "Fast"); - set_opt("ColorCorrection", "Raw"); + map { set_opt($_, $base_settings{$_})} keys %base_settings; + if (defined $output || defined $calc_md5) { + my $outkey = "${printer}_PrintingMode_${pmode}_Resolution_${resolution}"; + my $md5_dir = $calc_md5; + if (defined $calc_md5 && $calc_md5 eq "") { + $md5_dir = $output; + } + my $outbase = "${outkey}.prn"; + my $outfile = "$output/$outbase"; + my $md5file = "$md5_dir/${outkey}.md5"; + if (! $md5_dir) { + $md5file = "${outkey}.md5"; + } + if ($output && $calc_md5) { + push @extras, "output \"|tee '$outfile' | md5sum -b | sed 's/-/$outbase/' > '$md5file'\";\n"; + } elsif ($output) { + push @extras, "output \"$outfile\";\n"; + } else { + push @extras, "output \"|md5sum -b | sed 's/-/$outbase/' > '$md5file'\";\n"; + } + } set_message(" ${pmode}+${resolution}"); my $output = print_one_testpattern($printer); do_print( $output, $fh ); @@ -218,17 +268,48 @@ sub do_printer { if ($#opts >= 1) { my $opt; foreach $opt (@opts) { + my ($out_file); @extras = (); @messages = (); + @global_messages = (); if ($first_time) { - set_message("$printer\n"); + set_global_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"); + map { + if ($key ne $_) { + set_opt($_, $base_settings{$_}); + if ($key eq "Duplex") { + set_opt("JobMode", "Job"); + $pages = 4; + } else { + $pages = $std_pages; + } + } + } keys %base_settings; + if (defined $output || defined $calc_md5) { + my $outkey = "${printer}_PrintingMode_${pmode}_Resolution_${min_res_name}_${key}_${opt}"; + my $md5_dir = $calc_md5; + if (defined $calc_md5 && $calc_md5 eq "") { + $md5_dir = $output; + } + my $outbase = "${outkey}.prn"; + my $outfile = "$output/$outbase"; + my $md5file = "$md5_dir/${outkey}.md5"; + if (! $md5_dir) { + $md5file = "${outkey}.md5"; + } + if (defined $output && defined $calc_md5) { + push @extras, "output \"|tee '$outfile' | md5sum -b | sed 's/-/$outbase/' > '$md5file'\";\n"; + } elsif ($output) { + push @extras, "output \"$outfile\";\n"; + } else { + push @extras, "output \"|md5sum -b | sed 's/-/$outbase/' > '$md5file'\";\n"; + } + } set_message(" ${key}=${opt}+${pmode}+${min_res_name}"); my $output = print_one_testpattern($printer); do_print( $output, $fh ); @@ -263,19 +344,22 @@ if ($dontrun) { $valgrind_command = "valgrind $valopts"; } - 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 (defined $output && $output ne "" && ! -d $output) { + mkdir $output || die "Can't create directory $output: $!\n"; + } + + if (defined $calc_md5 && $calc_md5 ne "" && ! -d $calc_md5) { + mkdir $calc_md5 || die "Can't create directory $calc_md5: $!\n"; } + + my $status = 1; + my ($suppress); + if (! defined $output && ! defined $calc_md5) { $suppress = '-n'; } + $testpattern_command = "$valgrind_command ./testpattern $suppress"; + open TESTPATTERN, "|$testpattern_command" or + die "Can't run $testpattern_command: $!\n"; + map { do_printer($_, \*TESTPATTERN) } @printer_list; + $status = close TESTPATTERN; if ($status) { exit 0; } else { |