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
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.
24
# Sonja Mirtitsch Sun Microsystems
26
# Alternatively, the contents of this file may be used under the terms of
27
# either the GNU General Public License Version 2 or later (the "GPL"), or
28
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
# in which case the provisions of the GPL or the LGPL are applicable instead
30
# of those above. If you wish to allow use of your version of this file only
31
# under the terms of either the GPL or the LGPL, and not to allow others to
32
# use your version of this file under the terms of the MPL, indicate your
33
# decision by deleting the provisions above and replace them with the notice
34
# and other provisions required by the GPL or the LGPL. If you do not delete
35
# the provisions above, a recipient may use your version of this file under
36
# the terms of any one of the MPL, the GPL or the LGPL.
38
# ***** END LICENSE BLOCK *****
40
########################################################################
42
# mozilla/security/nss/tests/dbtest/dbtest.sh
44
# Certificate generating and handeling for NSS QA, can be included
45
# multiple times from all.sh and the individual scripts
47
# needs to work on all Unix and Windows platforms
49
# included from (don't expect this to be up to date)
50
# --------------------------------------------------
58
# FIXME ... known problems, search for this string
59
# NOTE .... unexpected behavior
61
# FIXME - Netscape - NSS
62
########################################################################
64
############################## dbtest_init ###############################
65
# local shell function to initialize this script
66
########################################################################
69
SCRIPTNAME="dbtests.sh"
70
if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
71
CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
73
if [ -z "${INIT_SOURCED}" ] ; then
77
if [ ! -r $CERT_LOG_FILE ]; then # we need certificates here
82
SCRIPTNAME="dbtests.sh"
83
DBTEST_LOG=${HOSTDIR}/dbtest.log #we don't want all the errormessages
84
# in the output.log, otherwise we can't tell what's a real error
85
RONLY_DIR=${HOSTDIR}/ronlydir
86
EMPTY_DIR=${HOSTDIR}/emptydir
88
html_head "CERT and Key DB Tests"
92
############################## dbtest_cleanup ############################
93
# local shell function to finish this script (no exit since it might be
95
########################################################################
100
chmod a+rw $RONLY_DIR
107
echo "---------------------------------------------------------------"
109
echo "---------------------------------------------------------------"
116
Echo "test opening the database read/write in a nonexisting directory"
117
certutil -L -X -d ./non_existant_dir
119
if [ $ret -ne 255 ]; then
120
html_failed "<TR><TD> Certutil succeeded in a nonexisting directory $ret"
122
html_passed "<TR><TD> Certutil didn't work in a nonexisting dir $ret"
124
dbtest -r -d ./non_existant_dir
126
if [ $ret -ne 46 ]; then
127
html_failed "<TR><TD> Dbtest readonly succeeded in a nonexisting directory $ret"
129
html_passed "<TR><TD> Dbtest readonly didn't work in a nonexisting dir $ret"
132
Echo "test force opening the database in a nonexisting directory"
133
dbtest -f -d ./non_existant_dir
135
if [ $ret -ne 0 ]; then
136
html_failed "<TR><TD> Dbtest force failed in a nonexisting directory $ret"
138
html_passed "<TR><TD> Dbtest force succeeded in a nonexisting dir $ret"
141
Echo "test opening the database readonly in an empty directory"
143
tstclnt -h ${HOST} -d $EMPTY_DIR
145
if [ $ret -ne 1 ]; then
146
html_failed "<TR><TD> Tstclnt succeded in an empty directory $ret"
148
html_passed "<TR><TD> Tstclnt didn't work in an empty dir $ret"
150
dbtest -r -d $EMPTY_DIR
152
if [ $ret -ne 46 ]; then
153
html_failed "<TR><TD> Dbtest readonly succeeded in an empty directory $ret"
155
html_passed "<TR><TD> Dbtest readonly didn't work in an empty dir $ret"
157
rm -rf $EMPTY_DIR/* 2>/dev/null
158
certutil -D -n xxxx -d $EMPTY_DIR #created DB
160
if [ $ret -ne 255 ]; then
161
html_failed "<TR><TD> Certutil succeeded in deleting a cert in an empty directory $ret"
163
html_passed "<TR><TD> Certutil didn't work in an empty dir $ret"
165
rm -rf $EMPTY_DIR/* 2>/dev/null
166
Echo "test force opening the database readonly in a empty directory"
167
dbtest -r -f -d $EMPTY_DIR
169
if [ $ret -ne 0 ]; then
170
html_failed "<TR><TD> Dbtest force readonly failed in an empty directory $ret"
172
html_passed "<TR><TD> Dbtest force readonly succeeded in an empty dir $ret"
175
Echo "test opening the database r/w in a readonly directory"
177
cp -r ${CLIENTDIR}/* $RONLY_DIR
178
chmod -w $RONLY_DIR $RONLY_DIR/*
180
# On Mac OS X 10.1, if we do a "chmod -w" on files in an
181
# NFS-mounted directory, it takes several seconds for the
182
# first open to see the files are readonly, but subsequent
183
# opens immediately see the files are readonly. As a
184
# workaround we open the files once first. (Bug 185074)
185
if [ "${OS_ARCH}" = "Darwin" ]; then
186
cat $RONLY_DIR/* > /dev/null
191
if [ $ret -ne 46 ]; then
192
html_failed "<TR><TD> Dbtest r/w succeeded in an readonly directory $ret"
194
html_passed "<TR><TD> Dbtest r/w didn't work in an readonly dir $ret"
196
certutil -D -n "TestUser" -d .
198
if [ $ret -ne 255 ]; then
199
html_failed "<TR><TD> Certutil succeeded in deleting a cert in an readonly directory $ret"
201
html_passed "<TR><TD> Certutil didn't work in an readonly dir $ret"
204
Echo "test opening the database ronly in a readonly directory"
206
dbtest -d $RONLY_DIR -r
208
if [ $ret -ne 0 ]; then
209
html_failed "<TR><TD> Dbtest readonly failed in a readonly directory $ret"
211
html_passed "<TR><TD> Dbtest readonly succeeded in a readonly dir $ret"
214
Echo "test force opening the database r/w in a readonly directory"
215
dbtest -d $RONLY_DIR -f
217
if [ $ret -ne 0 ]; then
218
html_failed "<TR><TD> Dbtest force failed in a readonly directory $ret"
220
html_passed "<TR><TD> Dbtest force succeeded in a readonly dir $ret"
223
Echo "ls -l $RONLY_DIR"
224
ls -ld $RONLY_DIR $RONLY_DIR/*
228
################## main #################################################
231
dbtest_main >$DBTEST_LOG 2>&1