Imported Upstream version 20080331
[ltp-debian.git] / testcases / network / rpc / rpc-tirpc-full-test-suite / scripts / rpc_createdestroy_clntudp_create.stress.sh
blobbaa565039f091d16b443989166d6dc87a120c750
1 #!/bin/sh
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
8 # TEST : RPC clntudp_create stress
9 # creation : 2007-06-15 revision 2007-
11 # **********************
12 # *** INITIALISATION ***
13 # **********************
14 # Parameters such as tests information, threads number...
15 # test information
16 TESTNAME="RPC_create-destroy_clntudp_create.stress"
17 TESTVERS="1.0"
18 # test binaries, used to call
19 TESTCLIENTPATH="rpc_suite/rpc/rpc_createdestroy_clntudp_create"
20 TESTCLIENTBIN="2-stress.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
27 # *****************
28 # *** PROCESSUS ***
29 # *****************
31 # erase temp. result file
32 echo -n "">$TMPRESULTFILE
34 # function to collect log result
35 get_test_result()
37 # default : test failed
38 r_value=1
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
46 for ((a=0; a < TESTINSTANCE-1 ; a++))
48 if [ ${result[$a]} -ne ${result[`expr $a + 1`]} ]
49 then
50 return
52 done
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]}
58 # function to put test result into logfile
59 result_to_logFile()
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
70 echo $TESTCLIENTPATH"/"$( echo $TESTCLIENTBIN | cut -d . -f1 )": execution: "$r_valueTxt>>$LOCLOGDIR/$TESTLOGFILE
73 # launch client instances depeding on test...
74 for ((a=0; a < TESTINSTANCE ; a++))
76 $REMOTESHELL $CLIENTUSER@$CLIENTIP "$TESTCLIENT $SERVERIP $PROGNUMNOSVC $NBTESTPROCESS" >>$TMPRESULTFILE&
77 done
80 # wait for the end of all test
81 sleep $STRESSTIMEOUT
83 # test if all test instances have stopped
84 # if it remains at least one instances, script kills instances and put status HUNG to the whole test case
86 IS_EX=`$REMOTESHELL $CLIENTUSER@$CLIENTIP "ps -e | grep $TESTCLIENTBIN"`
88 if [ "$IS_EX" ]
89 then
90 if [ $VERBOSE -eq 1 ]
91 then
92 echo " - error : prog is still running -> kill"
94 $REMOTESHELL $CLIENTUSER@$CLIENTIP "killall -9 $TESTCLIENTBIN"
95 r_value=2
96 result_to_logFile
97 echo " * $TESTNAME execution: "$r_valueTxt
98 exit 2
101 # ***************
102 # *** RESULTS ***
103 # ***************
105 # if test program correctly run, this part aims to collect all test results and put this result into log file
106 result=( $(cat $TMPRESULTFILE) )
107 get_test_result
108 result_to_logFile
109 echo " * $TESTNAME execution: "$r_valueTxt