Added test for pdelta and raise status to 3.
authorAxel Jacobs <axel@jaloxa.eu>
Tue, 28 Jun 2011 21:16:09 +0100
changeset 29 1d4a7742ba50
parent 28 fb441526d581
child 30 a853d5280041
Added test for pdelta and raise status to 3.
status/pdelta.status
tests/pdelta_test.pl
--- a/status/pdelta.status	Tue Jun 28 21:07:15 2011 +0100
+++ b/status/pdelta.status	Tue Jun 28 21:16:09 2011 +0100
@@ -9,5 +9,5 @@
 # 3 .. port is complete and fully tested (comprehensive test script(s) under tests/)
 # 4 .. port has been included in Radiance HEAD
 
-STATUS = 1
+STATUS = 3
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/pdelta_test.pl	Tue Jun 28 21:16:09 2011 +0100
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+
+# pdelta_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 = "pdelta";
+my $csh = "../orig/$script.csh";
+my $perl = "../bin/$script.perl";
+print "script: $script\n";
+
+use File::Temp qw/ tempdir /;
+my $tmpdir = tempdir( CLEANUP => 0 );
+
+my $img1 = "data/images/street-rgbe_rle_400x400.hdr";
+my $img2 = "data/images/street2-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 = (
+		["", "$img1 $img2"],
+);
+
+# 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) {
+	my $stdin = @$opts[0];
+	my $args = @$opts[1];
+	$total++;
+
+	my $cshout = "$tmpdir/${script}_csh$index.hdr";
+	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 $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");
+	if( $uval > 0 ) {
+		print "      Error: Diff image $diffimg contains $uval unique values (should be one).\n";
+		system "ximage $diffimg";
+		$fail++;
+	} else {
+		print "      Ok: Images $cshout and $perlout are identical.\n";
+	}
+}
+
+print "$fail of $total tests failed.\n";
+print "temp dir $tmpdir not removed. Please remove manually.\n";
+
+sub compare_images() {
+	my $in1 = shift;
+	my $in2 = shift;
+	my $out = shift;
+
+	my $cmd = "pcomb $in1 -s -1 $in2 > $out";
+	print "    $cmd\n";
+	system "$cmd";
+	my $unique = `pvalue -h -H -d -u $out`;
+	my $unique_cnt = scalar( split( '\n', $unique ) );
+
+	return $unique_cnt;
+}
+
+#EOF