Import from 1.9a8 tarball
[mozilla-nss.git] / security / nss / tests / libpkix / libpkix.sh
blobde026a1b5ff2813cb2d0279c0e2e15fa212b5bbd
1 #! /bin/sh
2 #
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
16 # The Original Code is the Netscape security libraries.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1994-2000
21 # the Initial Developer. All Rights Reserved.
23 # Contributor(s):
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.
37 # ***** END LICENSE BLOCK *****
39 # runTests.sh
42 totalErrors=0
43 pkixErrors=0
44 pkixplErrors=0
45 checkMemArg=""
46 arenasArg=""
47 quietArg=""
48 memText=""
50 ############################## libpkix_init ###############################
51 # local shell function to initialize this script
52 ########################################################################
53 libpkix_init()
55 SCRIPTNAME="libpkixs.sh"
56 if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
57 CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
60 LIBPKIX_CURDIR=`pwd`
61 if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ] ; then
62 cd ../common
63 . ./init.sh
65 cd ${LIBPKIX_CURDIR}
67 # test at libpkix is written in ksh and hence cannot be sourced "."
68 # by this sh script. While we want to provide each libpkix test script the
69 # ability to be executed alone, we will need to use common/init.sh
70 # to set up bin etc. Since variable values can not be passed to sub-directory
71 # script for checking ($INIT_SOURCED), log is recreated and old data lost.
72 # The cludge way provided here is not ideal, but works (for now) :
73 # We save the log up to this point then concatenate it with libpkix log
74 # as the final one.
75 LOGFILE_ALL=${LOGFILE}
76 if [ ! -z ${LOGFILE_ALL} ] ; then
77 mv ${LOGFILE_ALL} ${LOGFILE_ALL}.tmp
78 touch ${LOGFILE_ALL}
81 SCRIPTNAME="libpkixs.sh"
82 LIBPKIX_LOG=${HOSTDIR}/libpkix.log #we don't want all the errormessages
83 # in the output.log, otherwise we can't tell what's a real error
85 html_head "LIBPKIX Tests"
89 ############################## libpkix_cleanup ############################
90 # local shell function to finish this script (no exit since it might be
91 # sourced)
92 ########################################################################
93 libpkix_cleanup()
95 if [ ! -z ${LOGFILE_ALL} ] ; then
96 rm ${LOGFILE_ALL}
97 cat ${LOGFILE_ALL}.tmp ${LIBPKIX_LOG} > ${LOGFILE_ALL}
98 rm ${LOGFILE_ALL}.tmp
101 html "</TABLE><BR>"
102 cd ${QADIR}
103 . common/cleanup.sh
106 ParseArgs ()
108 while [ $# -gt 0 ]; do
109 if [ $1 == "-checkmem" ]; then
110 checkMemArg=$1
111 memText=" (Memory Checking Enabled)"
112 elif [ $1 == "-quiet" ]; then
113 quietArg=$1
114 elif [ $1 == "-arenas" ]; then
115 arenasArg=$1
117 shift
118 done
121 libpkix_main()
124 ParseArgs
126 echo "*******************************************************************************"
127 echo "START OF ALL TESTS${memText}"
128 echo "*******************************************************************************"
129 echo ""
131 echo "RUNNING tests in pkix_pl_test";
132 html_msg 0 0 "Running tests in pkix_pl_test:"
133 cd pkix_pl_tests;
134 runPLTests.sh ${arenasArg} ${checkMemArg} ${quietArg}
135 pkixplErrors=$?
136 html_msg $? 0 "Results of tests in pkix_pl_test"
138 echo "RUNNING tests in pkix_test";
139 html_msg 0 0 "Running tests in pkix_test:"
140 cd ../pkix_tests;
141 runTests.sh ${arenasArg} ${checkMemArg} ${quietArg}
142 pkixErrors=$?
143 html_msg $? 0 "Results of tests in pkix_test"
145 echo "RUNNING performance tests in sample_apps";
146 html_msg 0 0 "Running performance tests in sample_apps:"
147 cd ../sample_apps;
148 runPerf.sh ${arenasArg} ${checkMemArg} ${quietArg}
149 pkixPerfErrors=$?
150 html_msg $? 0 "Results of performance tests in sample_apps"
152 totalErrors=`expr ${pkixErrors} + ${pkixplErrors} + ${pkixPerfErrors}`
154 if [ ${totalErrors} -eq 0 ]; then
155 echo ""
156 echo "************************************************************"
157 echo "END OF ALL TESTS: ALL TESTS COMPLETED SUCCESSFULLY"
158 echo "************************************************************"
159 html_msg ${totalErrors} 0 "ALL LIBPKIX TESTS COMPLETED SUCCESSFULLY"
161 return 0
164 if [ ${totalErrors} -eq 1 ]; then
165 plural=""
166 else
167 plural="S"
170 if [ ${totalErrors} -ne 0 ]; then
171 echo ""
172 echo "************************************************************"
173 echo "END OF ALL TESTS: ${totalErrors} TEST${plural} FAILED"
174 echo "************************************************************"
175 html_msg 1 0 "${totalErrors} LIBPKIX TEST${plural} FAILED"
176 return 1
180 ################## main #################################################
182 libpkix_init
183 libpkix_main | tee ${LIBPKIX_LOG}
184 libpkix_cleanup