1 |
|
2 |
######################################################## |
3 |
# |
4 |
# Copyright (c) 2003-2008 by University of Queensland |
5 |
# Earth Systems Science Computational Center (ESSCC) |
6 |
# http://www.uq.edu.au/esscc |
7 |
# |
8 |
# Primary Business: Queensland, Australia |
9 |
# Licensed under the Open Software License version 3.0 |
10 |
# http://www.opensource.org/licenses/osl-3.0.php |
11 |
# |
12 |
######################################################## |
13 |
|
14 |
__copyright__="""Copyright (c) 2003-2008 by University of Queensland |
15 |
Earth Systems Science Computational Center (ESSCC) |
16 |
http://www.uq.edu.au/esscc |
17 |
Primary Business: Queensland, Australia""" |
18 |
__license__="""Licensed under the Open Software License version 3.0 |
19 |
http://www.opensource.org/licenses/osl-3.0.php""" |
20 |
__url__="https://launchpad.net/escript-finley" |
21 |
|
22 |
import sys, os, time, glob, fnmatch, types, py_compile, re |
23 |
|
24 |
from SCons.Script.SConscript import SConsEnvironment |
25 |
|
26 |
# Code to build .pyc from .py |
27 |
def build_py(target, source, env): |
28 |
py_compile.compile(str(source[0]), str(target[0])) |
29 |
return 0 |
30 |
|
31 |
# Code to run unit_test executables |
32 |
def runUnitTest(target, source, env): |
33 |
time_start = time.time() |
34 |
app = str(source[0].abspath) |
35 |
pn, sn= os.path.split(app) |
36 |
if not os.name== "nt": |
37 |
app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -bv "+os.path.join('.',sn) |
38 |
else: |
39 |
if env['usempi']: |
40 |
app = "cd %s | mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\ |
41 |
"FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s"\ |
42 |
%(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn) |
43 |
else: |
44 |
app = "cd "+ pn +" | "+ sn |
45 |
print "Executing test: " + app |
46 |
if not env.Execute(app): |
47 |
open(str(target[0]),'w').write("PASSED\n") |
48 |
else: |
49 |
return 1 |
50 |
print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath) |
51 |
return None |
52 |
|
53 |
def runPyUnitTest(target, source, env): |
54 |
time_start = time.time() |
55 |
app = str(source[0].abspath) |
56 |
pn, sn= os.path.split(app) |
57 |
if os.name== "nt": |
58 |
if env['usempi']: |
59 |
app = "cd %s | mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\ |
60 |
"FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\ |
61 |
%(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn) |
62 |
else: |
63 |
app = "cd "+ pn +" | "+sys.executable + " " + sn |
64 |
else: |
65 |
app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -ov "+sn |
66 |
print "Executing test: ",app |
67 |
if env.Execute(app) == 0: |
68 |
open(str(target[0]),'w').write("PASSED\n") |
69 |
else: |
70 |
return 1 |
71 |
print "Test execution time: ", round(time.time() - time_start, 1), " seconds wall time for " + str(source[0].abspath) |
72 |
return None |
73 |
|
74 |
def eps2pdf(target, source, env): |
75 |
if env.Execute("epstopdf "+str(source[0].abspath)+" -o "+str(target[0].abspath))!=0: |
76 |
return 1 |
77 |
return None |
78 |
|
79 |
def effectiveName(inname): |
80 |
m=re.compile("^r1i[0-9]{1,2}n[0-9]{1,2}$") # savanna names take the form r1i?n? |
81 |
if m.match(inname): |
82 |
return "service0" |
83 |
return inname |