Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/pkcs11/KeyStore/Basic.sh
38855 views
#1# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#2223# @test24# @bug 493818525# @summary KeyStore support for NSS cert/key databases26#27# @run shell Basic.sh2829# To run by hand:30# %sh Basic.sh <recompile> [yes|no]31# <token> [activcard|ibutton|nss|sca1000]32# <command> [list|basic]33#34# %sh Basic.sh no ibutton list35#36# Note:37# . 'list' lists the token aliases38# . 'basic' does not run with activcard,39# and tests different things depending on what is supported by each token4041# set a few environment variables so that the shell-script can run stand-alone42# in the source directory4344# if running by hand on windows, change TESTSRC and TESTCLASSES to "."45if [ "${TESTSRC}" = "" ] ; then46TESTSRC=`pwd`47fi48if [ "${TESTCLASSES}" = "" ] ; then49TESTCLASSES=`pwd`50fi5152# if running by hand on windows, change this to appropriate value53if [ "${TESTJAVA}" = "" ] ; then54TESTJAVA="/net/radiant/export1/charlie/mustang/build/solaris-sparc"55fi56if [ "${COMPILEJAVA}" = "" ]; then57COMPILEJAVA="${TESTJAVA}"58fi59echo TESTSRC=${TESTSRC}60echo TESTCLASSES=${TESTCLASSES}61echo TESTJAVA=${TESTJAVA}62echo echo COMPILEJAVA=${COMPILEJAVA}63echo ""6465# get command from input args -66# default to 'nss basic'6768RECOMPILE="yes"69if [ $# = '3' ] ; then70RECOMPILE=$171TOKEN=$272TEST=$373elif [ $# = '2' ] ; then74TOKEN=$175TEST=$276else77TOKEN="nss"78TEST="basic"79fi8081DEBUG=sunpkcs11,pkcs11keystore8283echo RECOMPILE=${RECOMPILE}84echo TOKEN=${TOKEN}85echo TEST=${TEST}86echo DEBUG=${DEBUG}87echo ""8889OS=`uname -s`90case "$OS" in91SunOS )92ARCH=`isainfo`93case "$ARCH" in94sparc* )95FS="/"96PS=":"97CP="${FS}bin${FS}cp"98CHMOD="${FS}bin${FS}chmod"99;;100i[3-6]86 )101FS="/"102PS=":"103CP="${FS}bin${FS}cp"104CHMOD="${FS}bin${FS}chmod"105;;106amd64* )107FS="/"108PS=":"109CP="${FS}bin${FS}cp"110CHMOD="${FS}bin${FS}chmod"111;;112* )113# ?itanium? )114# amd64* )115echo "Unsupported System: Solaris ${ARCH}"116exit 0;117;;118esac119;;120Linux )121ARCH=`uname -m`122case "$ARCH" in123i[3-6]86 )124FS="/"125PS=":"126CP="${FS}bin${FS}cp"127CHMOD="${FS}bin${FS}chmod"128;;129* )130# ia64 )131# x86_64 )132echo "Unsupported System: Linux ${ARCH}"133exit 0;134;;135esac136;;137Windows* )138FS="\\"139PS=";"140CP="cp"141CHMOD="chmod"142143# 'uname -m' does not give us enough information -144# should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk),145# but JTREG does not pass this env variable when executing a shell script.146#147# execute test program - rely on it to exit if platform unsupported148149;;150* )151echo "Unsupported System: ${OS}"152exit 0;153;;154esac155156# first make cert/key DBs writable if token is NSS157158if [ "${TOKEN}" = "nss" ] ; then159${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}cert8.db ${TESTCLASSES}160${CHMOD} +w ${TESTCLASSES}${FS}cert8.db161162${CP} ${TESTSRC}${FS}..${FS}nss${FS}db${FS}key3.db ${TESTCLASSES}163${CHMOD} +w ${TESTCLASSES}${FS}key3.db164fi165166# compile test167168if [ "${RECOMPILE}" = "yes" ] ; then169${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \170-classpath ${TESTSRC}${FS}..${PS}${TESTSRC}${FS}loader.jar \171-d ${TESTCLASSES} \172${TESTSRC}${FS}Basic.java \173${TESTSRC}${FS}..${FS}PKCS11Test.java174fi175176# run test177178${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \179-classpath ${TESTCLASSES}${PS}${TESTSRC}${FS}loader.jar \180-DDIR=${TESTSRC}${FS}BasicData \181-DCUSTOM_DB_DIR=${TESTCLASSES} \182-DCUSTOM_P11_CONFIG=${TESTSRC}${FS}BasicData${FS}p11-${TOKEN}.txt \183-DNO_DEFAULT=true \184-DNO_DEIMOS=true \185-DTOKEN=${TOKEN} \186-DTEST=${TEST} \187-Dtest.src=${TESTSRC} \188-Dtest.classes=${TESTCLASSES} \189-Djava.security.manager \190-Djava.security.policy=${TESTSRC}${FS}Basic.policy \191-Djava.security.debug=${DEBUG} \192Basic193194# save error status195status=$?196197# return198exit $status199200201