-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSuite_build.py
More file actions
161 lines (115 loc) · 5.67 KB
/
Copy pathTestSuite_build.py
File metadata and controls
161 lines (115 loc) · 5.67 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/python
#import python modules
import os
import sys
import subprocess
#import local, application specific modules
from TestSuite_dirs import root, root_app, src, bin, run, binSerial, binParallel
from TestSuite_dirs import src_root, SVNURL, cfgs
from TestSuite_dirs import UM, offline
from TestSuite_dirs import UMrun, UMsrc, UMjobID, UMjobScripts, UMjobScriptsHome
from TestSuite_dirs import TestUM, TestSerial, TestMPI, user, project, home
def TestSuite_builder( cfg ):
###############################################################################
# mkdir structure
print "mkdir structure\n"
cmd = ("/bin/mkdir -p " + root_app )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
cmd = ("/bin/mkdir -p " + src )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
cmd = ("/bin/mkdir -p " + bin )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
cmd = ("/bin/mkdir -p " + binSerial )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
cmd = ("/bin/mkdir -p " + binParallel )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
cmd = ("/bin/mkdir -p " + run )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
for i in range( len( cfg.path ) ):
cmd = ("/bin/mkdir -p " + run + "/" + cfg.path[i] )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
################################################################################
# checkout src_root (or URL to test - remove hardwiring)
os.chdir(src)
#use this on raijin
cmd = ("/usr/bin/svn co " + SVNURL )
#jiggle
#cmd = ("/opt/subversion/bin/svn co " + SVNURL )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
###############################################################################
with open(root + "/log", "a") as myfile:
myfile.write("BUILDS:\n\n")
myfile.write("Serial:\n")
###############################################################################
# build models
# overwrite build scripts checked out
cmd = ("/bin/cp " + root + "/build.ksh " + offline )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
cmd = ("/bin/cp " + root + "/build_mpi.ksh " + offline )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
# serial version
if TestSerial is True:
# offline
os.chdir(offline)
print "build serial model\n"
cmd = ("./build.ksh debug >> " + root + "/log" )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
print "build serial model finished\n"
cmd = ("/bin/cp cable " + binSerial )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
print "copied serial executable to the bin/ directory\n"
cmd = ("/bin/rm -fr .tmp" )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
with open(root + "/log", "a") as myfile:
myfile.write("\n\nParallel:\n")
# parallel version
if TestMPI is True:
# offline
os.chdir(offline)
print "build Parallel model\n"
cmd = ("./build_mpi.ksh >> " + root + "/log" )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
print "build parallel model finished\n"
cmd = ("/bin/cp cable-mpi " + binParallel )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
print "copied parallel executable to the bin/ directory\n"
# UM
if TestUM is True:
with open(root + "/log", "a") as myfile:
myfile.write("Build libcable first....\n\n")
os.chdir(UM)
#cmd = ("./build.ksh debug >> " + root + "/log" )
#p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
with open(root + "/log", "a") as myfile:
myfile.write("Then move to UM build....\n\n")
# cp UM jobscripts to execute from
cmd = ("/bin/cp -r " + root + "/" + UMjobScripts + " " + UMjobScriptsHome )
print "Copying " + root + "/" + UMjobScripts +" to " + UMjobScriptsHome
cmd = ("/bin/cp -r " + root + "/" + UMjobScripts + " " + UMjobScriptsHome )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
# cp UM Extracted src directory
print "Copying " + root + "/" + UMjobID +" to " + UMsrc
cmd = ("/bin/cp -r -p " + root + "/" + UMjobID + " " + UMsrc )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
os.chdir( UMjobScriptsHome )
# BUild UM
cmd = ("./umuisubmit_compile > " + root + "/um_buildlog")
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
################################################################################
def CleanSlate():
#check we are even writing this anymore
cmd = ("/bin/rm -fr " + root_app + " log" )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True )
# remove UM job scripts directory
cmd = ("/bin/rm -fr " + UMjobScriptsHome )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
# remove UM run directory
cmd = ("/bin/rm -fr " + UMrun )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
# remove UM src directory
cmd = ("/bin/rm -fr " + UMsrc )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
# remove all logs generated by previous use
cmd = ("/bin/rm -f " + root + "/*log*" )
p = subprocess.check_call(cmd, stdout=subprocess.PIPE, shell=True)
################################################################################