/[escript]/branches/lapack2681/scons/grouptest.py
ViewVC logotype

Diff of /branches/lapack2681/scons/grouptest.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/arrexp_2137_win_merge/scons/grouptest.py revision 2270 by jfenwick, Mon Feb 16 04:43:28 2009 UTC trunk/scons/grouptest.py revision 2504 by jfenwick, Wed Jul 1 07:27:17 2009 UTC
# Line 16  http://www.uq.edu.au/esscc Line 16  http://www.uq.edu.au/esscc
16  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
17  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
18  http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
19  __url__="http://www.uq.edu.au/esscc/escript-finley"  __url__="https://launchpad.net/escript-finley"
20    
21    
22    
23  class GroupTest:  class GroupTest:
24      def __init__(self, exec_cmd, evars, python_dir, working_dir, test_list):      def __init__(self, exec_cmd, evars, python_dir, working_dir, test_list, single_processor_only=False):
25      self.python_dir=python_dir      self.python_dir=python_dir
26      self.working_dir=working_dir      self.working_dir=working_dir
27      self.test_list=test_list      self.test_list=test_list
28      self.exec_cmd=exec_cmd      self.exec_cmd=exec_cmd
29      self.evars=evars      self.evars=evars
30      self.mkdirs=[]      self.mkdirs=[]
31            self.single_processor_only=single_processor_only
32            
33      def makeDir(self,dirname):      def makeDir(self,dirname):
34          self.mkdirs.append(dirname)          self.mkdirs.append(dirname)
35    
36      def makeHeader():      def makeHeader(build_platform):
37      res="#!/bin/bash\n"      res="#!/bin/bash\n"
38      res=res+"\n#############################################\n"      res=res+"\n#############################################\n"
39      res=res+"# This file is autogenerated by scons.\n"      res=res+"# This file is autogenerated by scons.\n"
40      res=res+"# It will be regenerated each time scons is run\n"      res=res+"# It will be regenerated each time scons is run\n"
41      res=res+"#############################################\n\n"      res=res+"#############################################\n\n"
42      res=res+"function failed()\n{\n  echo ""Execution failed for $@""\n  exit 1\n}\n"      res=res+"function failed()\n{\n  echo ""Execution failed for $@""\n  exit 1\n}\n"
43      res=res+"\n export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH\n"      res=res+'CMDSTR="getopt -uq -o p:n: -- $1"\nSTR=`$CMDSTR`\nNUMPROCS=1\n'
44      res=res+"\nexport OLD_PYTHON=`pwd`:$PYTHONPATH\nBINRUNNER=$1\nPYTHONRUNNER=\"$1 $2\"\nBATCH_ROOT=`pwd`\nBUILD_DIR=$BATCH_ROOT/build/posix\n"      res=res+'NUMNODES=1\n#This little complication is required because set --\n'
45      res=res+"if [ ! -d $BUILD_DIR ]\nthen\n echo Can not find build directory $BUILD_DIR\n exit 2\nfi\n"      res=res+'#does not seem to like -n as the first positional parameter\n'
46      res=res+"if [ $# -lt 2 ]\nthen\n echo Usage: $0 bin_run_cmd python_run_cmd\n exit 2\nfi\n"      res=res+'STATE=0\nfor name in $STR\ndo \n'
47        res=res+'case $STATE in\n'
48        res=res+'     0) case $name in\n'
49        res=res+'     -n) STATE=1;;\n'
50        res=res+'     -p) STATE=2;;\n'
51        res=res+'     --) break 2;;\n'
52        res=res+'        esac;;\n'
53        res=res+'     1) if [ $name == "--" ];then break; fi; NUMNODES=$name; STATE=0;;\n'
54        res=res+'     2) if [ $name == "--" ];then break; fi; NUMPROCS=$name; STATE=0;;\n'
55        res=res+'   esac\n'
56        res=res+'done\n'
57        res=res+'let MPIPROD="$NUMPROCS * $NUMNODES"\n'
58        res=res+"\nexport LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH\n"
59        if build_platform=='darwin':
60            res=res+"export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH\n"
61        res=res+"\nexport OLD_PYTHON=`pwd`:$PYTHONPATH\nBINRUNNER=\"`pwd`/bin/escript -b $1\"\nPYTHONRUNNER=\"`pwd`/bin/escript $1\"\nBATCH_ROOT=`pwd`\n"
62        res=res+"BUILD_DIR=$BATCH_ROOT/build/"+build_platform
63        res=res+"\nif [ ! -d $BUILD_DIR ]\nthen\n echo Can not find build directory $BUILD_DIR\n exit 2\nfi\n"
64        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"
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      return res
67      makeHeader=staticmethod(makeHeader)      makeHeader=staticmethod(makeHeader)
68    
69      def makeString(self):      def makeString(self):
70      res=""      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:      for d in self.mkdirs:
77          res=res+"if [ ! -d "+str(d)+" ]\nthen\n  mkdir "+d+"\nfi\n"          res=res+tt+"if [ ! -d "+str(d)+" ]\n"+tt+"then\n"+tt+"\tmkdir "+d+"\n"+tt+"fi\n"
78      for v in self.evars:      for v in self.evars:
79          res=res+"\nexport "+str(v[0])+"="+str(v[1])          res=res+tt+"export "+str(v[0])+"="+str(v[1])+"\n"
80      res=res+"\nexport PYTHONPATH="+self.python_dir+":$OLD_PYTHON"+"\n"+"cd "+self.working_dir+"\n"          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:      for t in self.test_list:
85          res=res+"echo Starting "+t+"\n"          res=res+tt+"echo Starting "+t+"\n"
86          res=res+self.exec_cmd+' '+t+' || failed '+t+'\n'          res=res+tt+self.exec_cmd+' '+t+' || failed '+t+'\n'
87          res=res+"echo Completed "+t+"\n"          res=res+tt+"echo Completed "+t+"\n"
88            if self.single_processor_only:
89                res+="fi\n"
90      res=res+"\n"      res=res+"\n"
91      return res      return res
92            

Legend:
Removed from v.2270  
changed lines
  Added in v.2504

  ViewVC Help
Powered by ViewVC 1.1.26