6 |
NUMJs=4 |
NUMJs=4 |
7 |
TOPDIR=str(datetime.date.today()) |
TOPDIR=str(datetime.date.today()) |
8 |
ERRMAIL="j.fenwick1@uq.edu.au" |
ERRMAIL="j.fenwick1@uq.edu.au" |
9 |
|
EXECUTELOCATION="/scratch/jfenwick/AUTOTESTS" |
10 |
|
OUTSIDEDIR=os.getcwd() |
11 |
|
|
12 |
|
#Settings for actual tests appear below the class declarations |
13 |
|
|
14 |
|
|
15 |
def failure(msg): |
def failure(msg): |
16 |
print "Terminating - Error "+str(msg) |
print "Terminating - Error "+str(msg) |
17 |
print "Should be sending mail to "+str(ERRMAIL) |
print "Should be sending mail to "+str(ERRMAIL) |
18 |
|
sys.exit(1) |
19 |
|
|
20 |
def progress(msg): |
def progress(msg): |
21 |
print msg |
print msg |
34 |
res=res+'MAIL_RECIPIENTS="'+ERRMAIL+'"\n' |
res=res+'MAIL_RECIPIENTS="'+ERRMAIL+'"\n' |
35 |
res=res+"function report()\n{\n" |
res=res+"function report()\n{\n" |
36 |
res=res+" NOW=`date '+%Y/%m/%d %H:%M'`\n" |
res=res+" NOW=`date '+%Y/%m/%d %H:%M'`\n" |
37 |
res=res+"cat <<END_MSG | mail -s \"Esys tests `date` $TESTSTATE\" $MAIL_RECIPIENTS\n" |
res=res+" cat > $LOGDIR/message << END_MSG\n" |
38 |
res=res+"Sucessful configurations:\n" |
res=res+"Sucessful configurations:\n" |
39 |
res=res+"$SUCCESSFUL\n\n" |
res=res+"$SUCCESSFUL\n\n" |
40 |
res=res+"Failed on configuration:\n" |
res=res+"Failed on configuration:\n" |
41 |
res=res+"$ATTEMPTED\n\n" |
res=res+"$ATTEMPTING\n\n" |
42 |
res=res+"Tests ran from $START until $NOW.\n" |
res=res+"Tests ran from $START until $NOW.\n" |
43 |
res=res+"Log files can be found in $TOP.\n" |
res=res+"Log files can be found in $TOP.\n" |
44 |
res=res+"This mail was sent from $SCRIPTNAME, running as $USER on `hostname`.\n" |
res=res+"This mail was sent from $SCRIPTNAME, running as $USER on `hostname`.\n" |
46 |
res=res+"}\n" |
res=res+"}\n" |
47 |
res=res+"function progress()\n{\n" |
res=res+"function progress()\n{\n" |
48 |
res=res+" echo $1\n" |
res=res+" echo $1\n" |
49 |
res=res+" cat $1 >> $LOGFILE\n" |
res=res+" echo $1 >> $PROGRESSFILE\n" |
50 |
res=res+"}\n" |
res=res+"}\n" |
51 |
res=res+"function failure()\n{\n echo $1\n" |
res=res+"function failure()\n{\n echo $1\n" |
52 |
res=res+" report\n" |
res=res+" report\n" |
53 |
res=res+" exit 1\n}\nTOP=`pwd`\nLOGFILE=$TOP/Logs\nOLDPYTH=$PYTHONPATH\nOLDLD=$LD_LIBRARY_PATH\n" |
res=res+" touch $LOGDIR/Failure\n" |
54 |
|
res=res+" exit 1\n}\nTOP=`pwd`\nLOGDIR=$TOP/Logs\nPROGRESSFILE=$LOGDIR/progress\nOLDPYTH=$PYTHONPATH\nOLDLD=$LD_LIBRARY_PATH\n" |
55 |
res=res+". /usr/share/modules/init/sh #So the module command works\n" |
res=res+". /usr/share/modules/init/sh #So the module command works\n" |
56 |
res=res+"module load subversion-1.3.1\nmodule load escript/current\nmodule load pbs\nmodule load mayavi/gcc-4.1.2/mayavi-1.5\n" |
res=res+"module load subversion-1.3.1\nmodule load escript/current\nmodule load pbs\nmodule load mayavi/gcc-4.1.2/mayavi-1.5\n" |
57 |
res=res+"module load mplayer/gcc-4.1.2/mplayer-1.0rc2\n\n" |
res=res+"module load mplayer/gcc-4.1.2/mplayer-1.0rc2\n\n" |
58 |
|
res=res+"SCRIPTNAME=$0\n" |
59 |
return res |
return res |
60 |
|
|
61 |
def toString(self): |
def toString(self): |
62 |
runcount=1 |
runcount=1 |
|
ref="cp -r "+self.name+"_src "+self.name+"_test"+str(runcount)+"\n" |
|
|
ref=ref+"cd "+self.name+"_test"+str(runcount)+"\n" |
|
|
ref=ref+"TESTROOT=`pwd`\n" |
|
63 |
for o in self.omp: |
for o in self.omp: |
64 |
for m in self.mpi: |
for m in self.mpi: |
65 |
cmd="bash utest.sh 'mpiexec -np"+str(m)+"' $TESTROOT/lib/pythonMPI" |
cmd="bash utest.sh 'mpiexec -np"+str(m)+"' $TESTROOT/lib/pythonMPI >$TESTLOGDIR/output 2>&1" |
66 |
ref=ref+"export OMP_NUM_THREADS="+str(o)+"\n" |
res="cp -r "+self.name+"_src "+self.name+"_test"+str(runcount)+"\n" |
67 |
ref=ref+"export PYTHONPATH=`pwd`:$OLDPYTH\n" |
res=res+"cd "+self.name+"_test"+str(runcount)+"\n" |
68 |
ref=ref+"export LD_LIBRARY_PATH=`pwd`/lib:$OLDLD\n" |
res=res+"TESTROOT=`pwd`\n" |
69 |
ref=ref+'RUNNAME="'+self.name+' omp='+str(o)+' mpi='+str(m)+'"\n' |
res=res+"TESTLOGDIR=$LOGDIR/"+self.name+"_test"+str(runcount)+"\n" |
70 |
ref=ref+'ATTEMPTING=$RUNNAME' |
res=res+"mkdir $TESTLOGDIR\n" |
71 |
ref=ref+'progress "Starting '+cmd+'"' |
res=res+"export OMP_NUM_THREADS="+str(o)+"\n" |
72 |
ref=ref+cmd+' || failure "'+cmd+'"\n' |
res=res+"export PYTHONPATH=`pwd`:$OLDPYTH\n" |
73 |
ref=ref+'SUCCESSFUL="$SUCCESSFUL, $RUNNAME"\n' |
res=res+"export LD_LIBRARY_PATH=`pwd`/lib:$OLDLD\n" |
74 |
ref=ref+'completed "'+cmd+'"' |
res=res+'RUNNAME="'+self.name+' omp='+str(o)+' mpi='+str(m)+'"\n' |
75 |
ref=ref+'ATTEMPTING=None\n' |
res=res+'ATTEMPTING=$RUNNAME\n' |
76 |
ref=ref+"export OMP_NUM_THREADS=1\n" |
res=res+'progress "Starting '+cmd+'"\n' |
77 |
|
res=res+cmd+' || failure "'+cmd+'"\n' |
78 |
|
res=res+'SUCCESSFUL="$SUCCESSFUL, $RUNNAME"\n' |
79 |
|
res=res+'progress "completed '+cmd+'"\n' |
80 |
|
res=res+'ATTEMPTING=None\n' |
81 |
|
res=res+"export OMP_NUM_THREADS=1\n" |
82 |
|
res=res+"cd $TOP\n" |
83 |
|
res=res+"rm -rf "+self.name+"_src "+self.name+"_test"+str(runcount)+"\n" |
84 |
++runcount |
++runcount |
85 |
if len(self.mpi)==0: |
if len(self.mpi)==0: |
86 |
cmd="bash utest.sh '' python" |
cmd="bash utest.sh '' python $TESTROOT/lib/pythonMPI >$TESTLOGDIR/output 2>&1" |
87 |
ref=ref+"export OMP_NUM_THREADS="+str(o)+"\n" |
res="cp -r "+self.name+"_src "+self.name+"_test"+str(runcount)+"\n" |
88 |
ref=ref+"export LD_LIBRARY_PATH=`pwd`/lib:$OLDLD\n" |
res=res+"cd "+self.name+"_test"+str(runcount)+"\n" |
89 |
ref=ref+"export PYTHONPATH=`pwd`:$OLDPYTH\n" |
res=res+"TESTROOT=`pwd`\n" |
90 |
ref=ref+'progress "Starting '+cmd+'"' |
res=res+"TESTLOGDIR=$LOGDIR/"+self.name+"_test"+str(runcount)+"\n" |
91 |
ref=ref+cmd+" || failure \""+cmd+"\" \n" |
res=res+"mkdir $TESTLOGDIR\n" |
92 |
ref=ref+'completed "'+cmd+'"' |
res=res+"export OMP_NUM_THREADS="+str(o)+"\n" |
93 |
|
res=res+"export LD_LIBRARY_PATH=`pwd`/lib:$OLDLD\n" |
94 |
|
res=res+"export PYTHONPATH=`pwd`:$OLDPYTH\n" |
95 |
|
res=res+'RUNNAME="'+self.name+' omp='+str(o)+' mpi=n/a"\n' |
96 |
|
res=res+'ATTEMPTING=$RUNNAME\n' |
97 |
|
res=res+'progress "Starting '+cmd+'"\n' |
98 |
|
res=res+cmd+" || failure \""+cmd+"\" \n" |
99 |
|
res=res+'ATTEMPTING=None\n' |
100 |
|
res=res+'progress "completed '+cmd+'"\n' |
101 |
|
res=res+"cd $TOP\n" |
102 |
|
res=res+"rm -rf "+self.name+"_src "+self.name+"_test"+str(runcount)+"\n" |
103 |
++runcount |
++runcount |
104 |
ref=ref+"\ncd $TOP\n\n" |
res=res+"\ncd $TOP\n\n" |
105 |
return ref |
return res |
106 |
|
|
107 |
|
def getFooter(): |
108 |
|
res="\ntouch $LOGDIR/Success\n" |
109 |
|
res=res+"report" |
110 |
|
return res |
111 |
|
|
112 |
getHeader=staticmethod(getHeader) |
getHeader=staticmethod(getHeader) |
113 |
|
getFooter=staticmethod(getFooter) |
114 |
|
|
115 |
|
#Test settings |
116 |
|
testconfs=[] |
117 |
|
testconfs.append(TestConfiguration("OMPNoMPI","",omp=(1,8),mpi=(),binexec="",pythonexec="python")) |
118 |
|
testconfs.append(TestConfiguration("MPI","usempi=yes",omp=(1,),mpi=(1,8),binexec="mpiexec -np ",pythonexec="lib/pythonMPI")) |
119 |
|
|
120 |
|
|
121 |
try: |
try: |
136 |
failure("Unable to export working copy") |
failure("Unable to export working copy") |
137 |
sys.exit(1) |
sys.exit(1) |
138 |
|
|
139 |
testconfs=[] |
|
|
testconfs.append(TestConfiguration("OMPNoMPI","",omp=(1,8),mpi=(),binexec="",pythonexec="python")) |
|
|
testconfs.append(TestConfiguration("MPI","usempi=yes",omp=(1,),mpi=(1,8),binexec="mpiexec -np ",pythonexec="lib/pythonMPI")) |
|
140 |
|
|
141 |
|
|
142 |
dir=os.getcwd() |
dir=os.getcwd() |
153 |
res=os.system(cmdstr) |
res=os.system(cmdstr) |
154 |
os.chdir(str(dir)) |
os.chdir(str(dir)) |
155 |
if res!=0: |
if res!=0: |
156 |
failure("Error running scons build failed for "+conf.name+"_src") |
failure("running scons build failed for "+conf.name+"_src") |
157 |
|
|
158 |
progress("Builds complete") |
progress("Builds complete") |
159 |
#print "Removing export copy" |
progress("Removing export copy") |
160 |
#shutil.rmtree("src",ignore_errors=True) |
shutil.rmtree("src",ignore_errors=True) |
161 |
progress("Building test file") |
progress("Building test file") |
162 |
|
|
163 |
try: |
try: |
170 |
failure("Creating testfile") |
failure("Creating testfile") |
171 |
|
|
172 |
progress("Building test file complete") |
progress("Building test file complete") |
173 |
|
progress("Copying files to exec area") |
174 |
|
os.chdir(OUTSIDEDIR) |
175 |
|
try: |
176 |
|
shutil.copytree(TOPDIR,EXECUTELOCATION) |
177 |
|
except IOError, OSError: |
178 |
|
failure("copying to work area") |
179 |
|
progress("Copy to exec area complete") |
180 |
|
|
181 |
print "Should be submitting this test now" |
print "Should be submitting this test now" |
182 |
raise "Test not submitted" |
|
183 |
|
os.chdir(EXECUTELOCATION) |
184 |
|
os.chdir(TOPDIR) |
185 |
|
try: |
186 |
|
res=os.system("bash dotests.sh") |
187 |
|
except OSError: |
188 |
|
failure("Running tests") |
189 |
|
|
190 |
|
try: |
191 |
|
shutil.copytree(EXECUTELOCATION+"/Logs",OUTSIDEDIR) |
192 |
|
except OSError: |
193 |
|
failure("Log copy failed") |
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
raise "Test not submitted - not cleaned up either" |
198 |
#Now we build the script and submit it pbs (that behaviour should be optional?) |
#Now we build the script and submit it pbs (that behaviour should be optional?) |