blob: b391e513cb229f12cff3d67b8774979ccfec2317 [file] [log] [blame]
subrata_modakc0caf8f2008-03-20 11:54:19 +00001#!/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
16TESTNAME="rpc_reg-unreg_svc_register.basic"
17TESTVERS="1.0"
18# test binaries, used to call
19TESTCLIENTPATH="rpc_suite/rpc/rpc_regunreg_svc_register"
20TESTCLIENTBIN="1-basic.bin"
21TESTCLIENT=$CLIENTTSTPACKDIR/$TESTCLIENTPATH/$TESTCLIENTBIN
22# table to save all tests result
23result=
24# tmp file declaration to store test returned result
25TMPRESULTFILE=/tmp/rpcts.tmp
26
27# *****************
28# *** PROCESSUS ***
29# *****************
30
31# erase temp. result file
32echo -n "">$TMPRESULTFILE
33
34# function to collect log result
35get_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
59result_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
74serv=$( $REMOTESHELL $SERVERUSER@$SERVERIP "ps -e | grep $TESTSERVER_1_BIN" )
75if [ -z "$serv" ]
76then
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
85fi
86
87# launch client instances depeding on test...
88for ((a=0; a < TESTINSTANCE ; a++))
89do
90 $REMOTESHELL $CLIENTUSER@$CLIENTIP "$TESTCLIENT $SERVERIP $PROGNUMNOSVC" >>$TMPRESULTFILE&
91done
92
93
94# wait for the end of all test
95sleep $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
100IS_EX=`$REMOTESHELL $CLIENTUSER@$CLIENTIP "ps -e | grep $TESTCLIENTBIN"`
101
102if [ "$IS_EX" ]
103then
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
113fi
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
120result=( $(cat $TMPRESULTFILE) )
121get_test_result
122result_to_logFile
123echo " * $TESTNAME execution: "$r_valueTxt