tests/objview_test.pl
changeset 21 3ea159f28920
equal deleted inserted replaced
20:a29baf51b980 21:3ea159f28920
       
     1 #!/usr/bin/perl
       
     2 
       
     3 # objview_test.pl
       
     4 # This file is part of the testsuite of the Radiance csh2perl project.
       
     5 # You may copy and modify this file as basis for other tests.
       
     6 #
       
     7 # (c) Axel Jacobs, 27 June 2011
       
     8 
       
     9 use strict;
       
    10 use warnings;
       
    11 
       
    12 my $script = "objview";
       
    13 my $csh = "../orig/$script.csh";
       
    14 my $perl = "../bin/$script.perl";
       
    15 print "script: $script\n";
       
    16 
       
    17 my $object = "data/objects/mybox.rad";
       
    18 my $material = "data/objects/objects.mat";
       
    19 
       
    20 # Options are arrays of [STDIN, command-line options].
       
    21 # Please include the pipe symbol as part of STDIN.
       
    22 # Put a leading space in front of STDIN to line up the output.
       
    23 my @options = (
       
    24 	["", "$material $object"],
       
    25 	# [" cat $material $object |", ""],   # The old csh script doesn't like STDIN
       
    26 	# Can't test OpenGL output on my system. Please add.
       
    27 );
       
    28 
       
    29 # Run old CSH and new Perl script with different options,
       
    30 # compare the resulting images.
       
    31 my $total = 0;
       
    32 my $fail = 0;
       
    33 my $index = 0;
       
    34 my $opts;
       
    35 foreach $opts (@options) {
       
    36 	# Hmm, not sure how to compare old and new automatically without screen-shooting.
       
    37 	my $stdin = @$opts[0];
       
    38 	my $args = @$opts[1];
       
    39 	$total++;
       
    40 
       
    41 	my $cshcmd = "$script.csh $args";
       
    42 	print " $stdin $cshcmd\n";
       
    43 	system "$stdin csh ../orig/$cshcmd >/dev/null &";
       
    44 
       
    45 	my $perlcmd = "$script.pl $args";
       
    46 	print " $stdin $perlcmd\n";
       
    47 	system "$stdin perl ../bin/$perlcmd >/dev/null &";
       
    48 
       
    49 	print "    Please compare the two rvu displays. Are they identical [y/N]? ";
       
    50 	my $identical = <>;
       
    51 	chomp $identical;
       
    52 	if( lc( $identical ) eq 'y' ) {
       
    53 		print "      Ok: Output appears to be identical.\n";
       
    54 	} else {
       
    55 		print "      Error: Output appears to be different.\n";
       
    56 		$fail++;
       
    57 	}
       
    58 }
       
    59 
       
    60 print "$fail of $total tests failed.\n";
       
    61 
       
    62 #EOF