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

Contents of /trunk/site_scons/grouptest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4078 - (show annotations)
Fri Nov 16 07:50:49 2012 UTC (6 years, 7 months ago) by jfenwick
File MIME type: text/x-python
File size: 4401 byte(s)
Unit tests for binary install with no scons and no source tree.
Script for installing and testing a .deb within a chroot.



1 ##############################################################################
2 #
3 # Copyright (c) 2003-2012 by University of Queensland
4 # http://www.uq.edu.au
5 #
6 # Primary Business: Queensland, Australia
7 # Licensed under the Open Software License version 3.0
8 # http://www.opensource.org/licenses/osl-3.0.php
9 #
10 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 # Development since 2012 by School of Earth Sciences
12 #
13 ##############################################################################
14
15 __copyright__="""Copyright (c) 2003-2012 by University of Queensland
16 http://www.uq.edu.au
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
23
24 class GroupTest:
25 def __init__(self, exec_cmd, evars, python_dir, working_dir, test_list, single_processor_only=False):
26 self.python_dir=python_dir
27 self.working_dir=working_dir
28 self.test_list=test_list
29 self.exec_cmd=exec_cmd
30 self.evars=evars
31 self.mkdirs=[]
32 self.single_processor_only=single_processor_only
33
34 def makeDir(self,dirname):
35 self.mkdirs.append(dirname)
36
37 #stdloc means that the files are in standard locations so don't use prefix
38 def makeHeader(build_platform, prefix, stdloc):
39 res="#!/bin/bash\n"
40 res=res+"\n#############################################\n"
41 res=res+"# This file is autogenerated by scons.\n"
42 res=res+"# It will be regenerated each time scons is run\n"
43 res=res+"#############################################\n\n"
44 res=res+"function failed()\n{\n echo ""Execution failed for $@""\n exit 1\n}\n"
45 res=res+"if [ $# -ne 2 ]\nthen\n echo Usage: $0 build_dir wrapper_options\necho Runs all unit tests. Options must be a single string.\nexit 2\nfi\n"
46 res=res+'CMDSTR="getopt -uq -o p:n: -- $2"\nSTR=`$CMDSTR`\nNUMPROCS=1\n'
47 if stdloc:
48 res=res+'MPITYPE=`run-escript -c | grep mpi=`\n'
49 else:
50 res=res+'MPITYPE=`%s/bin/run-escript -c | grep mpi=`\n'%prefix
51 res=res+'NUMNODES=1\n#This little complication is required because set --\n'
52 res=res+'#does not seem to like -n as the first positional parameter\n'
53 res=res+'STATE=0\nfor name in $STR\ndo \n'
54 res=res+'case $STATE in\n'
55 res=res+' 0) case $name in\n'
56 res=res+' -n) STATE=1;;\n'
57 res=res+' -p) STATE=2;;\n'
58 res=res+' --) break 2;;\n'
59 res=res+' esac;;\n'
60 res=res+' 1) if [ $name == "--" ];then break; fi; NUMNODES=$name; STATE=0;;\n'
61 res=res+' 2) if [ $name == "--" ];then break; fi; NUMPROCS=$name; STATE=0;;\n'
62 res=res+' esac\n'
63 res=res+'done\n'
64 res=res+'let MPIPROD="$NUMPROCS * $NUMNODES"\n'
65 if not stdloc:
66 res=res+"\nexport LD_LIBRARY_PATH=%s/lib:$LD_LIBRARY_PATH\n"%prefix
67 if build_platform=='darwin':
68 res=res+"export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH\n"
69 if stdloc:
70 res=res+"\nexport OLD_PYTHON=$PYTHONPATH\nBINRUNNER=\"run-escript -b $2\"\nPYTHONRUNNER=\"run-escript $2\"\nBATCH_ROOT=`pwd`\n"
71 else:
72 res=res+"\nexport OLD_PYTHON=%s:$PYTHONPATH\nBINRUNNER=\"%s/bin/run-escript -b $2\"\nPYTHONRUNNER=\"%s/bin/run-escript $2\"\nBATCH_ROOT=`pwd`\n"%(prefix,prefix,prefix)
73 res=res+"BUILD_DIR=$1"+"/"+build_platform
74 res=res+"\nif [ ! -d $BUILD_DIR ]\nthen\n echo Can not find build directory $BUILD_DIR\n exit 2\nfi\n"
75 #res=res+"if [ $# -lt 2 ]\nthen\n echo Usage: $0 bin_run_cmd python_run_cmd\n exit 2\nfi\n"
76 return res
77 makeHeader=staticmethod(makeHeader)
78
79 def makeString(self):
80 res=""
81 if self.single_processor_only:
82 res+="#if [ $MPIPROD -le 1 ]; then\n"
83 res+='if [$MPITYPE" == "mpi=none" ]; then\n'
84 tt="\t"
85 else:
86 tt=""
87 for d in self.mkdirs:
88 res=res+tt+"if [ ! -d "+str(d)+" ]\n"+tt+"then\n"+tt+"\tmkdir "+d+"\n"+tt+"fi\n"
89 for v in self.evars:
90 res=res+tt+"export "+str(v[0])+"="+str(v[1])+"\n"
91 if len(self.python_dir)>0:
92 res=res+tt+"export PYTHONPATH="+self.python_dir+":$OLD_PYTHON"+"\n"+tt+"cd "+self.working_dir+"\n"
93 else:
94 res=res+tt+"export PYTHONPATH=$OLD_PYTHON"+"\n"+tt+"cd "+self.working_dir+"\n"
95 for t in self.test_list:
96 res=res+tt+"echo Starting "+t+"\ndate\n"
97 res=res+tt+self.exec_cmd+' '+t+' || failed '+t+'\n'
98 res=res+tt+"echo Completed "+t+"\n"
99 if self.single_processor_only:
100 res+="fi\n"
101 res=res+"\n"
102 return res
103

  ViewVC Help
Powered by ViewVC 1.1.26