2 ###############################################################################
3 # Copyright (c) 2000-2015 Ericsson Telecom AB
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Eclipse Public License v1.0
6 # which accompanies this distribution, and is available at
7 # http://www.eclipse.org/legal/epl-v10.html
8 ###############################################################################
10 MYEXE
="EmergencyLogTest"
13 LIST_OF_FAILED
="failed_testcases.txt"
16 #####################################
18 # sets TTCN3_DIR, if is needed
20 #####################################
22 if [ "$TTCN3_DIR" == "" ]
24 echo "TTCN3_DIR should be set"
32 echo "Failed tests:" > ${LIST_OF_FAILED}
34 #TODO: set cut off length according to TimeStampFormat
37 #####################################
40 #####################################
42 if [ "$DEBUG" == "true" ] ; then
47 #####################################
50 #####################################
52 #remove timestamps, data different for run by run
53 debug
"Modifying file $1"
55 s/\ (No such file or directory)//g
56 s/^EXECUTOR_RUNTIME - MTC was created. Process id: [0-9]*\./EXECUTOR_RUNTIME - MTC was created. Process id:/g
57 s/rocess id: [0-9][0-9]*/rocess id: X/g
58 s/I\/O: [0-9][0-9]*/I\/O: Y/g
59 s/switches: [0-9][0-9]*/switches: S/g
60 s/block output operations: [0-9]*/block output operations: B/g
61 s/block input operations: [0-9]*/block input operations: I/g
62 s/system time: [0-9]*\.[0-9]*/system time: SYS/g
63 s/user time: [0-9]*\.[0-9]*/user time: T/g
64 s/seed [0-9][0-9]*[.][0-9]*/seed /g
65 s/returned [0-9][0-9]*[.][0-9]*/returned R/g
66 s/srand48.[\-]*[0-9]*.\./srand X/g
67 s/t1: [0-9]e-[0-9]* s/t1: T s/g
68 s/t1: [0-9e.-]* s/t1: T s/g
69 s/t: [0-9e.-]* s/t: T s/g
70 s/Mytime: [0-9.]*e-[0-9]* s/Mytime: T s/g
71 s/Mytime: [0-9.]* s/Mytime: T s/g
72 s/reference [0-9]* finished/reference R finished/g
73 s/started on [a-zA-Z0-9._-]*. Version: .*/started on X. Version: V/g
75 s/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/a\.b\.c\.d/g
76 s/The address of MC was set to [a-zA-Z0-9._-]*/The address of MC was set to X/g
77 s/resident set size: [0-9]*/resident set size: S/g
78 s/Action: Finish:[0-9][0-9]*[.][0-9]*/Action: Finish: F/g
79 s/Action: Elapsed time:[0-9][0-9]*[.][0-9]*/Action: Elapsed time:E/g
80 s/Read timer t: [0-9e.-]* s/Read timer t: T s/g
81 s/Read timer t1: [0-9e.-]* s/Read timer t1: T s/g
82 s/Action: Start:[0-9e.-]* s/Action: Start: S s/g
84 s/UNIX pathname .*$/UNIX pathname /g
85 s/^EXECUTOR_COMPONENT.*$//g
86 s/^PORTEVENT_MQUEUE.*$//g
89 sed -e "$cmd" < "$1" > "${LOGDIR}/tmp"
91 sed -e "/^$/d" < "${LOGDIR}/tmp" > "$1"
92 #mv "${LOGDIR}/tmp" "$1"
95 #####################################
96 # run_and_modify_logfile
98 # $2 : cfg file base without extension
99 #####################################
100 run_and_modify_logfile
() {
101 $TTCN3_DIR/bin
/ttcn3_start
$MYEXE $1
102 cp $LOGDIR/${MYEXE}-mtc.log
$LOGDIR/${2}-mtc.log
103 cp $LOGDIR/${MYEXE}-hc.log
$LOGDIR/${2}-hc.log
105 #remove timestamp, diff data:
106 modify_logfile
"${LOGDIR}/${2}-mtc.log"
107 modify_logfile
"${LOGDIR}/${2}-hc.log"
109 #emergency log handling
110 if [ -e "$LOGDIR/${MYEXE}-mtc.log_emergency" ]
112 debug
"Emergency log file name: $LOGDIR/${2}-mtc.log_emergency"
113 cp "$LOGDIR/${MYEXE}-mtc.log_emergency" "$LOGDIR/${2}-mtc.log_emergency"
114 modify_logfile
"$LOGDIR/${2}-mtc.log_emergency"
118 while [ -e "$LOGDIR/${MYEXE}-$i.log" ]
120 cp "$LOGDIR/${MYEXE}-$i.log" "$LOGDIR/${2}-$i.log"
121 modify_logfile
"$LOGDIR/${2}-$i.log"
125 #####################################
126 # create EmergencyLogCommentedOut (ELCO) file from the original log file
127 # $1:original config file
128 # output "${1}_ELCO.cfg"
129 #####################################
130 create_ELCO_config
() {
131 elco_cfg
=`basename $1 ".cfg"`
132 elco_cfg
="${elco_cfg}_ELCO.cfg"
135 s/^\*\.Emergency/#\*\.Emergency/g'
136 sed -e "$cmd" < "${elco_cfg}" > tmp
138 debug
"OLD cfg name: $1"
139 debug
"ELCO cfg name: ${elco_cfg}"
141 #####################################
143 # $1: componenent id (mtc, hc, 3, 4 etc)
144 #####################################
145 compare_with_ELCO
() {
146 diff -u "$LOGDIR/${elco_cfg_base}-$1.log" "$LOGDIR/${orig_cfg_base}-$1.log" > "${LOGDIR}/diff_${orig_cfg_base}_$1.log"
147 if [ "$?" -eq $SUCCESS ]
149 debug
">>>tc $orig_cfg_base $1 part success<<<"
150 let "success = $success + 1"
152 debug
">>>tc $orig_cfg_base $1 part failed<<<"
153 echo "tc $orig_cfg_base $1 part failed" >> ${LIST_OF_FAILED}
154 let "failed = $failed + 1"
156 debug
"success: ${success} failed: ${failed}"
159 #####################################
160 # compare_with_expected
161 # $1: componenent id (mtc, hc, 3, 4 etc)
163 #####################################
164 compare_with_expected
() {
165 diff -u "$2" "${LOGDIR}/${orig_cfg_base}-$1.log" > "${LOGDIR}/diff_${orig_cfg_base}_$1.log"
166 if [ "$?" -eq $SUCCESS ]
168 debug
">>>tc $orig_cfg_base $1 part success<<<"
169 let "success = $success + 1"
171 debug
">>>tc $orig_cfg_base $1 part failed<<<"
172 echo "tc $orig_cfg_base $1 part failed" >> ${LIST_OF_FAILED}
173 let "failed = $failed + 1"
175 debug
"success: ${success} failed: ${failed}"
178 #####################################
179 # compare_with_expected_emergency
180 # $1: componenent id (mtc, hc, 3, 4 etc)
182 #####################################
183 compare_with_expected_emergency
() {
184 #debug "==>diff -u $4 ${LOGDIR}/${orig_cfg_base}-$1.log_emergency > ${LOGDIR}/diff_${orig_cfg_base}_$1.log_emergency"
185 diff -u "$2" "${LOGDIR}/${orig_cfg_base}-$1.log_emergency" > "${LOGDIR}/diff_${orig_cfg_base}_$1.log_emergency"
186 if [ "$?" -eq $SUCCESS ]
188 debug
">>>tc $orig_cfg_base $1 part success<<<"
189 let "success = $success + 1"
191 debug
">>>tc $orig_cfg_base $1 part failed<<<"
192 echo "tc $orig_cfg_base $1 emergency part failed" >> ${LIST_OF_FAILED}
193 let "failed = $failed + 1"
195 debug
"success: ${success} failed: ${failed}"
197 #####################################
198 # run_and_compare_log_files
199 # $1 first config file
201 # $3 output file (diff_)
202 #####################################
203 run_and_compare_log_files
() {
204 #running with orig cfg:
205 rm ${LOGDIR}/${MYEXE}*.log
206 orig_cfg_base
=`basename $1 ".cfg"`
207 run_and_modify_logfile
"$1" "$orig_cfg_base"
209 if [ "$2" == "" ]; then
210 #running with modified cfg:
211 create_ELCO_config
"$1"
216 elco_cfg_base
=`basename "$elco_cfg" ".cfg"`
217 debug
"ELCO cfg name: ${elco_cfg}"
218 run_and_modify_logfile
"${elco_cfg}" "$elco_cfg_base"
221 compare_with_ELCO
"mtc"
222 compare_with_ELCO
"hc"
225 while [ -e "$LOGDIR/${elco_cfg_base}-$i.log" -a -e "$LOGDIR/${orig_cfg_base}-$i.log" ]
227 compare_with_ELCO
"$i"
232 #####################################
233 # run_and_compare_log_file_with_expected
234 # $1 first config file
235 # $2 expected mtc log file
236 # $3 expected hc log file
237 # $4 expected emergency log file
238 #####################################
239 run_and_compare_log_file_with_expected
() {
240 rm -f ${LOGDIR}/${MYEXE}*.log
*
241 #running with orig cfg:
242 orig_cfg_base
=`basename $1 ".cfg"`
243 run_and_modify_logfile
"$1" "$orig_cfg_base"
249 #diff mtc with the expected:
252 compare_with_expected
"mtc" "$2"
254 debug
">>>tc $orig_cfg_base mtc part failed, not existing expected log file $2<<<"
255 echo "tc $orig_cfg_base mtc part failed" >> ${LIST_OF_FAILED}
256 let "failed = $failed + 1"
261 if [ "$3" != "" ]; then
264 compare_with_expected
"hc" "$3"
266 debug
">>>tc $orig_cfg_base mtc part failed, not existing expected log file $3<<<"
267 echo "tc $orig_cfg_base mtc part failed" >> ${LIST_OF_FAILED}
268 let "failed = $failed + 1"
272 #mtc emergency log kezeles
273 if [ "$4" != "" ]; then
276 compare_with_expected_emergency
"mtc" "$4"
278 debug
">>>tc $orig_cfg_base mtc part failed, not existing expected log file $4<<<"
279 echo "tc $orig_cfg_base mtc part failed, not existing expected log file $4" >> ${LIST_OF_FAILED}
280 let "failed = $failed + 1"
285 #####################################
287 #####################################
289 echo "Summary: success: ${success}, failed: ${failed} "
292 echo "Overall verdict: success"
295 echo "Overall verdict: failed"
296 cat ${LIST_OF_FAILED} |
309 # see the files "logs/diff*.log" !
312 #======= Buffer All ========
313 run_and_compare_log_files EL_BufferAll_1.cfg
#compatibility test with minimal coverage (compare logs with/without EL setting if EL-event does not happen
314 run_and_compare_log_files EL_BufferAll_2.cfg
#compatibility test with coverage "tc_parallel_portconn" (compare logs with/without EL setting if EL-event does not happen) - NOT STABILE, hc FAILED
315 run_and_compare_log_files EL_BufferAll_3.cfg EL_BufferAll_3_NOEL.cfg
#the same log expected with two different log files: EL and NOEL, EL-event occurs in the first case - PASSED
316 run_and_compare_log_files EL_BufferAll_4.cfg
#compatibility test with "tc_timer" (compare logs with/without EL setting if EL-event does not happen) - hc FAILED
317 run_and_compare_log_files EL_BufferAll_5.cfg
#compatibility test "with Titan_LogTest.tc_encdec" - NOT STABILE, mtc PASSED, hc PASSED
318 run_and_compare_log_files EL_BufferAll_6.cfg
#compatibility test with "tc_function_rnd and tc_encdec" - mtc PASSED, hc PASSED
319 run_and_compare_log_file_with_expected
"EL_BufferAll_7.cfg" "EL_BufferAll_7_mtc_expected.log" # - mtc PASSED
320 run_and_compare_log_file_with_expected
"EL_BufferAll_7A.cfg" "EL_BufferAll_7A_mtc_expected.log" # - mtc PASSED
321 run_and_compare_log_files EL_BufferAll_8.cfg
#compatibility test with MAXIMAL coverage - NOT STABILE; mtc PASSED hc FAILED (1 line order problem,
322 run_and_compare_log_file_with_expected
"EL_BufferAll_9.cfg" "EL_BufferAll_9_mtc_expected.log" # - More EL-event can be logged after each other - mtc FAILED ( 1 line missing), hc FAILED
323 run_and_compare_log_file_with_expected
"EL_BufferAll_10.cfg" "EL_BufferAll_10_mtc_expected.log" # - More EL-event with big buffer - mtc PASSED
324 run_and_compare_log_file_with_expected
"EL_BufferAll_11.cfg" "EL_BufferAll_11_mtc_expected.log" # - More EL-event with big buffer - mtc PASSED
325 run_and_compare_log_file_with_expected
"EL_BufferAll_12.cfg" "EL_BufferAll_12_mtc_expected.log" # - More EL-event with very small buffer - (buffer size=2) - mtc FAILED, one line missing
326 run_and_compare_log_file_with_expected
"EL_BufferAll_13.cfg" "EL_BufferAll_13_mtc_expected.log" # - More EL-event with very small buffer - (buffer size=3) - mtc FAILED, one line missing
327 #======= Buffer Masked ========
328 run_and_compare_log_files EL_BufferMasked_1.cfg
#compatibility test with minimal coverage (compare logs with/without EL setting if EL-event does not happen
329 run_and_compare_log_files EL_BufferMasked_2.cfg
#compatibility test with coverage "tc_parallel_portconn" (compare logs with/without EL setting if EL-event does not happen) - NOT STABILE
330 run_and_compare_log_files EL_BufferMasked_4.cfg
#compatibility test with "tc_timer" (compare logs with/without EL setting if EL-event does not happen) - PASSED
331 run_and_compare_log_files EL_BufferMasked_5.cfg
#compatibility test "with Titan_LogTest.tc_encdec" - NOT STABILE
332 run_and_compare_log_files EL_BufferMasked_3.cfg EL_BufferMasked_3_NOEL.cfg
#the same log expected with two different log files: EL and NOEL, EL-event occurs in the first case - PASSED
333 run_and_compare_log_files EL_BufferMasked_6.cfg
#compatibility test with "tc_function_rnd and tc_encdec" - PASSED
334 run_and_compare_log_file_with_expected
"EL_BufferMasked_7.cfg" "EL_BufferMasked_7_mtc_expected.log" "" "EL_BufferMasked_7_mtc_expected.log_emergency" # - PASSED
335 run_and_compare_log_files EL_BufferMasked_8.cfg
#compatibility test with MAXIMAL coverage - NOT STABILE
336 run_and_compare_log_file_with_expected
"EL_BufferMasked_9.cfg" "EL_BufferMasked_9_mtc_expected.log" "" "EL_BufferMasked_9_mtc_expected.log_emergency" # - More EL-event can be logged after each other - PASSED
337 run_and_compare_log_file_with_expected
"EL_BufferMasked_10.cfg" "EL_BufferMasked_10_mtc_expected.log" "" "EL_BufferMasked_10_mtc_expected.log_emergency" # - More EL-event with big buffer - PASSED
338 run_and_compare_log_file_with_expected
"EL_BufferMasked_11.cfg" "EL_BufferMasked_11_mtc_expected.log" "" "EL_BufferMasked_11_mtc_expected.log_emergency" # - More EL-event with big buffer - PASSED
339 run_and_compare_log_file_with_expected
"EL_BufferMasked_12.cfg" "EL_BufferMasked_12_mtc_expected.log" "" "EL_BufferMasked_12_mtc_expected.log_emergency" # - More EL-event with very small buffer - (buffer size=2) - mtc.log_emergency FAILED (wrong order)
340 run_and_compare_log_file_with_expected
"EL_BufferMasked_13.cfg" "EL_BufferMasked_13_mtc_expected.log" "" "EL_BufferMasked_13_mtc_expected.log_emergency" # - More EL-event with very small buffer - (buffer size=3) - mtc.log_emergency FAILED (wrong order)
341 #Stat: 63 success/ 0 failed