source: /cluster/svnroot/bccd-ng/branches/leemasa-devel/trees/home/bccd/tests/bccd_tests.pm @ 2498

Last change on this file since 2498 was 2498, checked in by leemasa, 11 years ago

Added the bccd_tests perl module to hold the tests to be used by the test suite.

File size: 2.4 KB
Line 
1#Functions for the Automagic BCCD test suite!
2
3#Output to stdout and to data file
4sub output{
5        (my $OUTPUT, my $string) = @_;
6        print $string;
7        print $OUTPUT $string;
8}
9
10#Create the shell command to store output from a given test
11sub generate_storeOutput{
12        (my $testname) = @_;
13        my $path = `pwd`;
14        chop $path;
15        return ">> $path/$testdir/$testname.dat 2>> $path/$testdir/$testname.dat";
16}
17
18#Collect meaningful information from the syncdir command
19sub get_syncdir{
20        (my $tmpoutput) = @_;
21        open(FILE, "<$tmpoutput") or die "could not open temporary file: $!";
22        my $tmp = "";
23        while ($tmp !~ m/\//){
24                $tmp = readline FILE;
25        }
26        my $startindex = index($tmp,"/",);
27        my $endindex = index($tmp," ",$startindex);
28        my $syncdir = substr($tmp,$startindex,$endindex-1);
29        close FILE;
30        unlink("tmpdir") or die "Could not delete temporary directory: $!";
31        return $syncdir;
32}
33
34%tests = (
35                'Gal' => sub { #Test GalaxSee
36                (my $testname) = @_;
37                open(OUTPUT, "<$testdir/$testname.dat") or die "could not open data file: $!";
38                my $storeOutput = generate_storeOutput($testname);
39                system("cd ~/Gal                        $storeOutput
40                        make clean                      $storeOutput
41                        make                            $storeOutput
42                        mpirun -np 1 ~/Gal/GalaxSee     $storeOutput
43                        mpirun -np 2 ~/Gal/GalaxSee     $storeOutput");
44
45                if (`wc -l ~/machines` > 1){
46                system("bccd-syncdir . ~/machines       &> tmpoutput");
47
48                system("cat tmpoutput $storeOutput");
49
50#get path to temporary directory
51                get_syncdir("tmpoutput");
52                unlink "tmpoutput";
53
54                system("mpirun -machinefile ~/machines\
55                        -np 2 $tempDirectory/GalaxSee   $storeOutput");
56                }
57                else{
58                        output (OUTPUT, "Machinefile has too few machines: skipping multiprocessor test");
59
60                }
61                },
62
63'Life' => sub { #Test Conway's Game of Life
64        (my $testname) = @_;
65        open(OUTPUT, "<$testdir/$testname.dat") or die "could not open data file: $!";
66        my $storeOutput = generate_storeOutput($testname);
67       
68        system("cd ~/Life               $storeOutput
69                        make clean                      $storeOutput
70                       
71                        make                            $storeOutput
72                        mpirun -np 1 ~/Life/Life        $storeOutput
73                        mpirun -np 2 ~/Life/Life        $storeOutput");
74       
75        if (`wc -l ~/machines` > 1){
76                system("bccd-syncdir . ~/machines       &> tmpoutput");
77                system("cat tmpoutput $storeOutput");
78
79#get path to temporary directory
80                get_syncdir("tmpoutput");
81                unlink "tmpoutput";
82
83                system("mpirun -machinefile ~/machines\
84                                -np 2 $tempDirectory/Life       $storeOutput");
85                }
86                else{
87                        output (OUTPUT, "Machinefile has too few machines: skipping multiprocessor test");
88                }
89})
Note: See TracBrowser for help on using the repository browser.