Adding test framework and some sample test modules and test cases to the sytem.
[csql.git] / test / execTests.ksh
blobb1504ad9b831f1c5463ebbbd5df40bdd461d63ce
1 #!/bin/ksh
8 ######################Test Executor main starts here###################
10 #TEST_RUN_DIR should be set before running this
11 if [ ! "$TEST_RUN_ROOT" ]
12 then
13 echo "TEST_RUN_ROOT should be set before running the tests"
14 exit 1
16 ROOT_DIR=`pwd`
18 while read MODULE
20 echo $MODULE | grep "#" >/dev/null
21 if [ $? -eq 0 ]
22 then
23 continue
25 #echo "MODULE READ is $MODULE"
27 TEST_SCRIPT_DIR=${ROOT_DIR}/${MODULE}
28 TEST_RUN_DIR=${TEST_RUN_ROOT}/${MODULE}
29 if [ -s "$TEST_RUN_DIR" ]
30 then
31 echo "TEST_RUN_ROOT already has Connection directory. Remove and try again."
32 exit 1
34 mkdir -p $TEST_RUN_DIR
36 # TODO::check whether server is running
38 TEST_LOG=$TEST_RUN_DIR/testlog
40 if [ -s "$TEST_LOG" ]
41 then
42 echo "TEST_RUN_DIR has files in it. Remove before running the tests"
43 exit 1
46 TEST_EXEC_DIR=$TEST_RUN_DIR/tests
47 mkdir $TEST_EXEC_DIR
50 echo "Test Executor log file" >$TEST_LOG
51 echo "----------------------" >$TEST_LOG
53 TestList=`ls ${TEST_SCRIPT_DIR}/test*`
54 for test in $TestList
56 echo "Running $test"
57 echo "Running $test" >>$TEST_LOG
58 echo "Test started at : `date` "
59 echo "Test started at : `date` " >>$TEST_LOG
61 expPresent="no"
62 EXP_FILE=exp.`basename ${test}`
63 #echo "EXP_FILE is $EXP_FILE"
64 if [ -s "${TEST_SCRIPT_DIR}/${EXP_FILE}" ]
65 then
66 expPresent="yes"
69 if [ "$expPresent" = "yes" ]
70 then
71 cp ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}
72 ${test} > ${TEST_EXEC_DIR}/cur.${EXP_FILE} 2>&1
73 else
74 ${test} >> ${TEST_LOG} 2>&1
76 ret=$?
77 echo "Test Ended at : `date` "
78 echo "Test Ended at : `date` " >>$TEST_LOG
79 if [ $ret -eq 0 ]
80 then
81 if [ "$expPresent" = "yes" ]
82 then
83 #compare exp and current output
84 diff ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}/cur.${EXP_FILE} > ${TEST_EXEC_DIR}/diff.${EXP_FILE}
85 if [ $? -eq 0 ]
86 then
88 echo "Exp and current output matched."
89 echo "Test $test passed"
90 echo "Exp and current output matched." >>$TEST_LOG
91 echo "PASSED:Test $test passed" >>$TEST_LOG
92 rm ${TEST_EXEC_DIR}/cur.${EXP_FILE}
93 rm ${TEST_EXEC_DIR}/diff.${EXP_FILE}
94 rm ${TEST_EXEC_DIR}/${EXP_FILE}
95 else
96 echo "Exp and current output not matched."
97 echo "Test $test failed"
98 echo "Exp and current output not matched." >>$TEST_LOG
99 echo "FAILED:Test $test failed" >>$TEST_LOG
100 #TODO:get all the trace files from server and store it in a folder
102 else
103 echo "Returned 0."
104 echo "Test $test passed"
105 echo "Returned 0." >>$TEST_LOG
106 echo "PASSED:Test $test passed" >>$TEST_LOG
109 else
110 echo "Returned $ret "
111 echo "Test $test failed"
112 echo "Returned $ret " >>$TEST_LOG
113 echo "FAILED:Test $test failed" >>$TEST_LOG
114 #TODO:get all the trace files from server and store it in a folder
117 done
118 done < TestModules
119 exit 0