8144806: sun/security/tools/keytool/standard.sh fails intermittently at deleting x.jks

Reviewed-by: weijun
This commit is contained in:
Bhanu Prakash Gopularam 2018-04-25 12:29:48 +05:30 committed by Vyom Tewari
parent 2dbc9735ac
commit a3ed7dd7d6
3 changed files with 33 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -65,6 +65,7 @@ import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.security.cert.X509Certificate;
import jdk.test.lib.util.FileUtils;
import sun.security.util.ObjectIdentifier;
public class KeyToolTest {
@ -118,9 +119,10 @@ public class KeyToolTest {
if (debug) {
System.err.println("Removing " + filename);
}
new File(filename).delete();
if (new File(filename).exists()) {
throw new RuntimeException("Error deleting " + filename);
try{
FileUtils.deleteFileIfExistsWithRetry(Paths.get(filename));
}catch(IOException e) {
throw new RuntimeException("Error deleting " + filename, e);
}
}

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,9 @@
# @test
# @summary (almost) all keytool behaviors
# @author Weijun Wang
#
# @library /test/lib
# @build jdk.test.lib.util.FileUtils
# @run shell/timeout=600 autotest.sh
# This test is only executed on several platforms
#
# set a few environment variables so that the shell-script can run stand-alone
@ -92,6 +94,14 @@ case "$OS" in
exit 0;
;;
esac
case "$OS" in
Windows_* | CYGWIN* )
PS=";"
;;
* )
PS=":"
;;
esac
if [ "$LIBNAME" = "" ]; then
echo "Cannot find libsoftokn3.so"
@ -103,8 +113,7 @@ echo "Using NSS lib at $LIBNAME"
EXTRAOPTS="--add-exports java.base/sun.security.tools.keytool=ALL-UNNAMED \
--add-exports java.base/sun.security.util=ALL-UNNAMED \
--add-exports java.base/sun.security.x509=ALL-UNNAMED"
${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . -XDignore.symbol.file \
${COMPILEJAVA}${FS}bin${FS}javac -classpath ${TESTCLASSPATH} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . -XDignore.symbol.file \
${TESTSRC}${FS}KeyToolTest.java || exit 10
NSS=${TESTSRC}${FS}..${FS}..${FS}pkcs11${FS}nss
@ -116,8 +125,7 @@ cp ${NSS}${FS}db${FS}secmod.db .
chmod u+w key3.db
chmod u+w cert8.db
echo | ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${EXTRAOPTS} -Dnss \
echo | ${TESTJAVA}${FS}bin${FS}java -classpath .${PS}${TESTCLASSPATH} ${TESTVMOPTS} ${EXTRAOPTS} -Dnss \
-Dnss.lib=${LIBNAME} \
KeyToolTest
status=$?

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,8 @@
# @test
# @summary (almost) all keytool behaviors
# @author Weijun Wang
# @library /test/lib
# @build jdk.test.lib.util.FileUtils
# @run shell/timeout=600 standard.sh
# @key intermittent
@ -57,14 +59,22 @@ case "$OS" in
exit 1;
;;
esac
case "$OS" in
Windows_* | CYGWIN* )
PS=";"
;;
* )
PS=":"
;;
esac
EXTRAOPTS="--add-exports java.base/sun.security.tools.keytool=ALL-UNNAMED \
--add-exports java.base/sun.security.util=ALL-UNNAMED \
--add-exports java.base/sun.security.x509=ALL-UNNAMED"
${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . -XDignore.symbol.file ${TESTSRC}${FS}KeyToolTest.java || exit 10
${COMPILEJAVA}${FS}bin${FS}javac -classpath ${TESTCLASSPATH} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . -XDignore.symbol.file ${TESTSRC}${FS}KeyToolTest.java || exit 10
echo | ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${EXTRAOPTS} -Dfile KeyToolTest
echo | ${TESTJAVA}${FS}bin${FS}java -classpath .${PS}${TESTCLASSPATH} ${TESTVMOPTS} ${EXTRAOPTS} -Dfile KeyToolTest
status=$?
exit $status