tests/xyzimage_test.pl
author Axel Jacobs <axel@jaloxa.eu>
Mon, 10 Mar 2014 20:16:57 +0000
changeset 58 e4892d4ef026
parent 27 eef8e42d689c
permissions -rw-r--r--
ltpict: Minor readability changes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     1
#!/usr/bin/perl
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     2
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     3
# xyzimage_test.pl
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     4
# This file is part of the testsuite of the Radiance csh2perl project.
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     5
# You may copy and modify this file as basis for other tests.
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     6
#
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     7
# (c) Axel Jacobs, 28 June 2011
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     8
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     9
use strict;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    10
use warnings;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    11
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    12
my $script = "xyzimage";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    13
my $csh = "../orig/$script.csh";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    14
my $perl = "../bin/$script.perl";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    15
print "script: $script\n";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    16
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    17
my $img = "data/images/street-xyze_rle_400x400.hdr";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    18
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    19
# Options are arrays of [STDIN, command-line options].
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    20
# Please include the pipe symbol as part of STDIN.
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    21
# Put a leading space in front of STDIN to line up the output.
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    22
my @options = (
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    23
	["", "$img"],
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    24
	["", "-g 1.0 $img"],
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    25
	["", "-p 0.65 0.25  0.15 0.75  0.15 0.2  0.4 0.35 $img"],
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    26
	["", "-p 0.5 0.25  0.15 0.75  0.15 0.2  0.4 0.35 $img"],
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    27
);
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    28
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    29
# Run old CSH and new Perl script with different options,
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    30
# compare the resulting images.
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    31
my $total = 0;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    32
my $fail = 0;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    33
my $index = 0;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    34
my $opts;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    35
foreach $opts (@options) {
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    36
	# Hmm, not sure how to compare old and new automatically without screen-shooting.
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    37
	my $stdin = @$opts[0];
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    38
	my $args = @$opts[1];
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    39
	$total++;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    40
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    41
	my $cshcmd = "$script.csh $args";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    42
	print " $stdin $cshcmd\n";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    43
	system "$stdin csh ../orig/$cshcmd >/dev/null &";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    44
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    45
	my $perlcmd = "$script.pl $args";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    46
	print " $stdin $perlcmd\n";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    47
	system "$stdin perl ../bin/$perlcmd >/dev/null &";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    48
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    49
	print "    Please compare the two rvu displays. Are they identical [y/N]? ";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    50
	my $identical = <>;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    51
	chomp $identical;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    52
	if( lc( $identical ) eq 'y' ) {
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    53
		print "      Ok: Output appears to be identical.\n";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    54
	} else {
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    55
		print "      Error: Output appears to be different.\n";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    56
		$fail++;
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    57
	}
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    58
}
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    59
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    60
print "$fail of $total tests failed.\n";
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    61
eef8e42d689c Added test for xyzimage.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    62
#EOF