/[escript]/trunk/scons/grouptest.py
ViewVC logotype

Contents of /trunk/scons/grouptest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2508 - (show annotations)
Thu Jul 2 04:33:25 2009 UTC (10 years, 5 months ago) by jfenwick
File MIME type: text/x-python
File size: 3846 byte(s)
Ensured that example files are copied with build_py_tests rather than py_tests.
This means that:
build_full
will set up all the files ready for utest.sh
1 ########################################################
2 #
3 # Copyright (c) 2003-2008 by University of Queensland
4 # Earth Systems Science Computational Center (ESSCC)
5 # http://www.uq.edu.au/esscc
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 ########################################################
12
13 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
14 Earth Systems Science Computational Center (ESSCC)
15 http://www.uq.edu.au/esscc
16 Primary Business: Queensland, Australia"""
17 __license__="""Licensed under the Open Software License version 3.0
18 http://www.opensource.org/licenses/osl-3.0.php"""
19 __url__="https://launchpad.net/escript-finley"
20
21
22
23 class GroupTest:
24 def __init__(self, exec_cmd, evars, python_dir, working_dir, test_list, single_processor_only=False):
25 self.python_dir=python_dir
26 self.working_dir=working_dir
27 self.test_list=test_list
28 self.exec_cmd=exec_cmd
29 self.evars=evars
30 self.mkdirs=[]
31 self.single_processor_only=single_processor_only
32
33 def makeDir(self,dirname):
34 self.mkdirs.append(dirname)
35
36 def makeHeader(build_platform):
37 res="#!/bin/bash\n"
38 res=res+"\n#############################################\n"
39 res=res+"# This file is autogenerated by scons.\n"
40 res=res+"# It will be regenerated each time scons is run\n"
41 res=res+"#############################################\n\n"
42 res=res+"function failed()\n{\n echo ""Execution failed for $@""\n exit 1\n}\n"
43 res=res+"if [ $# -ne 1 ]\nthen\n echo Usage: $0 wrapper_options\necho Runs all unit tests. Options must be a single string.\nexit 2\nfi\n"
44 res=res+'CMDSTR="getopt -uq -o p:n: -- $1"\nSTR=`$CMDSTR`\nNUMPROCS=1\n'
45 res=res+'NUMNODES=1\n#This little complication is required because set --\n'
46 res=res+'#does not seem to like -n as the first positional parameter\n'
47 res=res+'STATE=0\nfor name in $STR\ndo \n'
48 res=res+'case $STATE in\n'
49 res=res+' 0) case $name in\n'
50 res=res+' -n) STATE=1;;\n'
51 res=res+' -p) STATE=2;;\n'
52 res=res+' --) break 2;;\n'
53 res=res+' esac;;\n'
54 res=res+' 1) if [ $name == "--" ];then break; fi; NUMNODES=$name; STATE=0;;\n'
55 res=res+' 2) if [ $name == "--" ];then break; fi; NUMPROCS=$name; STATE=0;;\n'
56 res=res+' esac\n'
57 res=res+'done\n'
58 res=res+'let MPIPROD="$NUMPROCS * $NUMNODES"\n'
59 res=res+"\nexport LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH\n"
60 if build_platform=='darwin':
61 res=res+"export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH\n"
62 res=res+"\nexport OLD_PYTHON=`pwd`:$PYTHONPATH\nBINRUNNER=\"`pwd`/bin/escript -b $1\"\nPYTHONRUNNER=\"`pwd`/bin/escript $1\"\nBATCH_ROOT=`pwd`\n"
63 res=res+"BUILD_DIR=$BATCH_ROOT/build/"+build_platform
64 res=res+"\nif [ ! -d $BUILD_DIR ]\nthen\n echo Can not find build directory $BUILD_DIR\n exit 2\nfi\n"
65 #res=res+"if [ $# -lt 2 ]\nthen\n echo Usage: $0 bin_run_cmd python_run_cmd\n exit 2\nfi\n"
66 return res
67 makeHeader=staticmethod(makeHeader)
68
69 def makeString(self):
70 res=""
71 if self.single_processor_only:
72 res+="if [ $MPIPROD -le 1 ]; then\n"
73 tt="\t"
74 else:
75 tt=""
76 for d in self.mkdirs:
77 res=res+tt+"if [ ! -d "+str(d)+" ]\n"+tt+"then\n"+tt+"\tmkdir "+d+"\n"+tt+"fi\n"
78 for v in self.evars:
79 res=res+tt+"export "+str(v[0])+"="+str(v[1])+"\n"
80 if len(self.python_dir)>0:
81 res=res+tt+"export PYTHONPATH="+self.python_dir+":$OLD_PYTHON"+"\n"+tt+"cd "+self.working_dir+"\n"
82 else:
83 res=res+tt+"export PYTHONPATH=$OLD_PYTHON"+"\n"+tt+"cd "+self.working_dir+"\n"
84 for t in self.test_list:
85 res=res+tt+"echo Starting "+t+"\n"
86 res=res+tt+self.exec_cmd+' '+t+' || failed '+t+'\n'
87 res=res+tt+"echo Completed "+t+"\n"
88 if self.single_processor_only:
89 res+="fi\n"
90 res=res+"\n"
91 return res
92

  ViewVC Help
Powered by ViewVC 1.1.26