jdk/test/sun/security/pkcs11/KeyStore/Basic.sh
author tbell
Tue, 11 Nov 2008 22:01:08 -0800
changeset 1546 a02228c60567
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6764892: VS2008 changes required to compile hotspot sources Summary: Minor changes required to build using the Visual Studio 2008 compiler Reviewed-by: kvn, ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
# Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
# CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
# have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
# @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
# @bug 4938185
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
# @summary KeyStore support for NSS cert/key databases
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
# @run shell Basic.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
# To run by hand:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#    %sh Basic.sh <recompile> [yes|no]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#		  <token>     [activcard|ibutton|nss|sca1000]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#                 <command>   [list|basic]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#    %sh Basic.sh no ibutton list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
# Note:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#    . 'list' lists the token aliases
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#    . 'basic' does not run with activcard,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#      and tests different things depending on what is supported by each token
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
# set a few environment variables so that the shell-script can run stand-alone
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
# in the source directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
# if running by hand on windows, change TESTSRC and TESTCLASSES to "."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
if [ "${TESTSRC}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    TESTSRC=`pwd`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
if [ "${TESTCLASSES}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    TESTCLASSES=`pwd`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
# if running by hand on windows, change this to appropriate value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
if [ "${TESTJAVA}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    TESTJAVA="/net/radiant/export1/charlie/mustang/build/solaris-sparc"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
echo TESTSRC=${TESTSRC}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
echo TESTCLASSES=${TESTCLASSES}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
echo TESTJAVA=${TESTJAVA}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
echo ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
# get command from input args -
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
# default to 'nss basic'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
RECOMPILE="yes"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
if [ $# = '3' ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    RECOMPILE=$1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    TOKEN=$2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    TEST=$3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
elif [ $# = '2' ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    TOKEN=$1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    TEST=$2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    TOKEN="nss"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    TEST="basic"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
DEBUG=sunpkcs11,pkcs11keystore
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
echo RECOMPILE=${RECOMPILE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
echo TOKEN=${TOKEN}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
echo TEST=${TEST}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
echo DEBUG=${DEBUG}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
echo ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
OS=`uname -s`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
case "$OS" in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
  SunOS )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    ARCH=`isainfo`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    case "$ARCH" in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
      sparc* )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
	FS="/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
	PS=":"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
	CP="${FS}bin${FS}cp"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
	CHMOD="${FS}bin${FS}chmod"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
	;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
      i[3-6]86 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
	FS="/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
	PS=":"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
	CP="${FS}bin${FS}cp"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
	CHMOD="${FS}bin${FS}chmod"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
	;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
      amd64* )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
	FS="/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
	PS=":"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
	CP="${FS}bin${FS}cp"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
	CHMOD="${FS}bin${FS}chmod"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
	;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
      * )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#     ?itanium? )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
#     amd64* )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
	echo "Unsupported System: Solaris ${ARCH}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
	exit 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
	;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  Linux )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    ARCH=`uname -m`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    case "$ARCH" in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      i[3-6]86 ) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
	FS="/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
	PS=":"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
	CP="${FS}bin${FS}cp"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
	CHMOD="${FS}bin${FS}chmod"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
	;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
      * )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
#     ia64 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
#     x86_64 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
	echo "Unsupported System: Linux ${ARCH}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
	exit 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
	;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  Windows* )  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    FS="\\"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    PS=";"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    CP="cp"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    CHMOD="chmod"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    # 'uname -m' does not give us enough information -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    #  should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    #  but JTREG does not pass this env variable when executing a shell script.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    #
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    #  execute test program - rely on it to exit if platform unsupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
  * )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    echo "Unsupported System: ${OS}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    exit 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
# first make cert/key DBs writable if token is NSS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
if [ "${TOKEN}" = "nss" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    ${CHMOD} +w ${TESTCLASSES}${FS}cert8.db
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    ${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    ${CHMOD} +w ${TESTCLASSES}${FS}key3.db
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
# compile test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
if [ "${RECOMPILE}" = "yes" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    ${TESTJAVA}${FS}bin${FS}javac \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
	-classpath ${TESTSRC}${FS}..${PS}${TESTSRC}${FS}loader.jar \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
	-d ${TESTCLASSES} \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
	${TESTSRC}${FS}Basic.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
# run test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
${TESTJAVA}${FS}bin${FS}java \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
	-classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
	-DDIR=${TESTSRC}${FS}BasicData \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
	-DCUSTOM_DB_DIR=${TESTCLASSES} \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
	-DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${TOKEN}.txt \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
	-DNO_DEFAULT=true \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
	-DNO_DEIMOS=true \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
	-DTOKEN=${TOKEN} \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
	-DTEST=${TEST} \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
	-Dtest.src=${TESTSRC} \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
	-Dtest.classes=${TESTCLASSES} \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
	-Djava.security.manager \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
	-Djava.security.policy=${TESTSRC}${FS}Basic.policy \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
	-Djava.security.debug=${DEBUG} \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
	Basic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
# save error status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
status=$?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
# return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
exit $status