judft_tests.pm 1.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
package judft_tests;
@EXPORT="";

use jt;

#This runs a single test
sub execute_test($$$$){
    my $testdir=shift;
    my $exec=shift;
    my $mpi=shift;
    $workdir=shift;

    #is this test ok for the current configuration?
    my ($stages,$test_name)=
               test_applicable($testdir,$exec);
    if ($stages>0) {
	$executable="$mpi $exec";
	my $starttime=time();
	jt::initlog($workdir,$test_name,$executable);
    #prepare the workdir
	if (-r $workdir){
	    system("rm -f $workdir/*");
	}else{
	    die "Invalid workdir:$workdir" if (system("mkdir $workdir"));
	}
    
	my $old_dir=`pwd`;
	chomp $old_dir;
	chdir("tests/$testdir");
        #run all stages of the test
	for(my $stage=1;$stage<=$stages;$stage++){
	    print "Stage: $stage / $stages\n";
Daniel Wortmann's avatar
Daniel Wortmann committed
33
		eval `cat test.run$stage`;
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
	}   
	chdir($old_dir);
	my $time=time()-$starttime;
	jt::stoplog($time);
    }
    jt::testresult($workdir);
}    
    

sub test_applicable($$){
    my $testdir=shift;
    my $exec=shift;   


    #read description of test
Daniel Wortmann's avatar
Daniel Wortmann committed
49 50 51 52 53 54 55 56 57 58 59 60 61
    eval `cat tests/$testdir/test.desc`;
    
    #open(DESC,"<tests/$testdir/test.desc") or die "Could not open tests/$testdir/test.desc";
    #LINE:while(<DESC>){
    #    next LINE if /^#/;  # discard comments
    #	if (/NAME:(.*)/){
    #	    $test_name=$1;
    #	}
    #	if (/STAGES:(.*)/){
    #	    $test_stages=$1*1;
    #	}
    #}
    #close(DESC);
62 63 64 65 66
    #check if executable name starts with code name
    #if (!($exec=~/^\Q$test_code\E/i)){
    #	return (0,"");
    #}
    #test requirements
67 68 69 70 71 72 73 74 75

#    if ($exec=~/_SOC/){
#	return (0,"") if ($test_requirements{"SOC"}==0);
#    }else{
#	return (0,"") if ($test_requirements{"SOC"}==1);
#    }
#    if ($exec=~/_INVS/){
#	return (0,"") if ($test_requirements{"complex"}==1);
#    }
Daniel Wortmann's avatar
Daniel Wortmann committed
76 77 78
#    if (!($exec=~/_MPI/)){
#	return (0,"") if ($test_requirements{"MPI"}==1);
#    }
79 80 81
    return ($test_stages,$test_name);
}