~ubuntu-branches/ubuntu/raring/nss/raring-security

« back to all changes in this revision

Viewing changes to mozilla/security/nss/coverage/report.sh

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2010-03-25 13:46:06 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100325134606-bl6liuok2w9l7snv
Tags: 3.12.6-0ubuntu1
* New upstream release 3.12.6 RTM (NSS_3_12_6_RTM)
  - fixes CVE-2009-3555 aka US-CERT VU#120541
* Adjust patches to changed upstream code base
  - update debian/patches/38_kbsd.patch
  - update debian/patches/38_mips64_build.patch
  - update debian/patches/85_security_load.patch
* Remove patches that are merged upstream
  - delete debian/patches/91_nonexec_stack.patch
  - update debian/patches/series
* Bump nspr dependency to 4.8
  - update debian/control
* Add new symbols for 3.12.6
  - update debian/libnss3-1d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# ***** BEGIN LICENSE BLOCK *****
 
4
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
5
#
 
6
# The contents of this file are subject to the Mozilla Public License Version
 
7
# 1.1 (the "License"); you may not use this file except in compliance with 
 
8
# the License. You may obtain a copy of the License at
 
9
# http://www.mozilla.org/MPL/
 
10
#
 
11
# Software distributed under the License is distributed on an "AS IS" basis, 
 
12
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
 
13
# for the specific language governing rights and limitations under the 
 
14
# License.
 
15
#
 
16
# The Original Code is the Network Security Services
 
17
#
 
18
# The Initial Developer of the Original Code is Sun Microsystems, Inc.
 
19
# Portions created by the Initial Developer are Copyright (C) 2007-2009
 
20
# Sun Microsystems, Inc. All Rights Reserved.
 
21
#
 
22
# Contributor(s):
 
23
#   Slavomir Katuscak <slavomir.katuscak@sun.com>, Sun Microsystems, Inc.
 
24
#
 
25
# Alternatively, the contents of this file may be used under the terms of
 
26
# either the GNU General Public License Version 2 or later (the "GPL"), or
 
27
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
28
# in which case the provisions of the GPL or the LGPL are applicable instead
 
29
# of those above. If you wish to allow use of your version of this file only
 
30
# under the terms of either the GPL or the LGPL, and not to allow others to
 
31
# use your version of this file under the terms of the MPL, indicate your
 
32
# decision by deleting the provisions above and replace them with the notice
 
33
# and other provisions required by the GPL or the LGPL. If you do not delete
 
34
# the provisions above, a recipient may use your version of this file under
 
35
# the terms of any one of the MPL, the GPL or the LGPL.
 
36
#
 
37
# ***** END LICENSE BLOCK *****
 
38
 
 
39
OS=`uname -s`
 
40
ARCH=`uname -p`
 
41
SCRIPT_DIR=`pwd`
 
42
DATE=`date +%Y-%m-%d`
 
43
 
 
44
if [ $# -lt 1 -o $# -gt 3 ]; then
 
45
    echo "Usage: $0 [securitytip|securityjes5] <date> <architecture>"
 
46
    exit 1
 
47
fi
 
48
 
 
49
BRANCH="$1"
 
50
 
 
51
if [ "${BRANCH}" != "securitytip" -a "${BRANCH}" != "securityjes5" ]; then
 
52
    echo "Usage: $0 [securitytip|securityjes5] <date> <architecture>"
 
53
    exit 1
 
54
fi
 
55
 
 
56
if [ $# -ge 2 ]; then
 
57
    DATE=$2
 
58
fi
 
59
 
 
60
if [ $# -ge 3 ]; then
 
61
    ARCH=$3
 
62
fi
 
63
 
 
64
HEADER="Code Coverage - NSS - ${BRANCH} - ${OS}/${ARCH} - ${DATE}"
 
65
 
 
66
COV_DIR="/share/builds/mccrel3/security/coverage"
 
67
BRANCH_DIR="${COV_DIR}/${BRANCH}"
 
68
DATE_DIR="${BRANCH_DIR}/${DATE}-${ARCH}"
 
69
CVS_DIR="${DATE_DIR}/cvs_mozilla"
 
70
TCOV_DIR="${DATE_DIR}/tcov_mozilla"
 
71
OUTPUT="${DATE_DIR}/nss.html"
 
72
 
 
73
LIB_PATH="/mozilla/security/nss/lib"
 
74
CVS_PATH="${CVS_DIR}${LIB_PATH}"
 
75
TCOV_PATH="${TCOV_DIR}${LIB_PATH}"
 
76
 
 
77
MIN_GREEN=70
 
78
MIN_YELLOW=40
 
79
 
 
80
print_header()
 
81
{
 
82
    echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final\">" 
 
83
    echo "<HTML><HEAD><TITLE>${HEADER}</TITLE></HEAD><BODY>" 
 
84
    echo "<TABLE ALIGN=\"CENTER\" WIDTH=\"100%\">"
 
85
    echo "<TR><TH BGCOLOR=\"GREY\"><H2>${HEADER}</H2></TH></TR>"
 
86
    echo "</TABLE><BR>"
 
87
}
 
88
 
 
89
print_footer()
 
90
{
 
91
    echo "</BODY></HTML>"
 
92
}
 
93
 
 
94
print_notes()
 
95
{
 
96
    echo "<TABLE ALIGN=\"CENTER\" WIDTH=\"100%\">"
 
97
    echo "<TR ALIGN=\"CENTER\" BGCOLOR=\"LIGHTGREY\"><TD><A HREF=\"http://wikihome.sfbay.sun.com/jes-security/Wiki.jsp?page=Code_Coverage_Test_Execution\">Test Execution Notes</A></TD></TR>"
 
98
    echo "</TABLE><BR>"
 
99
}
 
100
 
 
101
print_legend()
 
102
{
 
103
    echo "<TABLE ALIGN=\"CENTER\" WIDTH=\"100%\">"
 
104
    echo "<TR ALIGN=\"CENTER\" BGCOLOR=\"GREY\"><TH>Legend</TH></TR>"
 
105
    echo "<TR ALIGN=\"CENTER\" BGCOLOR=\"LIGHTGREEN\"><TD>${MIN_GREEN}% - 100% of blocks tested</TD></TR>"
 
106
    echo "<TR ALIGN=\"CENTER\" BGCOLOR=\"YELLOW\"><TD>${MIN_YELLOW}% - ${MIN_GREEN}% of blocks tested</TD></TR>"
 
107
    echo "<TR ALIGN=\"CENTER\" BGCOLOR=\"ORANGE\"><TD>0% - ${MIN_YELLOW}% of blocks tested</TD></TR>"
 
108
    echo "<TR ALIGN=\"CENTER\" BGCOLOR=\"RED\"><TD>File not tested (these files are not included into statistics)</TD></TR>"
 
109
    echo "</TABLE>"
 
110
}
 
111
 
 
112
set_color()
 
113
{
 
114
    if [ ${PERCENT_INT} -le ${MIN_YELLOW} ]; then
 
115
        bgcolor="ORANGE"
 
116
    elif [ ${PERCENT_INT} -le ${MIN_GREEN} ]; then
 
117
        bgcolor="YELLOW"
 
118
    else
 
119
        bgcolor="LIGHTGREEN"
 
120
    fi    
 
121
}
 
122
 
 
123
create_table()
 
124
{
 
125
    echo "<TABLE ALIGN=\"CENTER\" WIDTH=\"100%\">"
 
126
    echo "<TR><TH BGCOLOR=\"GREY\" COLSPAN=\"2\">${DIR}</TH></TR>"
 
127
    echo "<TR BGCOLOR=\"DARKGREY\"><TH WIDTH=\"50%\">File</TH>"
 
128
    echo "<TH>Tested blocks (Tested blocks/Total blocks/Total lines)</TR>"
 
129
}
 
130
 
 
131
close_table()
 
132
{
 
133
    if [ "${LASTDIR}" != "" ]; then
 
134
        if [ ${DFILES} -gt 0 ]; then
 
135
            if [ ${DBLOCKS_TOTAL} -eq 0 ]; then
 
136
                PERCENT_INT=0
 
137
            else
 
138
                PERCENT_INT=`expr ${DBLOCKS_EXEC} \* 100 \/ ${DBLOCKS_TOTAL}`
 
139
            fi
 
140
            set_color
 
141
 
 
142
            echo "<TR><TH BGCOLOR=\"${bgcolor}\" COLSPAN=\"2\">Total: ${PERCENT_INT}% (${DBLOCKS_EXEC}/${DBLOCKS_TOTAL})</TH></TR>"
 
143
        else
 
144
            echo "<TR><TH BGCOLOR=\"RED\" COLSPAN=\"2\">Total: Not tested</TH></TR>"
 
145
        fi
 
146
        echo "</TABLE><BR>"
 
147
    fi
 
148
}
 
149
 
 
150
print_line()
 
151
{
 
152
    LINES_TOTAL=`wc -l "${file}" | /usr/bin/awk '{print $1}'`
 
153
 
 
154
    if [ -r "${TCOV_PATH}/${DIR}/${FILE}" ]; then
 
155
        BLOCKS_EXEC=`cat "${TCOV_PATH}/${DIR}/${FILE}" | grep "Basic blocks executed" | /usr/bin/awk '{print $1}'`
 
156
        BLOCKS_TOTAL=`cat "${TCOV_PATH}/${DIR}/${FILE}" | grep "Basic blocks in this file" | /usr/bin/awk '{print $1}'`
 
157
 
 
158
        DBLOCKS_EXEC=`expr ${DBLOCKS_EXEC} + ${BLOCKS_EXEC}`
 
159
        DBLOCKS_TOTAL=`expr ${DBLOCKS_TOTAL} + ${BLOCKS_TOTAL}`
 
160
        TBLOCKS_EXEC=`expr ${TBLOCKS_EXEC} + ${BLOCKS_EXEC}`
 
161
        TBLOCKS_TOTAL=`expr ${TBLOCKS_TOTAL} + ${BLOCKS_TOTAL}`
 
162
 
 
163
        TFILES=`expr ${TFILES} + 1`
 
164
        DFILES=`expr ${DFILES} + 1`
 
165
 
 
166
        PERCENT_EXEC=`cat "${TCOV_PATH}/${DIR}/${FILE}" | grep "Percent of the file executed" | /usr/bin/awk '{print $1}'`
 
167
        PERCENT_INT=`echo ${PERCENT_EXEC} | cut -d. -f1`
 
168
        set_color
 
169
 
 
170
        echo "<TR><TD BGCOLOR=\"LIGHTGREY\"><A HREF=\"${TCOV_PATH}/${DIR}/${FILE}\">${FILE}</A></TD>"
 
171
        echo "<TD BGCOLOR=\"${bgcolor}\">${PERCENT_EXEC}% (${BLOCKS_EXEC}/${BLOCKS_TOTAL}/${LINES_TOTAL})</TD></TR>"
 
172
    else
 
173
        echo "<TR><TD BGCOLOR=\"LIGHTGREY\"><A HREF=\"${file}\">${FILE}</A></TD>"
 
174
        echo "<TD BGCOLOR=\"RED\">Not tested (0/?/${LINES_TOTAL})</TD></TR>"
 
175
    fi
 
176
}
 
177
 
 
178
print_total()
 
179
{
 
180
    echo "<TABLE ALIGN=\"CENTER\" WIDTH=\"100%\">"
 
181
    if [ ${TFILES} -gt 0 ]; then
 
182
        if [ ${TBLOCKS_TOTAL} -eq 0 ]; then
 
183
            PERCENT_INT=0
 
184
        else
 
185
            PERCENT_INT=`expr ${TBLOCKS_EXEC} \* 100 \/ ${TBLOCKS_TOTAL}`
 
186
        fi
 
187
        set_color
 
188
 
 
189
        echo "<TR><TH BGCOLOR=\"${bgcolor}\"><H2>Total: ${PERCENT_INT}% (${TBLOCKS_EXEC}/${TBLOCKS_TOTAL})</H2></TH></TR>"
 
190
    else
 
191
        echo "<TR><TH BGCOLOR=\"RED\"><H2>Total: Not tested</H2></TH></TR>"
 
192
    fi
 
193
    echo "</TABLE><BR>"
 
194
}
 
195
 
 
196
process_cmd()
 
197
{
 
198
    LASTDIR=""
 
199
    TBLOCKS_EXEC=0
 
200
    TBLOCKS_TOTAL=0
 
201
    TFILES=0
 
202
 
 
203
    for dir in `find "${CVS_PATH}" -type d | sort`
 
204
    do
 
205
        DIR=`echo "${dir}" | sed "s:^${CVS_PATH}/::"`
 
206
        for file in `ls -1 ${dir}/*.c 2> /dev/null`
 
207
        do 
 
208
            if [ "${DIR}" != "${LASTDIR}" ]; then
 
209
                close_table
 
210
                create_table 
 
211
 
 
212
                LASTDIR="${DIR}";
 
213
                DBLOCKS_EXEC=0
 
214
                DBLOCKS_TOTAL=0
 
215
                DFILES=0
 
216
            fi
 
217
 
 
218
            FILE=`echo "${file}" | sed "s:^.*/\(.*.c\):\1:"`
 
219
            print_line
 
220
        done
 
221
    done
 
222
 
 
223
    close_table
 
224
    print_total
 
225
}
 
226
 
 
227
report()
 
228
{
 
229
    print_header > "${OUTPUT}"
 
230
    print_notes >> "${OUTPUT}"
 
231
    process_cmd >> "${OUTPUT}"
 
232
    print_legend >> "${OUTPUT}"
 
233
    print_footer >> "${OUTPUT}"
 
234
}
 
235
 
 
236
report
 
237
 
 
238
exit 0