subrata_modak | c0caf8f | 2008-03-20 11:54:19 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # This test is a part of RPC & TI-RPC Test Suite created by Cyril LACABANNE |
| 4 | # (c) 2007 BULL S.A.S. |
| 5 | # Please refer to RPC & TI-RPC Test Suite documentation. |
| 6 | # More details at http://nfsv4.bullopensource.org/doc/rpc_testsuite.php |
| 7 | |
| 8 | # TEST : RPC svc_register basic |
| 9 | # creation : 2007-05-30 revision 2007- |
| 10 | |
| 11 | # ********************** |
| 12 | # *** INITIALISATION *** |
| 13 | # ********************** |
| 14 | # Parameters such as tests information, threads number... |
| 15 | # test information |
| 16 | TESTNAME="rpc_reg-unreg_svc_register.basic" |
| 17 | TESTVERS="1.0" |
| 18 | # test binaries, used to call |
| 19 | TESTCLIENTPATH="rpc_suite/rpc/rpc_regunreg_svc_register" |
| 20 | TESTCLIENTBIN="1-basic.bin" |
| 21 | TESTCLIENT=$CLIENTTSTPACKDIR/$TESTCLIENTPATH/$TESTCLIENTBIN |
| 22 | # table to save all tests result |
| 23 | result= |
| 24 | # tmp file declaration to store test returned result |
| 25 | TMPRESULTFILE=/tmp/rpcts.tmp |
| 26 | |
| 27 | # ***************** |
| 28 | # *** PROCESSUS *** |
| 29 | # ***************** |
| 30 | |
| 31 | # erase temp. result file |
| 32 | echo -n "">$TMPRESULTFILE |
| 33 | |
| 34 | # function to collect log result |
| 35 | get_test_result() |
| 36 | { |
| 37 | # default : test failed |
| 38 | r_value=1 |
| 39 | |
| 40 | # if result table is empty last test crashes (segment fault), so return must be "failed" |
| 41 | if [ ${#result[*]} -eq 0 ] |
| 42 | then |
| 43 | return |
| 44 | fi |
| 45 | |
| 46 | for ((a=0; a < TESTINSTANCE-1 ; a++)) |
| 47 | do |
| 48 | if [ ${result[$a]} -ne ${result[`expr $a + 1`]} ] |
| 49 | then |
| 50 | return |
| 51 | fi |
| 52 | done |
| 53 | |
| 54 | # if all test instances return same result return the first element, note that test succeeds if value is 0 |
| 55 | r_value=${result[0]} |
| 56 | } |
| 57 | |
| 58 | # function to put test result into logfile |
| 59 | result_to_logFile() |
| 60 | { |
| 61 | case $r_value in |
| 62 | 0)r_valueTxt="PASS";; |
| 63 | 1)r_valueTxt="FAILED";; |
| 64 | 2)r_valueTxt="HUNG";; |
| 65 | 3)r_valueTxt="INTERRUPTED";; |
| 66 | 4)r_valueTxt="SKIP";; |
| 67 | 5)r_valueTxt="UNTESTED";; |
| 68 | esac |
| 69 | |
| 70 | echo $TESTCLIENTPATH"/"$( echo $TESTCLIENTBIN | cut -d . -f1 )": execution: "$r_valueTxt>>$LOCLOGDIR/$TESTLOGFILE |
| 71 | } |
| 72 | |
| 73 | # test needs this server to run |
| 74 | serv=$( $REMOTESHELL $SERVERUSER@$SERVERIP "ps -e | grep $TESTSERVER_1_BIN" ) |
| 75 | if [ -z "$serv" ] |
| 76 | then |
| 77 | echo " - Skipped..." |
| 78 | echo "/!\ Panic : no test server found" |
| 79 | echo " $TESTSERVER_1_BIN needed, but not running on server" |
| 80 | echo " Test skipped with status 4" |
| 81 | r_value=4 |
| 82 | result_to_logFile |
| 83 | echo " * $TESTNAME execution: "$r_valueTxt |
| 84 | exit 4 |
| 85 | fi |
| 86 | |
| 87 | # launch client instances depeding on test... |
| 88 | for ((a=0; a < TESTINSTANCE ; a++)) |
| 89 | do |
| 90 | $REMOTESHELL $CLIENTUSER@$CLIENTIP "$TESTCLIENT $SERVERIP $PROGNUMNOSVC" >>$TMPRESULTFILE& |
| 91 | done |
| 92 | |
| 93 | |
| 94 | # wait for the end of all test |
| 95 | sleep $GLOBALTIMEOUT |
| 96 | |
| 97 | # test if all test instances have stopped |
| 98 | # if it remains at least one instances, script kills instances and put status HUNG to the whole test case |
| 99 | |
| 100 | IS_EX=`$REMOTESHELL $CLIENTUSER@$CLIENTIP "ps -e | grep $TESTCLIENTBIN"` |
| 101 | |
| 102 | if [ "$IS_EX" ] |
| 103 | then |
| 104 | if [ $VERBOSE -eq 1 ] |
| 105 | then |
| 106 | echo " - error : prog is still running -> kill" |
| 107 | fi |
| 108 | $REMOTESHELL $CLIENTUSER@$CLIENTIP "killall -9 $TESTCLIENTBIN" |
| 109 | r_value=2 |
| 110 | result_to_logFile |
| 111 | echo " * $TESTNAME execution: "$r_valueTxt |
| 112 | exit 2 |
| 113 | fi |
| 114 | |
| 115 | # *************** |
| 116 | # *** RESULTS *** |
| 117 | # *************** |
| 118 | |
| 119 | # if test program correctly run, this part aims to collect all test results and put this result into log file |
| 120 | result=( $(cat $TMPRESULTFILE) ) |
| 121 | get_test_result |
| 122 | result_to_logFile |
| 123 | echo " * $TESTNAME execution: "$r_valueTxt |