3 ################### Settings ########################################
4 #Timeout value for the hanging scripts
7 ################### TIMEOUT HANDLER #################################
12 echo "HANG_FLAG is set here"
13 kill -9 $CMD_PID 2>/dev
/null
17 ##################### Test Executor main starts here ##################
19 #TEST_RUN_DIR should be set before running this
20 if [ ! "$TEST_RUN_ROOT" ]
22 echo "TEST_RUN_ROOT should be set before running the tests"
25 if [ ! "$CSQL_INSTALL_ROOT" ]
27 echo "CSQL_INSTALL_ROOT should be set before running the tests"
31 mkdir
-p $TEST_RUN_ROOT
32 SERVOUT
=$TEST_RUN_ROOT/serv.out
34 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
36 echo "Starting Server"
40 echo $MODULE |
grep "#" >/dev
/null
45 echo "MODULE READ is $MODULE"
47 if [ "$MODULE" = "system/lock" ]
49 echo "Restarting the server for lock module"
52 echo "csqlserver killed PID=${SERVER_PID}" >>$TEST_LOG
53 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
55 echo "csqlserver restarted with PID=${SERVER_PID}" >>$TEST_LOG
56 echo "Restarting Server"
59 TEST_SCRIPT_DIR
=${ROOT_DIR}/${MODULE}
60 TEST_RUN_DIR
=${TEST_RUN_ROOT}/${MODULE}
61 if [ -s "$TEST_RUN_DIR" ]
63 echo "TEST_RUN_ROOT directory is not empty. Clean and try again."
66 mkdir
-p $TEST_RUN_DIR
68 # TODO::check whether server is running
70 TEST_LOG
=$TEST_RUN_DIR/testlog
74 echo "TEST_RUN_DIR has files in it. Remove before running the tests"
78 TEST_EXEC_DIR
=$TEST_RUN_DIR/tests
82 echo "Test Executor log file" >$TEST_LOG
83 echo "----------------------" >>$TEST_LOG
85 TestList
=`ls ${TEST_SCRIPT_DIR}/test*`
89 echo "Running $test" >>$TEST_LOG
90 echo "Test started at : `date` "
91 echo "Test started at : `date` " >>$TEST_LOG
94 EXP_FILE
=exp.
`basename ${test}`
95 #echo "EXP_FILE is $EXP_FILE"
96 if [ -s "${TEST_SCRIPT_DIR}/${EXP_FILE}" ]
102 trap timeout_handler USR1
103 sleep ${HANG_TIMEOUT} && kill -s USR1 $$
&
106 if [ "$expPresent" = "yes" ]
108 cp ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}
109 ${test} > ${TEST_EXEC_DIR}/cur.${EXP_FILE} 2>/dev
/null
&
111 ${test} >> ${TEST_LOG} 2>/dev
/null
&
114 wait ${CMD_PID} 2>/dev
/null
116 echo "Test Ended at : `date` "
117 echo "Test Ended at : `date` " >>$TEST_LOG
120 kill -9 ${SLEEP_PID} 2>/dev
/null
122 if [ "$HANG_FLAG" = "Yes" ]
124 echo "Test Hung. so it is killed." >>$TEST_LOG
125 echo "FAILED:Test $test failed" >>$TEST_LOG
126 #TODO::Reinitalize the database, as it may be in corrupted state.
128 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
129 kill -9 ${SERVER_PID}
130 ipcrm
-M 2222 -M 3333
131 echo "csqlserver killed PID=${SERVER_PID}" >>$TEST_LOG
132 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
134 echo "csqlserver restarted with PID=${SERVER_PID}" >>$TEST_LOG
135 echo "Restarting Server"
144 if [ "$expPresent" = "yes" ]
146 #compare exp and current output
147 diff ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}/cur.${EXP_FILE} > ${TEST_EXEC_DIR}/diff.${EXP_FILE}
151 echo "Exp and current output matched."
152 echo "Test $test passed"
153 echo "Exp and current output matched." >>$TEST_LOG
154 echo "PASSED:Test $test passed" >>$TEST_LOG
155 rm ${TEST_EXEC_DIR}/cur.
${EXP_FILE}
156 rm ${TEST_EXEC_DIR}/diff.
${EXP_FILE}
157 rm ${TEST_EXEC_DIR}/${EXP_FILE}
159 echo "Exp and current output not matched."
160 echo "Test $test failed"
161 echo "Exp and current output not matched." >>${TEST_LOG}
162 echo "FAILED:Test $test failed" >>$TEST_LOG
163 #TODO::Reinitalize the database, as it may be in corrupted state.
165 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
166 echo "Refer ${SERVOUT}.${SERVER_PID}.${CURTIME} file for server log" >>$TEST_LOG
167 kill -9 ${SERVER_PID}
168 ipcrm
-M 2222 -M 3333
169 echo "csqlserver killed PID=${SERVER_PID}" >>${TEST_LOG}
170 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
172 echo "csqlserver restarted with PID=${SERVER_PID}" >>${TEST_LOG}
173 echo "Restarting Server"
178 echo "Test $test passed"
179 echo "Returned 0." >>$TEST_LOG
180 echo "PASSED:Test $test passed" >>$TEST_LOG
184 echo "Returned $ret "
185 echo "Test $test failed"
186 echo "Returned $ret " >>$TEST_LOG
187 echo "FAILED:Test $test failed" >>$TEST_LOG
188 #TODO::Reinitalize the database, as it may be in corrupted state.
190 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
191 echo "Refer ${SERVOUT}.${SERVER_PID}.${CURTIME} file for server log" >>$TEST_LOG
192 kill -9 ${SERVER_PID}
193 ipcrm
-M 2222 -M 3333
194 echo "csqlserver killed PID=${SERVER_PID}" >>$TEST_LOG
195 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} 2>${SERVOUT} &
197 echo "csqlserver restarted with PID=${SERVER_PID}" >>${TEST_LOG}
198 echo "Restarting Server"
205 kill -9 ${SERVER_PID}
206 ipcrm
-M 2222 -M 3333
207 echo "csqlserver killed PID=${SERVER_PID}" >>${TEST_LOG}