# HG changeset patch # User Axel Jacobs # Date 1309124203 -3600 # Node ID e4ebb10e4697b35169036611253d85431e4c34ec # Parent 7174511d4983c84a15bd66ab0a191c3b8c9e8959 Added configurabe STDIN to falsecolor test. diff -r 7174511d4983 -r e4ebb10e4697 tests/falsecolor_test.pl --- a/tests/falsecolor_test.pl Sun Jun 26 21:32:00 2011 +0100 +++ b/tests/falsecolor_test.pl Sun Jun 26 22:36:43 2011 +0100 @@ -1,5 +1,11 @@ #!/usr/bin/perl +# falsecolor_test.pl +# This file is part of the testsuite of the Radiance csh2perl project. +# You may copy and modify this file as basis for other tests. +# +# (c) Axel Jacobs, 26 June 2011 + use strict; use warnings; @@ -10,34 +16,43 @@ use File::Temp qw/ tempdir /; my $tmpdir = tempdir( CLEANUP => 0 ); -print "temp dir: $tmpdir\n"; my $img = "data/images/street-rgbe_rle_400x400.hdr"; +# Options are arrays of [STDIN, command-line options]. +# Please include the pipe symbol as part of STDIN. +# Put a leading space in front of STDIN to line up the output. my @options = ( - "-ip $img", - "-ip $img -l cd/m2", # Label now defaults to cd/m2, not nits. - "-i $img -p $img -l cd/m2", - "-ip $img -cl -l cd/m2", - "-ip $img -n 10 -l cd/m2", - "-ip $img -s 2000 -l cd/m2", - "-ip $img -lw 200 -lh 300 -l cd/m2", # scale is slightly higher now. + ["", "-ip $img"], + ["", "-ip $img -l cd/m2"], # Label now defaults to cd/m2, not nits. + ["", "-i $img -p $img -l cd/m2"], + ["", "-ip $img -cl -l cd/m2"], + ["", "-ip $img -n 10 -l cd/m2"], + ["", "-ip $img -s 2000 -l cd/m2"], + [" cat $img |", "-ip - -s 2000 -l cd/m2"], # take image from STDIN. + ["", "-ip $img -lw 200 -lh 300 -l cd/m2"], # scale is slightly higher now. ); # Run old CSH and new Perl script with different options, # compare the resulting images. +my $total = 0; +my $fail = 0; my $index = 0; -my $opt; -foreach $opt (@options) { +my $opts; +foreach $opts (@options) { + my $stdin = @$opts[0]; + my $args = @$opts[1]; + $total++; + my $cshout = "$tmpdir/${script}_csh$index.hdr"; - my $cshcmd = "$script.csh $opt > $cshout"; - print " $cshcmd\n"; - system "csh ../orig/$cshcmd"; + my $cshcmd = "$script.csh $args > $cshout"; + print " $stdin $cshcmd\n"; + system "$stdin csh ../orig/$cshcmd"; my $perlout = "$tmpdir/${script}_perl$index.hdr"; - my $perlcmd = "$script.pl $opt > $perlout"; - print " $perlcmd\n"; - system "perl ../bin/$perlcmd"; + my $perlcmd = "$script.pl $args > $perlout"; + print " $stdin $perlcmd\n"; + system "$stdin perl ../bin/$perlcmd"; my $diffimg = "$tmpdir/${script}_diff$index.hdr"; my $uval = &compare_images("$cshout", "$perlout", "$diffimg"); @@ -46,8 +61,11 @@ system "ximage $diffimg"; } else { print " Ok: Images $cshout and $perlout are identical.\n"; + $fail++; } } + +print "$fail of $total tests failed.\n"; print "temp dir $tmpdir not removed. Please remove manually.\n"; sub compare_images() {