Salome HOME
PR: merge from branch BR_UnitTests tag mergeto_trunk_17oct05
[modules/kernel.git] / bin / appliskel / runTests
1 #!/bin/bash
2
3 # --- retrieve APPLI path, relative to $HOME
4 #     on sarge, "which" gives not allways the absolute path...
5      
6 comName=`which $0`
7 aa=${comName:0:1}
8 if test x$aa == x\/; then
9   mycom=${comName}
10 elif test x$aa == x\.; then
11   mycom=${PWD}/${comName:2}
12 else
13   mycom=${PWD}/${comName}
14 fi
15 APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '`
16 #echo $APPLI
17 export APPLI
18
19 # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...)
20
21 . ${HOME}/${APPLI}/envd ${HOME}/${APPLI}
22
23 # --- define port for CORBA naming service
24
25 searchFreePort() {
26     echo -n "Searching for a free port for naming service: "
27     export NSPORT=2810
28     local limit=$NSPORT
29     let limit=limit+100
30     while [ 1 ]
31     do
32         aRes=`netstat -ltn | grep -E :${NSPORT}`
33         if [ -z "$aRes" ]; then
34             echo ${NSPORT} - Ok
35             local myhost=`hostname`
36             export OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_${NSPORT}.cfg
37             export NSPORT
38             export NSHOST=${myhost}
39             local initref="NameService=corbaname::"`hostname`":$NSPORT"
40             #echo "ORBInitRef $initref" > $OMNIORB_CONFIG
41             echo "InitRef = $initref" > $OMNIORB_CONFIG
42             export LAST_RUNNING_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_test.cfg
43             rm ${LAST_RUNNING_CONFIG}
44             ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG}
45             break
46         fi
47         echo -n "${NSPORT} "
48         if [[ $NSPORT -eq $limit ]] ; then
49             echo
50             echo "Can't find a free port to launch omniNames"
51             echo "Try to kill the running servers and then launch SALOME again."
52             exit
53         fi
54         let NSPORT=NSPORT+1
55     done
56 }
57
58 # --- invoque shell with or without args
59
60 searchFreePort
61
62 if [ $# -ne 0 ] ; then
63     ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/bash --rcfile ${HOME}/${APPLI}/.bashrc -c "$*"
64 else
65
66     ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/bash --rcfile ${HOME}/${APPLI}/.bashrc
67 fi
68
69 rm ${OMNIORB_CONFIG}
70 rm ${LAST_RUNNING_CONFIG}