Merge pull request #19 from nspaseski/master
[deliverable/titan.core.git] / regression_test / logger / logtest / logtest.sh
CommitLineData
970ed795
EL
1#!/bin/bash
2###############################################################################
3abe9331 3# Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
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###############################################################################
9
10
11#Description:
12#The goal of this script is to compare the logfile generation result for two different Titan version.
13#If switches are not applied the original logfiles given as input will be compared with the just generated log files
14#This is the use case in folder regression_test/logger/logtest
15
16
17#Inputs
18# old_logfilename.txt -if "-o" not used
19# old_logfilename_modified.txt -if "-o" not used
20# Outputs:
21# old_logfilename.txt -if "-o" used
22# old_logfilename_modified.txt -if "-o" used
23# Console_old_logfilename.txt
24# new_logfilename.txt
25# new_logfilename_modified.txt
26# Console_new_logfilename.txt
27
28create_old=0
29cfg_filename="Titan_LogTest.cfg"
30old_logfilename="original_merged_log"
31new_logfilename="new_merged_log"
32generate_makefile=0
33
34
35
36##### FUNCTIONS #######
37
38####################
39# showUsage
40####################
41showUsage()
42{
43 echo "Usage: $0 <options>"
44 echo "Options:"
45 echo " -o create old versions"
46 echo " -c [config filename] e.g.: Titan_LogTest.cfg"
47 echo " -O [Old log file name (before modification)]"
48 echo " -N [New log file name (before modification)]"
49 echo " -g generate makefiles. Mandatory if -o applied"
50 echo "Prerequisite: TTCN3_DIR set for the new ttcn3 dir"
51}
52
53####################
54# init
55####################
56init() {
57 echo "Init called"
58
59 if [ "$TTCN3_DIR_OLD" == "" ]
60 then
61 TTCN3_DIR_OLD="/mnt/TTCN/Releases/TTCNv3-1.8.pl5"
62 fi
63 echo "TTCN3_DIR_OLD:${TTCN3_DIR_OLD}"
64
65 if [ "$TTCN3_DIR" == "" ]
66 then
67 TTCN3_DIR="/export/localhome/TCC/ethbaat/XmlTest/install"
68 fi
69 TTCN3_DIR_NEW=${TTCN3_DIR}
70
71 echo "TTCN3_DIR:${TTCN3_DIR}"
72
73 LD_LIBRARY_PATH_ORIG=$LD_LIBRARY_PATH
74
75 SYSTEM_NAME=`uname -n`
76 HOST_NAME=`hostname`
77 export HOST_NAME
78 if [ "$USER" == "" ]
79 then
80 export USER=$(whoami)
81 fi
82 if [ "$USER" == "" ]
83 then
84 export USER=$(/usr/ucb/whoami)
85 fi
86}
87
88####################
89# create_log
90# $1: name of the cfg file
91# $2: name of the merged log file
92# $3: name of the merged modified log file (timestamps removed)
93####################
94create_log() {
95
96echo "Create_log called"
97
98make clean
99
100if [ "${generate_makefile}" == "1" ]
101then
102 ttcn3_makefilegen -fg Titan_LogTest.ttcn Titan_LogTestDefinitions.ttcn *.cc *.hh
103fi
104
105make
3f84031e 106echo "ttcn3_start Titan_LogTest $1"
970ed795
EL
107ttcn3_start Titan_LogTest "$1" | tee "Console_$2"
108
109#ttcn3_logmerge *.log > "$2"
110#logmerge the order of the loglines can be different per executions
111# therefore the logs will be appended instead of merge
112echo "Appended logs:" > "$2"
113list=$(ls Titan_LogTest*.log | xargs)
114for i in $list
115do
116 cat $i >> "$2"
117done
118
119cmd='
120s/^.*\(EXECUTOR_COMPONENT - TTCN-3 Parallel Test Component started on\).*\( Component reference:\).*$/\1 \2/g
121s/^.*\(PORTEVENT_UNQUALIFIED - Port internal_port is waiting for connection from\).*$/\1/g
122s/^.*\(EXECUTOR_UNQUALIFIED - The local IP address of the control connection to\).*$/\1/g
123s/^.*\(EXECUTOR_COMPONENT - TTCN-3 Main Test Component started on\).*$/\1/g
124s/^.*\(EXECUTOR_RUNTIME - TTCN-3 Host Controller started on\).*$/\1/g
125s/^.*\(EXECUTOR_UNQUALIFIED - The address of MC was set to\).*$/\1/g
126s/^.*\(EXECUTOR_RUNTIME - MTC was created. Process id\).*$/\1/g
127s/^.*\(Random number generator was initialized with seed\)\(.*\)$/\1/g
128s/^.*\(Function rnd() returned\)\(.*\)$/\1/g
129s/^.*\(PARALLEL_PTC - PTC was created. Component reference: \).*\(testcase name:\).*\(, process id:\)\(.*\)$/\1\2\3/g
130s/^.*\(ERROR_UNQUALIFIED Titan_LogTest.ttcn\)\(.*\)\(Dynamic test case error: Assignment of an unbound integer value\).*/\1 \3/g
131s/^.*\(TIMEROP_READ Titan_LogTest.ttcn\)\(.*\)/\1/g
132s/^.*\(USER_UNQUALIFIED Titan_LogTest.ttcn\)\(.*\)/\1/g
133s/^.*\(PARALLEL_PTC - PTC with component reference\)\(.*\)/\1/g
134s/^.*\(PARALLEL_PTC - MTC finished.\)\(.*\)//g
135s/^.*\(EXECUTOR_RUNTIME - Maximum number of open file descriptors\).*//g
136s/^.\{15\} //g
137'
138# TODO: s/^.*\(PARALLEL_PTC - MTC finished.\)\(.*\)/\1/g should be used instead of s/^.*\(PARALLEL_PTC - MTC finished.\)\(.*\)//g
139# TODO: s/^.*\(EXECUTOR_RUNTIME - Maximum number of open file descriptors\).*//g kiszedese
140# This line removes the random/seldom line from the log
141sed -e "$cmd" -e "/^$/d" < "$2" > "$3"
142
143}
144
145####################
146# create_log_old
147# $1: name of the cfg file
148# $2: name of the merged log file
149# $3: name of the merged modified log file (timestamps removed)
150####################
151create_log_old() {
152 TTCN3_DIR_ORIG=${TTCN3_DIR}
153 TTCN3_DIR=${TTCN3_DIR_OLD}
154 PATH_ORIG=$PATH}
155 PATH=${TTCN3_DIR}/bin:${PATH}
156 LD_LIBRARY_PATH_ORIG=${LD_LIBRARY_PATH}
157 LD_LIBRARY_PATH=${TTCN3_DIR}/lib:${LD_LIBRARY_PATH}
158 export TTCN3_DIR PATH LD_LIBRARY_PATH
159
160 create_log $1 $2 $3
161
162 TTCN3_DIR=${TTCN3_DIR_ORIG}
163 PATH=${PATH_ORIG}
164 LD_LIBRARY_PATH=${LD_LIBRARY_PATH_ORIG}
165 export TTCN3_DIR PATH LD_LIBRARY_PATH
166}
167
168####################
169# create_log_new
170# $1: name of the cfg file
171# $2: name of the merged log file
172# $3: name of the merged modified log file (timestamps removed)
173####################
174create_log_new() {
175 echo ">>>>create_log_new args: $1 $2 $3"
176 TTCN3_DIR_ORIG=${TTCN3_DIR}
177 TTCN3_DIR=${TTCN3_DIR_NEW}
178 PATH_ORIG=${PATH}
179 PATH=${TTCN3_DIR}/bin:${PATH}
180 LD_LIBRARY_PATH_ORIG=${LD_LIBRARY_PATH}
181 LD_LIBRARY_PATH=${TTCN3_DIR}/lib:${LD_LIBRARY_PATH}
182 export TTCN3_DIR PATH LD_LIBRARY_PATH
183
184 create_log $1 $2 $3
185
186 TTCN3_DIR=${TTCN3_DIR_ORIG}
187 PATH=${PATH_ORIG}
188 LD_LIBRARY_PATH=${LD_LIBRARY_PATH_ORIG}
189 export TTCN3_DIR PATH LD_LIBRARY_PATH
190}
191####################
192# compare
193# $1: name of the old merged modified log file
194# $2: name of the new merged modified log file
195####################
196compare() {
197 echo "Comparison follows"
198 diff "$1" "$2"
199 result=$?
200 echo "Comparison result is $result"
201 exit $result
202}
203
204####################### EOF FUNCTIONS ###################################
205
206#===== MAIN =======
207while getopts "hoc:O:N:g" o
208do
209 case "$o" in
210 h) showUsage; exit 1;;
211 o) create_old=1;;
212 c) cfg_filename=$OPTARG;;
213 O) old_logfilename=$OPTARG;;
214 N) new_logfilename=$OPTARG;;
215 g) generate_makefile=1;;
216 [?]) showUsage; exit 1;;
217 esac
218done
219
220init
221
222if [ "${create_old}" == "1" ]
223then
224 echo ">>>CREATES OLD<<<"
225 create_log_old "${cfg_filename}" "${old_logfilename}.txt" "${old_logfilename}_modified.txt"
226else
227 echo ">>>OLD LOG NOT CREATED<<<"
228 echo ">>>${create_old}<<<"
229fi
230
231create_log_new "${cfg_filename}" "${new_logfilename}.txt" "${new_logfilename}_modified.txt"
232
233compare "${old_logfilename}_modified.txt" "${new_logfilename}_modified.txt"
This page took 0.064286 seconds and 5 git commands to generate.