jdk/test/sun/security/tools/keytool/autotest.sh
author mchung
Wed, 10 Aug 2016 15:51:25 -0700
changeset 40261 86a49ba76f52
parent 36928 71f5c0728dfc
permissions -rw-r--r--
8136930: Simplify use of module-system options by custom launchers Reviewed-by: alanb, ksrini, henryjen, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#
24629
97bddac495b7 8044038: Security tests fail on 32 bit linux platform
vinnie
parents: 22965
diff changeset
     2
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
2
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
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2067
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2067
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2067
diff changeset
    21
# questions.
2
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
# @summary (almost) all keytool behaviors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
# @author Weijun Wang
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#
2067
6f9db5f305cd 6780416: New keytool commands/options: -gencert, -printcertreq, -ext
weijun
parents: 629
diff changeset
    28
# This test is only executed on several platforms
6f9db5f305cd 6780416: New keytool commands/options: -gencert, -printcertreq, -ext
weijun
parents: 629
diff changeset
    29
#
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
# set a few environment variables so that the shell-script can run stand-alone
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
# in the source directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
if [ "${TESTSRC}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
  TESTSRC="."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
if [ "${TESTCLASSES}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  TESTCLASSES="."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
if [ "${TESTJAVA}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  echo "TESTJAVA not set.  Test cannot execute."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  echo "FAILED!!!"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
fi
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 14182
diff changeset
    43
if [ "${COMPILEJAVA}" = "" ]; then
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 14182
diff changeset
    44
  COMPILEJAVA="${TESTJAVA}"
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 14182
diff changeset
    45
fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    47
find_one() {
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    48
  for TARGET_FILE in $@; do
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    49
    if [ -e "$TARGET_FILE" ]; then
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    50
      echo $TARGET_FILE
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    51
      return
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    52
    fi
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    53
  done
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    54
}
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    55
20762
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    56
FS="/"
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    57
${TESTJAVA}${FS}bin${FS}java -XshowSettings:properties -version 2> allprop
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    58
cat allprop | grep sun.arch.data.model | grep 32
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    59
if [ "$?" != "0" ]; then
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    60
  B32=false
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    61
else
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    62
  B32=true
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    63
fi
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    64
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
# set platform-dependent variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
OS=`uname -s`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
case "$OS" in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  SunOS )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    FS="/"
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 15254
diff changeset
    70
    LIBNAME="/usr/lib/mps/`isainfo -n`/libsoftokn3.so"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  Linux )
20762
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    73
    if [ $B32 = true ]; then
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    74
        LIBNAME=`find_one \
24629
97bddac495b7 8044038: Security tests fail on 32 bit linux platform
vinnie
parents: 22965
diff changeset
    75
            "/usr/lib32/libsoftokn3.so" \
97bddac495b7 8044038: Security tests fail on 32 bit linux platform
vinnie
parents: 22965
diff changeset
    76
            "/usr/lib32/nss/libsoftokn3.so" \
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    77
            "/usr/lib/libsoftokn3.so" \
20871
b5fa714232e7 8026712: TEST_BUG: update sun/security/tools/keytool/autotest.sh with a new location to find of libsoftokn3.so
weijun
parents: 20771
diff changeset
    78
            "/usr/lib/i386-linux-gnu/nss/libsoftokn3.so" \
b5fa714232e7 8026712: TEST_BUG: update sun/security/tools/keytool/autotest.sh with a new location to find of libsoftokn3.so
weijun
parents: 20771
diff changeset
    79
            "/usr/lib/nss/libsoftokn3.so"`
14010
24f9f29d5532 7200682: TEST_BUG: keytool/autotest.sh still has problems with libsoftokn.so
weijun
parents: 13809
diff changeset
    80
    else
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    81
        LIBNAME=`find_one \
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    82
            "/usr/lib64/libsoftokn3.so" \
20871
b5fa714232e7 8026712: TEST_BUG: update sun/security/tools/keytool/autotest.sh with a new location to find of libsoftokn3.so
weijun
parents: 20771
diff changeset
    83
            "/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so" \
b5fa714232e7 8026712: TEST_BUG: update sun/security/tools/keytool/autotest.sh with a new location to find of libsoftokn3.so
weijun
parents: 20771
diff changeset
    84
            "/usr/lib/nss/libsoftokn3.so"`
14010
24f9f29d5532 7200682: TEST_BUG: keytool/autotest.sh still has problems with libsoftokn.so
weijun
parents: 13809
diff changeset
    85
    fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    ;;
26863
0f0d2cdda7d3 8059313: Enable keytool NSS test on Mac
weijun
parents: 24629
diff changeset
    87
  Darwin )
26970
51018a2f505d 8060007: Keytool test can use bundled NSS lib on Mac
weijun
parents: 26863
diff changeset
    88
    LIBNAME="$TESTSRC/../../pkcs11/nss/lib/macosx-x86_64/libsoftokn3.dylib"
26863
0f0d2cdda7d3 8059313: Enable keytool NSS test on Mac
weijun
parents: 24629
diff changeset
    89
    ;;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
  * )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    echo "Will not run test on: ${OS}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    exit 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    96
if [ "$LIBNAME" = "" ]; then
14182
3041082abb40 7194449: String resources for Key Tool and Policy Tool should be in their respective packages
sflores
parents: 14010
diff changeset
    97
  echo "Cannot find libsoftokn3.so"
20762
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    98
  exit 0
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    99
fi
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
   100
26863
0f0d2cdda7d3 8059313: Enable keytool NSS test on Mac
weijun
parents: 24629
diff changeset
   101
echo "Using NSS lib at $LIBNAME"
0f0d2cdda7d3 8059313: Enable keytool NSS test on Mac
weijun
parents: 24629
diff changeset
   102
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 36928
diff changeset
   103
EXTRAOPTS="--add-exports java.base/sun.security.tools.keytool=ALL-UNNAMED \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 36928
diff changeset
   104
 --add-exports java.base/sun.security.util=ALL-UNNAMED \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 36928
diff changeset
   105
 --add-exports java.base/sun.security.x509=ALL-UNNAMED"
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27344
diff changeset
   106
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27344
diff changeset
   107
${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . -XDignore.symbol.file \
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
   108
        ${TESTSRC}${FS}KeyToolTest.java || exit 10
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
NSS=${TESTSRC}${FS}..${FS}..${FS}pkcs11${FS}nss
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
cp ${TESTSRC}${FS}p11-nss.txt .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
cp ${NSS}${FS}db${FS}cert8.db .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
cp ${NSS}${FS}db${FS}key3.db .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
cp ${NSS}${FS}db${FS}secmod.db .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
chmod u+w key3.db
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
chmod u+w cert8.db
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27344
diff changeset
   120
echo | ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${EXTRAOPTS} -Dnss \
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
   121
   -Dnss.lib=${LIBNAME} \
629
9ceba556df24 6705313: Incorrect exit $? in keytool's autotest.sh
weijun
parents: 2
diff changeset
   122
   KeyToolTest
9ceba556df24 6705313: Incorrect exit $? in keytool's autotest.sh
weijun
parents: 2
diff changeset
   123
status=$?
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
629
9ceba556df24 6705313: Incorrect exit $? in keytool's autotest.sh
weijun
parents: 2
diff changeset
   125
exit $status