$gsexe = "bin/gs";
$pclexe = "bin/gpcl6";
$xpsexe = "bin/gxps";
$gpdlexe = "bin/gpdl";
$format_override="";
$fileadjust = "/home/marcos/cluster/";
use Errno qw(EAGAIN);
$basedir = $ARGV[0];
$ARGV = shift @ARGV;
$images = 0;
while (<>)
{
($path,$exe) = /^(\S+)\s+(\S+)/;
($file,$fmt,$res,$band) = ($path =~ /(\S+)\.(\S+)\.(\d+)\.(\d+)$/);
$file =~ s/__/\//g;
if ($file eq "") {
next;
}
$file = $fileadjust.$file;
$file2 = "";
if (!stat($file))
{
($file2) = ($file =~ /(\S+).pdf$/);
if (stat($file2))
{
$exe = "pdfw".$exe;
}
else
{
($file2) = ($file =~ /(\S+).ps$/);
if (!stat($file2))
{
print "Unknown file: ".$file." (".$exe.")\n";
next;
}
$exe = "psw".$exe;
}
}
if ($done{"$file:fmt:$res:$band:$exe"})
{
print "Repeated test: $file:$fmt:$res:$bad:$exe\n";
next;
}
$done{"$file:$fmt:$res:$band:$exe"} = 1;
if ($fmt eq "ppmraw") {
$devargs="-sDEVICE=ppmraw";
$suffix="ppm";
} elsif ($fmt eq "pbmraw") {
$devargs="-sDEVICE=pbmraw";
$suffix="pbm";
} elsif ($fmt eq "pam") {
$devargs="-sDEVICE=pam";
$suffix="pam";
} elsif ($fmt eq "pgmraw") {
$devargs="-sDEVICE=pgmraw";
$suffix="pgm";
} elsif ($fmt eq "pnmcmyk") {
$devargs="-sDEVICE=pnmcmyk";
$suffix="pnm";
} elsif ($fmt eq "pkmraw") {
$devargs="-sDEVICE=pkmraw";
$suffix="pkm";
} elsif ($fmt eq "bmp") {
$devargs="-sDEVICE=bmp16m";
$suffix="bmp";
} elsif ($fmt eq "png") {
$devargs="-sDEVICE=png16m";
$suffix="png";
} elsif ($fmt eq "tiffscaled") {
$devargs="-sDEVICE=tiffscaled";
$suffix="tif";
} elsif ($fmt eq "bitrgb") {
$devargs="-sDEVICE=bitrgb";
$suffix="bit";
} elsif ($fmt eq "bitrgbtags") {
$devargs="-sDEVICE=bitrgbtags";
$suffix="bit";
} elsif ($fmt eq "cups") {
$devargs="-sDEVICE=cups";
$suffix="cups";
} elsif ($fmt eq "plank") {
$devargs="-sDEVICE=plank";
$suffix="plank";
} elsif ($fmt eq "psdcmyk") {
$devargs="-sDEVICE=psdcmyk";
$suffix="psd";
} elsif ($fmt eq "psdcmykog") {
$devargs="-sDEVICE=psdcmykog";
$suffix="psd";
} else {
print "Unsupported format $fmt - skipping\n";
next;
}
print "=====$path:$exe=====\n";
my $resargs = " -r$res";
my $bandargs = " -dMaxBitmap=400000000";
if ($band == 1) {
$bandargs = " -dMaxBitmap=1000";
}
my $randargs = " -Z: -dNOPAUSE -dBATCH -K2000000 -dClusterJob";
my $binargs;
my $psargs = "";
if ($file =~ m/\.PS$/) { $psargs = " -dCETMODE"; };
if ($exe =~ m/gs/)
{
$binargs = $gsexe;
}
elsif ($exe =~ m/pcl/)
{
$binargs = $pclexe;
}
elsif ($exe =~ m/xps/)
{
$binargs = $xpsexe;
}
elsif ($exe =~ m/gpdl/)
{
$binargs = $gpdlexe;
}
else
{
die "$bin not matched; dying";
}
my $dev1args = $devargs;
my $out1args = "/dev/null";
my $two_stage = 0;
if ($exe =~ m/pdfw/)
{
$dev1args = "-sDEVICE=pdfwrite";
$out1args = "out.pdf";
$two_stage = 1;
}
elsif ($exe =~ m/psw/)
{
$dev1args = "-sDEVICE=ps2write";
$out1args = "out.ps";
$two_stage = 1;
}
$cmd = "valgrind --track-origins=yes $binargs $psargs -sOutputFile=$out1args $bandargs $dev1args $resargs $randargs $file2";
system("echo $cmd");
system("$cmd");
my $ret = $?;
system("echo return $ret");
if ($ret == 0 && $two_stage != 0) {
system("echo -----");
if ($exe =~ m/pdfw/ ||
$exe =~ m/psw/)
{
$binargs = $gsexe;
}
else
{
die "$exe second stage not matchined; dying";
}
$cmd = "valgrind --track-origins=yes $binargs $psargs -sOutputFile=/dev/null $bandargs $devargs $resargs $randargs $out1args";
system("echo $cmd");
system("$cmd");
$ret = $?;
system("echo return $ret");
}
}
print "TESTING COMPLETED!\n";