9 |
|
# newtest() : Initiate a testing sequence |
10 |
|
# verify(actual_result_file, expected_result_file) : compare two files |
11 |
|
# verifydir(dir) : Check existence of the directory |
12 |
+ |
# verifyexists(file) : Verify the existence of file |
13 |
|
# datadir([dir]) : return the current data directory (set it to dir if supplied) |
14 |
< |
# ------------------- Private Methods ---------------------------------- |
14 |
> |
# testfail(string) : report that current test has failed |
15 |
> |
# testpass(string) : report that current test has passed |
16 |
|
# newfilename() : return a new filename that can be opened etc. |
17 |
|
# temparea() : return a directory for building temporary stuff |
18 |
|
# newobject(@args) : Set up a new object to be tested |
19 |
|
# testinterface($name,@args) : perform interface tests for $name with @args |
20 |
|
# expect(string) : tell the testinterface of any expected return values |
21 |
|
# clearexpect() : Reset any expect variables. |
22 |
+ |
#cleantemp() : delete the temporary area |
23 |
|
|
24 |
|
package TestClass; |
25 |
|
require 5.004; |
55 |
|
$self->{class}=$module; |
56 |
|
$self->{"datadir"}=$datadir; |
57 |
|
$self->{filenumber}=0; |
58 |
< |
$self->{temparea}="/tmp/SCRAMtest"; |
58 |
> |
$self->{temparea}="/tmp/SCRAMtest++"; |
59 |
|
use File::Path; |
60 |
|
mkpath ($self->{temparea},0, 0777); |
61 |
|
|
111 |
|
open ( FILE1, "<$file1" ) or die "Cannot Read Test Output $file1 $!\n"; |
112 |
|
open ( FILE2, "<$file2" ) or die "Cannot Read Benchmark file ". |
113 |
|
"$file2 $!\n"; |
114 |
< |
while ( $f1=<FILE1> ) { |
115 |
< |
$f2=<FILE2>; |
116 |
< |
if ( $f2 ne $f1 ) { |
117 |
< |
print "T:\n$f1\nB:$f2\n"; |
114 |
> |
while ( $f1=<FILE2> ) { |
115 |
> |
$f2=<FILE1>; |
116 |
> |
if ( (!defined $f2 ) || ( ! defined $f1) || ($f2 ne $f1 )) { |
117 |
> |
#print "T:\n$f1\nB:$f2\n"; |
118 |
|
$same=0; |
119 |
|
} |
120 |
|
} |
130 |
|
my $name=shift; |
131 |
|
|
132 |
|
if ( -d "$name" ) { |
133 |
< |
$self->testpass(""); |
133 |
> |
$self->testpass("Directory $name exists - test passed"); |
134 |
|
} |
135 |
|
else { |
136 |
|
$self->testfail("Directory $name does not exist"); |
137 |
|
} |
138 |
|
} |
139 |
|
|
140 |
+ |
sub verifyexists { |
141 |
+ |
my $self=shift; |
142 |
+ |
my $name=shift; |
143 |
+ |
|
144 |
+ |
if ( -f "$name" ) { |
145 |
+ |
$self->testpass("File $name exists - test passed"); |
146 |
+ |
} |
147 |
+ |
else { |
148 |
+ |
$self->testfail("File $name does not exist"); |
149 |
+ |
} |
150 |
+ |
} |
151 |
+ |
|
152 |
|
sub testfail { |
153 |
|
my $self=shift; |
154 |
|
my $string=shift; |
247 |
|
if ( ! defined $myreturn ) { |
248 |
|
print "Undefined Value Passed Back\n"; |
249 |
|
} |
250 |
< |
elsif ( \$myreturn=~/HASH/ ) { |
251 |
< |
print "Hash Refreturned\n"; |
250 |
> |
elsif ( $myreturn=~/HASH/ ) { |
251 |
> |
print "Hash Ref returned\n"; |
252 |
|
} |
253 |
< |
elsif ( \$myreturn=~/CODE/ ) { |
253 |
> |
elsif ( $myreturn=~/CODE/ ) { |
254 |
|
print "Code Ref returned\n"; |
255 |
|
} |
256 |
< |
elsif ( \$myreturn=~/ARRAY/ ) { |
256 |
> |
elsif ( $myreturn=~/ARRAY/ ) { |
257 |
|
print "Array Ref returned\n"; |
258 |
|
} |
259 |
|
else { |
380 |
|
} |
381 |
|
close SRCIN; |
382 |
|
} |
383 |
+ |
|
384 |
+ |
sub cleantemp { |
385 |
+ |
my $self=shift; |
386 |
+ |
use File::Path; |
387 |
+ |
rmtree($self->temparea()); |
388 |
+ |
} |