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