tests/xyzimage_test.pl
author Axel Jacobs <axel@jaloxa.eu>
Mon, 14 Apr 2014 22:21:35 +0100
changeset 74 196d637b14b5
parent 27 eef8e42d689c
permissions -rw-r--r--
New Radiance fitting with spaces in file name

#!/usr/bin/perl

# xyzimage_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, 28 June 2011

use strict;
use warnings;

my $script = "xyzimage";
my $csh = "../orig/$script.csh";
my $perl = "../bin/$script.perl";
print "script: $script\n";

my $img = "data/images/street-xyze_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 = (
	["", "$img"],
	["", "-g 1.0 $img"],
	["", "-p 0.65 0.25  0.15 0.75  0.15 0.2  0.4 0.35 $img"],
	["", "-p 0.5 0.25  0.15 0.75  0.15 0.2  0.4 0.35 $img"],
);

# Run old CSH and new Perl script with different options,
# compare the resulting images.
my $total = 0;
my $fail = 0;
my $index = 0;
my $opts;
foreach $opts (@options) {
	# Hmm, not sure how to compare old and new automatically without screen-shooting.
	my $stdin = @$opts[0];
	my $args = @$opts[1];
	$total++;

	my $cshcmd = "$script.csh $args";
	print " $stdin $cshcmd\n";
	system "$stdin csh ../orig/$cshcmd >/dev/null &";

	my $perlcmd = "$script.pl $args";
	print " $stdin $perlcmd\n";
	system "$stdin perl ../bin/$perlcmd >/dev/null &";

	print "    Please compare the two rvu displays. Are they identical [y/N]? ";
	my $identical = <>;
	chomp $identical;
	if( lc( $identical ) eq 'y' ) {
		print "      Ok: Output appears to be identical.\n";
	} else {
		print "      Error: Output appears to be different.\n";
		$fail++;
	}
}

print "$fail of $total tests failed.\n";

#EOF