{
return undef; # userSupplied is invalid -> FAIL
}
}
# Simple Case : "t" is a subdirectory of the current directory
if ( -d "./t" )
{
return "./t";
}
# To be honest I don't understand which case satisfies the
# original code in test.pl : when $tstdir == `pwd` w.r.t.
# $tstdir =~ s|^(.*)/([^/]+)/?$|$1/$2|; and if (-d "../../$2/t")
# Assuming pwd is "/a/b/c/d/e" then we are testing for "/a/b/c/e/t"
# if I understand the code correctly (a big assumption)
# Simple Case : the current directory is "t"
my $pwd = cwd();
if ( $pwd =~ m|/t$| )
{
return $pwd;
# The alternate that might work better is
# chdir( ".." );
# return "./t";
# As the current test harnesses assume the application
# to be tested is in the current directory (ie "./check_disk ....")
}
return undef;
}
sub TestsFrom
{
my( $directory, $excludeIfAppMissing ) = @_;
$excludeIfAppMissing = 0 unless defined( $excludeIfAppMissing );
if ( ! opendir( DIR, $directory ) )
{
print STDERR "NPTest::TestsFrom() - Failed to open ${directory} : $!\n";
return ();
}
my( @tests ) = ();
my $filename;
my $application;
while ( $filename = readdir( DIR ) )
{
if ( $filename =~ m/\.t$/ )
{
if ( $excludeIfAppMissing )
{
$application = basename( $filename, ".t" );
if ( ! -e $application )
{
print STDERR "No application (${application}) found for test harness (${filename})\n";
next;
}
}
push @tests, "${directory}/${filename}";
}
}
closedir( DIR );
return sort @tests;
}
# All the new object oriented stuff below
sub new {
my $type = shift;
my $self = {};
return bless $self, $type;
}
# Accessors
sub return_code {
my $self = shift;
if (@_) {
return $self->{return_code} = shift;
} else {
return $self->{return_code};
}
}
sub output {
my $self = shift;
if (@_) {
return $self->{output} = shift;
} else {
return $self->{output};
}
}
sub perf_output {
=6= |