|
1 #!/bin/bash |
|
2 # |
|
3 # This Source Code Form is subject to the terms of the Mozilla Public |
|
4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
6 |
|
7 ######################################################################## |
|
8 # |
|
9 # mozilla/security/nss/tests/all.sh |
|
10 # |
|
11 # Script to start selected available NSS QA suites on one machine |
|
12 # this script is called or sourced by NSS QA which runs on all required |
|
13 # platforms |
|
14 # |
|
15 # Needs to work on all Unix and Windows platforms |
|
16 # |
|
17 # Currently available NSS QA suites: |
|
18 # ---------------------------------- |
|
19 # cipher.sh - tests NSS ciphers |
|
20 # libpkix.sh - tests PKIX functionality |
|
21 # cert.sh - exercises certutil and creates certs necessary for |
|
22 # all other tests |
|
23 # dbtests.sh - tests related to certificate databases |
|
24 # tools.sh - tests the majority of the NSS tools |
|
25 # fips.sh - tests basic functionallity of NSS in FIPS-compliant |
|
26 # - mode |
|
27 # sdr.sh - tests NSS SDR |
|
28 # crmf.sh - CRMF/CMMF testing |
|
29 # smime.sh - S/MIME testing |
|
30 # ssl.sh - tests SSL V2 SSL V3 and TLS |
|
31 # ocsp.sh - OCSP testing |
|
32 # merge.sh - tests merging old and new shareable databases |
|
33 # pkits.sh - NIST/PKITS tests |
|
34 # chains.sh - PKIX cert chains tests |
|
35 # dbupgrade.sh - upgrade databases to new shareable version (used |
|
36 # only in upgrade test cycle) |
|
37 # memleak.sh - memory leak testing (optional) |
|
38 # |
|
39 # NSS testing is now devided to 4 cycles: |
|
40 # --------------------------------------- |
|
41 # standard - run test suites with defaults settings |
|
42 # pkix - run test suites with PKIX enabled |
|
43 # upgradedb - upgrade existing certificate databases to shareable |
|
44 # format (creates them if doesn't exist yet) and run |
|
45 # test suites with those databases |
|
46 # sharedb - run test suites with shareable database format |
|
47 # enabled (databases are created directly to this |
|
48 # format) |
|
49 # |
|
50 # Mandatory environment variables (to be set before testing): |
|
51 # ----------------------------------------------------------- |
|
52 # HOST - test machine host name |
|
53 # DOMSUF - test machine domain name |
|
54 # |
|
55 # Optional environment variables to specify build to use: |
|
56 # ------------------------------------------------------- |
|
57 # BUILT_OPT - use optimized/debug build |
|
58 # USE_64 - use 64bit/32bit build |
|
59 # |
|
60 # Optional environment variables to enable specific NSS features: |
|
61 # --------------------------------------------------------------- |
|
62 # NSS_DISABLE_ECC - disable ECC |
|
63 # NSS_ECC_MORE_THAN_SUITE_B - enable extended ECC |
|
64 # |
|
65 # Optional environment variables to select which cycles/suites to test: |
|
66 # --------------------------------------------------------------------- |
|
67 # NSS_CYCLES - list of cycles to run (separated by space |
|
68 # character) |
|
69 # - by default all cycles are tested |
|
70 # |
|
71 # NSS_TESTS - list of all test suites to run (separated by space |
|
72 # character, without trailing .sh) |
|
73 # - this list can be reduced for individual test cycles |
|
74 # |
|
75 # NSS_SSL_TESTS - list of ssl tests to run (see ssl.sh) |
|
76 # NSS_SSL_RUN - list of ssl sub-tests to run (see ssl.sh) |
|
77 # |
|
78 # Testing schema: |
|
79 # --------------- |
|
80 # all.sh ~ (main) |
|
81 # | | |
|
82 # +------------+------------+-----------+ ~ run_cycles |
|
83 # | | | | | |
|
84 # standard pkix upgradedb sharedb ~ run_cycle_* |
|
85 # | | |
|
86 # +------+------+------+-----> ~ run_tests |
|
87 # | | | | | |
|
88 # cert tools fips ssl ... ~ . *.sh |
|
89 # |
|
90 # Special strings: |
|
91 # ---------------- |
|
92 # FIXME ... known problems, search for this string |
|
93 # NOTE .... unexpected behavior |
|
94 # |
|
95 # NOTE: |
|
96 # ----- |
|
97 # Unlike the old QA this is based on files sourcing each other |
|
98 # This is done to save time, since a great portion of time is lost |
|
99 # in calling and sourcing the same things multiple times over the |
|
100 # network. Also, this way all scripts have all shell function |
|
101 # available and a completely common environment |
|
102 # |
|
103 ######################################################################## |
|
104 |
|
105 ############################## run_tests ############################### |
|
106 # run test suites defined in TESTS variable, skip scripts defined in |
|
107 # TESTS_SKIP variable |
|
108 ######################################################################## |
|
109 run_tests() |
|
110 { |
|
111 for TEST in ${TESTS} |
|
112 do |
|
113 echo "${TESTS_SKIP}" | grep "${TEST}" > /dev/null |
|
114 if [ $? -eq 0 ]; then |
|
115 continue |
|
116 fi |
|
117 |
|
118 SCRIPTNAME=${TEST}.sh |
|
119 echo "Running tests for ${TEST}" |
|
120 echo "TIMESTAMP ${TEST} BEGIN: `date`" |
|
121 (cd ${QADIR}/${TEST}; . ./${SCRIPTNAME} 2>&1) |
|
122 echo "TIMESTAMP ${TEST} END: `date`" |
|
123 done |
|
124 } |
|
125 |
|
126 ########################## run_cycle_standard ########################## |
|
127 # run test suites with defaults settings (no PKIX, no sharedb) |
|
128 ######################################################################## |
|
129 run_cycle_standard() |
|
130 { |
|
131 TEST_MODE=STANDARD |
|
132 |
|
133 TESTS="${ALL_TESTS}" |
|
134 TESTS_SKIP= |
|
135 |
|
136 run_tests |
|
137 } |
|
138 |
|
139 ############################ run_cycle_pkix ############################ |
|
140 # run test suites with PKIX enabled |
|
141 ######################################################################## |
|
142 run_cycle_pkix() |
|
143 { |
|
144 TEST_MODE=PKIX |
|
145 |
|
146 TABLE_ARGS="bgcolor=cyan" |
|
147 html_head "Testing with PKIX" |
|
148 html "</TABLE><BR>" |
|
149 |
|
150 HOSTDIR="${HOSTDIR}/pkix" |
|
151 mkdir -p "${HOSTDIR}" |
|
152 init_directories |
|
153 |
|
154 NSS_ENABLE_PKIX_VERIFY="1" |
|
155 export NSS_ENABLE_PKIX_VERIFY |
|
156 |
|
157 TESTS="${ALL_TESTS}" |
|
158 TESTS_SKIP="cipher dbtests sdr crmf smime merge multinit" |
|
159 |
|
160 echo "${NSS_SSL_TESTS}" | grep "_" > /dev/null |
|
161 RET=$? |
|
162 NSS_SSL_TESTS=`echo "${NSS_SSL_TESTS}" | sed -e "s/normal//g" -e "s/bypass//g" -e "s/fips//g" -e "s/_//g"` |
|
163 [ ${RET} -eq 0 ] && NSS_SSL_TESTS="${NSS_SSL_TESTS} bypass_bypass" |
|
164 |
|
165 run_tests |
|
166 } |
|
167 |
|
168 ######################### run_cycle_upgrade_db ######################### |
|
169 # upgrades certificate database to shareable format and run test suites |
|
170 # with those databases |
|
171 ######################################################################## |
|
172 run_cycle_upgrade_db() |
|
173 { |
|
174 TEST_MODE=UPGRADE_DB |
|
175 |
|
176 TABLE_ARGS="bgcolor=pink" |
|
177 html_head "Testing with upgraded library" |
|
178 html "</TABLE><BR>" |
|
179 |
|
180 OLDHOSTDIR="${HOSTDIR}" |
|
181 HOSTDIR="${HOSTDIR}/upgradedb" |
|
182 mkdir -p "${HOSTDIR}" |
|
183 init_directories |
|
184 |
|
185 if [ -r "${OLDHOSTDIR}/cert.log" ]; then |
|
186 DIRS="alicedir bobdir CA cert_extensions client clientCA dave eccurves eve ext_client ext_server fips SDR server serverCA stapling tools/copydir cert.log cert.done tests.*" |
|
187 for i in $DIRS |
|
188 do |
|
189 cp -r ${OLDHOSTDIR}/${i} ${HOSTDIR} #2> /dev/null |
|
190 done |
|
191 fi |
|
192 |
|
193 # upgrade certs dbs to shared db |
|
194 TESTS="dbupgrade" |
|
195 TESTS_SKIP= |
|
196 |
|
197 run_tests |
|
198 |
|
199 NSS_DEFAULT_DB_TYPE="sql" |
|
200 export NSS_DEFAULT_DB_TYPE |
|
201 |
|
202 # run the subset of tests with the upgraded database |
|
203 TESTS="${ALL_TESTS}" |
|
204 TESTS_SKIP="cipher libpkix cert dbtests sdr ocsp pkits chains" |
|
205 |
|
206 echo "${NSS_SSL_TESTS}" | grep "_" > /dev/null |
|
207 RET=$? |
|
208 NSS_SSL_TESTS=`echo "${NSS_SSL_TESTS}" | sed -e "s/normal//g" -e "s/bypass//g" -e "s/fips//g" -e "s/_//g"` |
|
209 [ ${RET} -eq 0 ] && NSS_SSL_TESTS="${NSS_SSL_TESTS} bypass_bypass" |
|
210 NSS_SSL_RUN=`echo "${NSS_SSL_RUN}" | sed -e "s/cov//g" -e "s/auth//g"` |
|
211 |
|
212 run_tests |
|
213 } |
|
214 |
|
215 ########################## run_cycle_shared_db ######################### |
|
216 # run test suites with certificate databases set to shareable format |
|
217 ######################################################################## |
|
218 run_cycle_shared_db() |
|
219 { |
|
220 TEST_MODE=SHARED_DB |
|
221 |
|
222 TABLE_ARGS="bgcolor=yellow" |
|
223 html_head "Testing with shared library" |
|
224 html "</TABLE><BR>" |
|
225 |
|
226 HOSTDIR="${HOSTDIR}/sharedb" |
|
227 mkdir -p "${HOSTDIR}" |
|
228 init_directories |
|
229 |
|
230 NSS_DEFAULT_DB_TYPE="sql" |
|
231 export NSS_DEFAULT_DB_TYPE |
|
232 |
|
233 # run the tests for native sharedb support |
|
234 TESTS="${ALL_TESTS}" |
|
235 TESTS_SKIP="cipher libpkix dbupgrade sdr ocsp pkits" |
|
236 |
|
237 echo "${NSS_SSL_TESTS}" | grep "_" > /dev/null |
|
238 RET=$? |
|
239 NSS_SSL_TESTS=`echo "${NSS_SSL_TESTS}" | sed -e "s/normal//g" -e "s/bypass//g" -e "s/fips//g" -e "s/_//g"` |
|
240 [ ${RET} -eq 0 ] && NSS_SSL_TESTS="${NSS_SSL_TESTS} bypass_bypass" |
|
241 NSS_SSL_RUN=`echo "${NSS_SSL_RUN}" | sed -e "s/cov//g" -e "s/auth//g"` |
|
242 |
|
243 run_tests |
|
244 } |
|
245 |
|
246 ############################# run_cycles ############################### |
|
247 # run test cycles defined in CYCLES variable |
|
248 ######################################################################## |
|
249 run_cycles() |
|
250 { |
|
251 for CYCLE in ${CYCLES} |
|
252 do |
|
253 case "${CYCLE}" in |
|
254 "standard") |
|
255 run_cycle_standard |
|
256 ;; |
|
257 "pkix") |
|
258 run_cycle_pkix |
|
259 ;; |
|
260 "upgradedb") |
|
261 run_cycle_upgrade_db |
|
262 ;; |
|
263 "sharedb") |
|
264 run_cycle_shared_db |
|
265 ;; |
|
266 esac |
|
267 . ${ENV_BACKUP} |
|
268 done |
|
269 } |
|
270 |
|
271 ############################## main code ############################### |
|
272 |
|
273 cycles="standard pkix upgradedb sharedb" |
|
274 CYCLES=${NSS_CYCLES:-$cycles} |
|
275 |
|
276 tests="cipher lowhash libpkix cert dbtests tools fips sdr crmf smime ssl ocsp merge pkits chains" |
|
277 TESTS=${NSS_TESTS:-$tests} |
|
278 |
|
279 ALL_TESTS=${TESTS} |
|
280 |
|
281 nss_ssl_tests="crl bypass_normal normal_bypass fips_normal normal_fips iopr" |
|
282 NSS_SSL_TESTS="${NSS_SSL_TESTS:-$nss_ssl_tests}" |
|
283 |
|
284 nss_ssl_run="cov auth stapling stress" |
|
285 NSS_SSL_RUN="${NSS_SSL_RUN:-$nss_ssl_run}" |
|
286 |
|
287 SCRIPTNAME=all.sh |
|
288 CLEANUP="${SCRIPTNAME}" |
|
289 cd `dirname $0` |
|
290 |
|
291 # all.sh should be the first one to try to source the init |
|
292 if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then |
|
293 cd common |
|
294 . ./init.sh |
|
295 fi |
|
296 |
|
297 # NOTE: |
|
298 # Since in make at the top level, modutil is the last file |
|
299 # created, we check for modutil to know whether the build |
|
300 # is complete. If a new file is created after that, the |
|
301 # following test for modutil should check for that instead. |
|
302 # Exception: when building softoken only, shlibsign is the |
|
303 # last file created. |
|
304 if [ ${NSS_BUILD_SOFTOKEN_ONLY} -eq "1" ]; then |
|
305 LAST_FILE_BUILT=shlibsign |
|
306 else |
|
307 LAST_FILE_BUILT=modutil |
|
308 fi |
|
309 |
|
310 if [ ! -f ${DIST}/${OBJDIR}/bin/${LAST_FILE_BUILT}${PROG_SUFFIX} ]; then |
|
311 echo "Build Incomplete. Aborting test." >> ${LOGFILE} |
|
312 html_head "Testing Initialization" |
|
313 Exit "Checking for build" |
|
314 fi |
|
315 |
|
316 # NOTE: |
|
317 # Lists of enabled tests and other settings are stored to ${ENV_BACKUP} |
|
318 # file and are are restored after every test cycle. |
|
319 |
|
320 ENV_BACKUP=${HOSTDIR}/env.sh |
|
321 env_backup > ${ENV_BACKUP} |
|
322 |
|
323 if [ "${O_CRON}" = "ON" ]; then |
|
324 run_cycles >> ${LOGFILE} |
|
325 else |
|
326 run_cycles | tee -a ${LOGFILE} |
|
327 fi |
|
328 |
|
329 SCRIPTNAME=all.sh |
|
330 |
|
331 . ${QADIR}/common/cleanup.sh |
|
332 |