test/jdk/sun/security/tools/keytool/autotest.sh
author jjiang
Thu, 16 Aug 2018 02:00:31 +0800
changeset 51461 58d7aa066071
parent 49882 a02abc7e5536
permissions -rw-r--r--
8209537: Two security tests failed after JDK-8164639 due to dependency was missed Summary: Skip sun/security/tools/keytool/autotest.sh on macosx and add /test/lib to sun/security/ec/TestEC.java Reviewed-by: rhalade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#
49882
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
     2
# Copyright (c) 2006, 2018, 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
49882
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
    27
# @library /test/lib
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
    28
# @build jdk.test.lib.util.FileUtils
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
    29
# @run shell/timeout=600 autotest.sh
2067
6f9db5f305cd 6780416: New keytool commands/options: -gencert, -printcertreq, -ext
weijun
parents: 629
diff changeset
    30
# This test is only executed on several platforms
6f9db5f305cd 6780416: New keytool commands/options: -gencert, -printcertreq, -ext
weijun
parents: 629
diff changeset
    31
#
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
# set a few environment variables so that the shell-script can run stand-alone
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
# in the source directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
if [ "${TESTSRC}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  TESTSRC="."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
if [ "${TESTCLASSES}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  TESTCLASSES="."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
if [ "${TESTJAVA}" = "" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  echo "TESTJAVA not set.  Test cannot execute."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  echo "FAILED!!!"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
fi
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 14182
diff changeset
    45
if [ "${COMPILEJAVA}" = "" ]; then
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 14182
diff changeset
    46
  COMPILEJAVA="${TESTJAVA}"
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 14182
diff changeset
    47
fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    49
find_one() {
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    50
  for TARGET_FILE in $@; do
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    51
    if [ -e "$TARGET_FILE" ]; then
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    52
      echo $TARGET_FILE
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    53
      return
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    54
    fi
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    55
  done
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    56
}
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    57
20762
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    58
FS="/"
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    59
${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
    60
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
    61
if [ "$?" != "0" ]; then
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    62
  B32=false
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    63
else
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    64
  B32=true
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    65
fi
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    66
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
# set platform-dependent variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
OS=`uname -s`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
case "$OS" in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  SunOS )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    FS="/"
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 15254
diff changeset
    72
    LIBNAME="/usr/lib/mps/`isainfo -n`/libsoftokn3.so"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  Linux )
20762
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
    75
    if [ $B32 = true ]; then
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    76
        LIBNAME=`find_one \
24629
97bddac495b7 8044038: Security tests fail on 32 bit linux platform
vinnie
parents: 22965
diff changeset
    77
            "/usr/lib32/libsoftokn3.so" \
97bddac495b7 8044038: Security tests fail on 32 bit linux platform
vinnie
parents: 22965
diff changeset
    78
            "/usr/lib32/nss/libsoftokn3.so" \
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    79
            "/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
    80
            "/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
    81
            "/usr/lib/nss/libsoftokn3.so"`
14010
24f9f29d5532 7200682: TEST_BUG: keytool/autotest.sh still has problems with libsoftokn.so
weijun
parents: 13809
diff changeset
    82
    else
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    83
        LIBNAME=`find_one \
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
    84
            "/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
    85
            "/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
    86
            "/usr/lib/nss/libsoftokn3.so"`
14010
24f9f29d5532 7200682: TEST_BUG: keytool/autotest.sh still has problems with libsoftokn.so
weijun
parents: 13809
diff changeset
    87
    fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
  * )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    echo "Will not run test on: ${OS}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    exit 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
esac
49882
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
    94
case "$OS" in
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
    95
  Windows_* | CYGWIN* )
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
    96
    PS=";"
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
    97
    ;;
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
    98
  * )
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
    99
    PS=":"
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
   100
    ;;
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
   101
esac
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
   103
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
   104
  echo "Cannot find libsoftokn3.so"
20762
7ec392af43cd 8026235: keytool NSS test should use 64 bit lib on Solaris
weijun
parents: 15254
diff changeset
   105
  exit 0
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
   106
fi
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
   107
26863
0f0d2cdda7d3 8059313: Enable keytool NSS test on Mac
weijun
parents: 24629
diff changeset
   108
echo "Using NSS lib at $LIBNAME"
0f0d2cdda7d3 8059313: Enable keytool NSS test on Mac
weijun
parents: 24629
diff changeset
   109
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 36928
diff changeset
   110
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
   111
 --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
   112
 --add-exports java.base/sun.security.x509=ALL-UNNAMED"
49882
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
   113
${COMPILEJAVA}${FS}bin${FS}javac -classpath ${TESTCLASSPATH} ${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
   114
        ${TESTSRC}${FS}KeyToolTest.java || exit 10
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
NSS=${TESTSRC}${FS}..${FS}..${FS}pkcs11${FS}nss
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
cp ${TESTSRC}${FS}p11-nss.txt .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
cp ${NSS}${FS}db${FS}cert8.db .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
cp ${NSS}${FS}db${FS}key3.db .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
cp ${NSS}${FS}db${FS}secmod.db .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
chmod u+w key3.db
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
chmod u+w cert8.db
49882
a02abc7e5536 8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks
vtewari
parents: 47216
diff changeset
   125
echo | ${TESTJAVA}${FS}bin${FS}java -classpath .${PS}${TESTCLASSPATH} ${TESTVMOPTS} ${EXTRAOPTS} -Dnss \
13809
dea6d093c703 7196855: autotest.sh fails on ubuntu because libsoftokn.so not found
weijun
parents: 12294
diff changeset
   126
   -Dnss.lib=${LIBNAME} \
629
9ceba556df24 6705313: Incorrect exit $? in keytool's autotest.sh
weijun
parents: 2
diff changeset
   127
   KeyToolTest
9ceba556df24 6705313: Incorrect exit $? in keytool's autotest.sh
weijun
parents: 2
diff changeset
   128
status=$?
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
629
9ceba556df24 6705313: Incorrect exit $? in keytool's autotest.sh
weijun
parents: 2
diff changeset
   130
exit $status