38 |
# Runs ff3d on the program given as parameter |
# Runs ff3d on the program given as parameter |
39 |
|
|
40 |
sub Run{ |
sub Run{ |
41 |
my ($program) = @_; |
my ($program,$name) = @_; |
42 |
|
|
43 |
# Writes the program into a file for ff3d to read. |
# The program can be provided either as a full program text, or as |
44 |
open PROGRAM,"> test.ff"; |
# a file name. |
45 |
print PROGRAM $program; |
if(defined $name){ |
46 |
close PROGRAM; |
die "File $name not here" unless -f $name; |
47 |
|
} |
48 |
|
else{ |
49 |
|
# Writes the program into a file for ff3d to read. |
50 |
|
$name = 'test.ff'; |
51 |
|
open PROGRAM,"> $name"; |
52 |
|
print PROGRAM $program; |
53 |
|
close PROGRAM; |
54 |
|
} |
55 |
|
|
56 |
|
# Where to find the executable |
57 |
|
# Default value |
58 |
|
$ff3d = 'ff3d'; |
59 |
|
# Inside the automake procedure |
60 |
|
$ff3d = "$ENV{top_srcdir}/ff3d" if defined $ENV{top_srcdir}; |
61 |
|
# User-defined environment |
62 |
|
$ff3d = $ENV{FF3DTEST} if defined $ENV{FF3DTEST}; |
63 |
|
|
64 |
|
die "$ff3d not found - please define FF3DTEST" unless -f $ff3d; |
65 |
|
|
66 |
# Runs ff3d and stores its output into $output |
# Runs ff3d, displays its output but also stores it into $output. |
67 |
$output = `../ff3d test.ff`; |
|
68 |
|
print "*** check.pl: using \"$ff3d\"\n"; |
69 |
|
system "$ff3d $name | tee test.out"; |
70 |
if($?){ |
if($?){ |
71 |
print $output; |
print $output; |
72 |
die "*** ff3d crashed"; |
die "*** ff3d crashed"; |
73 |
} |
} |
74 |
|
die "$$ff3d produced no output" unless -f 'test.out'; |
75 |
|
$output = `cat test.out`; |
76 |
} |
} |
77 |
|
|
78 |
# Checks that one expected result (expressed as a regexp) is present |
# Checks that one expected result (expressed as a regexp) is present |
138 |
# Final report, after all checks have been done on one ff3d run. |
# Final report, after all checks have been done on one ff3d run. |
139 |
|
|
140 |
sub Report{ |
sub Report{ |
141 |
if($errors > 0){ |
die "*** $errors error(s)" if $errors > 0; |
|
print "*** Erroneous output:\n"; |
|
|
print $output; |
|
|
print "*** $errors error(s)\n"; |
|
|
die; |
|
|
} |
|
142 |
} |
} |
143 |
|
|
144 |
# Builds the given povray scene, read it in ff3d and checks wether the |
# Builds the given povray scene, read it in ff3d and checks wether the |