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

Diff of /trunk/site_scons/grouptest.py

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

revision 4575 by jfenwick, Fri Mar 8 00:07:07 2013 UTC revision 4576 by sshaw, Mon Dec 9 23:35:30 2013 UTC
# Line 23  __url__="https://launchpad.net/escript-f Line 23  __url__="https://launchpad.net/escript-f
23    
24  class GroupTest(object):  class GroupTest(object):
25      def __init__(self, exec_cmd, evars, python_dir, working_dir, test_list, single_processor_only=False):      def __init__(self, exec_cmd, evars, python_dir, working_dir, test_list, single_processor_only=False):
26      self.python_dir=python_dir          self.python_dir=python_dir
27      self.working_dir=working_dir          self.working_dir=working_dir
28      self.test_list=test_list          self.test_list=test_list
29      self.exec_cmd=exec_cmd          self.exec_cmd=exec_cmd
30      self.evars=evars          self.evars=evars
31      self.mkdirs=[]          self.mkdirs=[]
32          self.single_processor_only=single_processor_only          self.single_processor_only=single_processor_only
33                
34      def makeDir(self,dirname):      def makeDir(self,dirname):
35          self.mkdirs.append(dirname)              self.mkdirs.append(dirname)
36    
37      #stdloc means that the files are in standard locations so don't use prefix      #stdloc means that the files are in standard locations so don't use prefix
38      def makeHeader(build_platform, prefix, stdloc):      def makeHeader(build_platform, prefix, stdloc):
39      res="#!/bin/bash\n"          res="#!/bin/bash\n"
40      res=res+"\n#############################################\n"          res=res+"\n#############################################\n"
41      res=res+"# This file is autogenerated by scons.\n"          res=res+"# This file is autogenerated by scons.\n"
42      res=res+"# It will be regenerated each time scons is run\n"          res=res+"# It will be regenerated each time scons is run\n"
43      res=res+"#############################################\n\n"          res=res+"#############################################\n\n"
44      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"
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"          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'          res=res+'CMDSTR="getopt -uq -o p:n: -- $2"\nSTR=`$CMDSTR`\nNUMPROCS=1\n'
47      if stdloc:          if stdloc:
48          res=res+'MPITYPE=`run-escript -c | grep mpi=`\n'              res=res+'MPITYPE=`run-escript -c | grep mpi=`\n'
49      else:          else:
50          res=res+'MPITYPE=`%s/bin/run-escript -c | grep mpi=`\n'%prefix              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'          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'          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'          res=res+'STATE=0\nfor name in $STR\ndo \n'
54      res=res+'case $STATE in\n'          res=res+'case $STATE in\n'
55      res=res+'     0) case $name in\n'          res=res+'     0) case $name in\n'
56      res=res+'     -n) STATE=1;;\n'          res=res+'          -n) STATE=1;;\n'
57      res=res+'     -p) STATE=2;;\n'          res=res+'          -p) STATE=2;;\n'
58      res=res+'     --) break 2;;\n'          res=res+'          --) break 2;;\n'
59      res=res+'        esac;;\n'          res=res+'        esac;;\n'
60      res=res+'     1) if [ $name == "--" ];then break; fi; NUMNODES=$name; STATE=0;;\n'          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'          res=res+'     2) if [ $name == "--" ];then break; fi; NUMPROCS=$name; STATE=0;;\n'
62      res=res+'   esac\n'          res=res+'   esac\n'
63      res=res+'done\n'          res=res+'done\n'
64      res=res+'let MPIPROD="$NUMPROCS * $NUMNODES"\n'          res=res+'let MPIPROD="$NUMPROCS * $NUMNODES"\n'
65      if not stdloc:          if not stdloc:
66          res=res+"\nexport LD_LIBRARY_PATH=%s/lib:$LD_LIBRARY_PATH\n"%prefix              res=res+"\nexport LD_LIBRARY_PATH=%s/lib:$LD_LIBRARY_PATH\n"%prefix
67      if build_platform=='darwin':          if build_platform=='darwin':
68          res=res+"export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH\n"                  res=res+"export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH\n"
69      if stdloc:          if stdloc:
70          res=res+"\nexport OLD_PYTHON=$PYTHONPATH\nBINRUNNER=\"run-escript -b $2\"\nPYTHONRUNNER=\"run-escript $2\"\nBATCH_ROOT=`pwd`\n"              res=res+"\nexport OLD_PYTHON=$PYTHONPATH\nBINRUNNER=\"run-escript -b $2\"\nPYTHONRUNNER=\"run-escript $2\"\nBATCH_ROOT=`pwd`\n"
71      else:          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)              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          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"          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"          #res=res+"if [ $# -lt 2 ]\nthen\n echo Usage: $0 bin_run_cmd python_run_cmd\n exit 2\nfi\n"
76      return res          return res
77      makeHeader=staticmethod(makeHeader)      makeHeader=staticmethod(makeHeader)
78    
79      def makeString(self):      def makeString(self):
80      res=""          res=""
81          if self.single_processor_only:          if self.single_processor_only:
82              res+="#if [ $MPIPROD -le 1 ]; then\n"              res+="#if [ $MPIPROD -le 1 ]; then\n"
83          res+='if [ "$MPITYPE" == "mpi=none" ]; then\n'              res+='if [ "$MPITYPE" == "mpi=none" ]; then\n'
84              tt="\t"              tt="\t"
85          else:          else:
86              tt=""              tt=""
87      for d in self.mkdirs:          for d in self.mkdirs:
88          res=res+tt+"if [ ! -d "+str(d)+" ]\n"+tt+"then\n"+tt+"\tmkdir "+d+"\n"+tt+"fi\n"              res=res+tt+"if [ ! -d "+str(d)+" ]\n"+tt+"then\n"+tt+"\tmkdir "+d+"\n"+tt+"fi\n"
89      for v in self.evars:          for v in self.evars:
90          res=res+tt+"export "+str(v[0])+"="+str(v[1])+"\n"              res=res+tt+"export "+str(v[0])+"="+str(v[1])+"\n"
91          if len(self.python_dir)>0:          if len(self.python_dir)>0:
92          res=res+tt+"export PYTHONPATH="+self.python_dir+":$OLD_PYTHON"+"\n"+tt+"cd "+self.working_dir+"\n"              res=res+tt+"export PYTHONPATH="+self.python_dir+":$OLD_PYTHON"+"\n"+tt+"cd "+self.working_dir+"\n"
93          else:          else:
94          res=res+tt+"export PYTHONPATH=$OLD_PYTHON"+"\n"+tt+"cd "+self.working_dir+"\n"              res=res+tt+"export PYTHONPATH=$OLD_PYTHON"+"\n"+tt+"cd "+self.working_dir+"\n"
95      for t in self.test_list:          for t in self.test_list:
96          res=res+tt+"echo Starting "+t+"\ndate\n"              res=res+tt+"echo Starting "+t+"\ndate\n"
97          res=res+tt+self.exec_cmd+' '+t+' || failed '+t+'\n'              res=res+tt+self.exec_cmd+' '+t+' || failed '+t+'\n'
98          res=res+tt+"echo Completed "+t+"\n"              res=res+tt+"echo Completed "+t+"\n"
99          if self.single_processor_only:          if self.single_processor_only:
100              res+="fi\n"              res+="fi\n"
101      res=res+"\n"          res=res+"\n"
102      return res          return res
103                

Legend:
Removed from v.4575  
changed lines
  Added in v.4576

  ViewVC Help
Powered by ViewVC 1.1.26