Debian Codegraph @

bin/run-tests-sync-app.sh

raw
1 #!/bin/bash
2 #/*
3 # * This file is part of buteo-sync-plugins package
4 # *
5 # * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 # *
7 # * Contact: Sateesh Kavuri <[email protected]>
8 # *
9 # * This library is free software; you can redistribute it and/or
10 # * modify it under the terms of the GNU Lesser General Public License
11 # * version 2.1 as published by the Free Software Foundation.
12 # *
13 # * This library is distributed in the hope that it will be useful, but
14 # * WITHOUT ANY WARRANTY; without even the implied warranty of
15 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # * Lesser General Public License for more details.
17 # *
18 # * You should have received a copy of the GNU Lesser General Public
19 # * License along with this library; if not, write to the Free Software
20 # * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 # * 02110-1301 USA
22 # *
23 # */
24 #Author - Srikanth Kavoori
25 # This file should run unittests for sync-app
26 # and create the result file with unittest rate
27 # and coverage to this folder with name
28 # sync-app-results
29 #
30 # The release number should be in the file
31 # this script generates the results automatically
32 # for the latest weekXxX directory under sync-app
33 #this script updation should be rarely needed
34
35 #Script Specific Variables
36
37 TARGET=sync-app
38 TARGET_WEEK=week$(date +%V)$(date +%G)
39 if [ $# == 0 ];
40 then
41 WD=$PWD
42 ROOTDIR=$WD/..
43 RESULTS_FILE=$TARGET-results_$TARGET_WEEK
44 else
45 WD=$1
46 TARGET_WEEK=$(ls -c $WD/../$TARGET | head -1)
47 echo "TARGET WEEK is $TARGET_WEEK"
48 ROOTDIR=$WD/../$TARGET/$TARGET_WEEK
49 echo "ROOTDIR is $ROOTDIR"
50 echo $1
51 RESULTS_DIR=$2
52 echo "RESULTS_DIR is $RESULTS_DIR"
53 RESULTS_FILE=$RESULTS_DIR/$TARGET-results_$TARGET_WEEK
54 fi
55
56
57 echo "if running inside scratchbox use export SBOX_USE_CCACHE=no and ccache -c commands for gcov to work"
58 PLUGINS=(clientplugins storageplugins syncmlcommon)
59 #PLUGINTARGETS=(syncmlclient hcalendar hcontacts hbookmarks hnotes unittest)
60 PLUGINTARGETS=(syncmlclient hcalendar hcontacts hnotes unittest)
61 TEMPFILE1=$WD/.temp_results
62
63 if [ -f $TEMPFILE1 ]
64 then
65 rm -f $TEMPFILE1
66 fi
67
68 TEMPFILE2=$WD/.gcov_info.txt
69 if [ -f $TEMPFILE2 ]
70 then
71 rm -f $TEMPFILE2
72 fi
73
74 TEMPFILE3=$WD/.percent
75 if [ -f $TEMPFILE3 ]
76 then
77 rm -f $TEMPFILE3
78 fi
79 echo "Running the unit tests for $TARGET..."
80 echo "Results will be stored in: $RESULTS_FILE ...."
81 cd $ROOTDIR
82 echo ${PLUGINS[@]}
83 echo ${PLUGINTARGETS[@]}
84 for plugin in ${PLUGINS[@]}
85 do
86 cd $plugin
87 for target in ${PLUGINTARGETS[@]}
88 do
89 if [ -d $target ];
90 then
91 echo "Building the plugin $target in $PWD"
92 cd $target
93 # qmake
94 # make clean
95 # make
96 if [ -d unittest ];
97 then
98 cd unittest
99 fi
100 echo "Building the unittest for plugin $target in $PWD"
101 if [ -f run-test ]
102 then
103 echo "Running the unittest for plugin $target in $PWD"
104 ./run-test
105 cat unit_test_results.txt >> $TEMPFILE1
106 cat gcov_results.txt >> $TEMPFILE2
107 cd ..
108 else
109 echo" run-test script not present for $target "
110 cd ..
111 fi
112 cd ..
113 fi
114 done
115 if [ -d syncmlcommon ];
116 then
117 echo "do nothing"
118 else
119 cd ..
120 fi
121 done
122
123 # get coverage information for the files using perl
124 echo "executing perl $ROOTDIR/bin/gcov_info.pl $TEMPFILE2 $TEMPFILE3"
125 GCOV_REPORT=$WD/gcov_report.txt
126 perl $WD/gcov_info.pl $TEMPFILE2 $TEMPFILE3 $GCOV_REPORT
127
128 if [ ! $? -eq 0 ]; then
129 #echo "Perl Script for Gcov information exit normal"
130 #else
131 echo "Perl Script Failed to execute ... Exiting ... "
132 exit 0
133 fi
134
135 SUMMARY_FILE=$WD/.summary_file
136 if [ -f $SUMMARY_FILE ]
137 then
138 rm -f $SUMMARY_FILE
139 fi
140 perl $WD/test_info.pl $TEMPFILE1 $SUMMARY_FILE
141
142 if [ ! $? -eq 0 ]; then
143 #echo "Perl Script for test information exit normal"
144 #else
145 echo "Perl Script for test information Failed to execute ... Exiting ... "
146 exit 0
147 fi
148
149
150 echo "Writing the file $RESULTS_FILE"
151 echo "#Results for $TARGET_WEEK " > $RESULTS_FILE
152
153 echo "Results Summary STARTED " >> $RESULTS_FILE
154
155 echo "#Current gcov reported coverage (line rate) is" >> $RESULTS_FILE
156 cat $TEMPFILE3 >> $RESULTS_FILE
157
158 echo "Unit test Results Summary " >> $RESULTS_FILE
159 cat $SUMMARY_FILE >> $RESULTS_FILE
160
161 echo "Results Summary ENDED " >> $RESULTS_FILE
162
163 echo "****************UNIT_TEST Results **************" >> $RESULTS_FILE
164 cat $TEMPFILE1 >> $RESULTS_FILE
165 rm -f $TEMPFILE1 $TEMPFILE3 $SUMMARY_FILE
166 cd $ROOTDIR
167 echo $PWD
168 qmake
169 make distclean
170 cd $WD
171 echo "$RESULTS_FILE created"