changeset 14567:f08c91aa150d

8157417: Some of SecureRandom test might get timed out in linux Reviewed-by: weijun
author ssahoo
date Fri, 20 May 2016 09:57:01 -0700
parents 0fca98a37871
children 8c75ff8185c6 6b5863d6cd01
files test/java/security/SecureRandom/GetInstanceTest.java test/java/security/SecureRandom/MultiThreadTest.java test/java/security/SecureRandom/SerializedSeedTest.java test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java
diffstat 4 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/security/SecureRandom/GetInstanceTest.java	Fri May 20 09:40:29 2016 -0700
+++ b/test/java/security/SecureRandom/GetInstanceTest.java	Fri May 20 09:57:01 2016 -0700
@@ -36,12 +36,9 @@
 import java.security.SecureRandom;
 import java.security.SecureRandomParameters;
 import java.security.DrbgParameters;
-
 import static java.security.DrbgParameters.Capability.*;
-
 import java.security.Security;
 import java.util.Arrays;
-
 import jdk.testlibrary.Asserts;
 
 public class GetInstanceTest {
@@ -77,13 +74,16 @@
                     + "strong algorithm through security Property: "
                     + "'securerandom.strongAlgorithms'.");
         }
-        Security.setProperty(STRONG_ALG_SEC_PROP, "DRBG:SUN");
-        sr = matchExc(() -> SecureRandom.getInstanceStrong(),
-                PASS, NoSuchAlgorithmException.class,
-                "PASS - Undefined security Property "
-                + "'securerandom.strongAlgorithms'");
-        checkAttributes(sr, "DRBG");
-        Security.setProperty(STRONG_ALG_SEC_PROP, origDRBGConfig);
+        try {
+            Security.setProperty(STRONG_ALG_SEC_PROP, "DRBG:SUN");
+            sr = matchExc(() -> SecureRandom.getInstanceStrong(),
+                    PASS, NoSuchAlgorithmException.class,
+                    "PASS - Undefined security Property "
+                    + "'securerandom.strongAlgorithms'");
+            checkAttributes(sr, "DRBG");
+        } finally {
+            Security.setProperty(STRONG_ALG_SEC_PROP, origDRBGConfig);
+        }
 
         for (String mech : new String[]{
             "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG", INVALID_ALGO,}) {
--- a/test/java/security/SecureRandom/MultiThreadTest.java	Fri May 20 09:40:29 2016 -0700
+++ b/test/java/security/SecureRandom/MultiThreadTest.java	Fri May 20 09:57:01 2016 -0700
@@ -41,7 +41,7 @@
  * @library /lib/testlibrary
  * @summary Test behavior of a shared SecureRandom object when it is operated
  *          by multiple threads concurrently.
- * @run main MultiThreadTest
+ * @run main/othervm -Djava.security.egd=file:/dev/urandom MultiThreadTest
  */
 public class MultiThreadTest {
 
--- a/test/java/security/SecureRandom/SerializedSeedTest.java	Fri May 20 09:40:29 2016 -0700
+++ b/test/java/security/SecureRandom/SerializedSeedTest.java	Fri May 20 09:57:01 2016 -0700
@@ -29,7 +29,7 @@
  *          as well from it's serialized instance in the same time then the
  *          generated random numbers should be different when one or both are
  *          reseeded.
- * @run main SerializedSeedTest
+ * @run main/othervm -Djava.security.egd=file:/dev/urandom SerializedSeedTest
  */
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
--- a/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java	Fri May 20 09:40:29 2016 -0700
+++ b/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java	Fri May 20 09:57:01 2016 -0700
@@ -27,7 +27,6 @@
  * @bug 6998583 8141039
  * @summary NativeSeedGenerator is making 8192 byte read requests from
  *             entropy pool on each init.
- * @run main SeedGeneratorChoice
  * @run main/othervm -Djava.security.egd=file:/dev/random SeedGeneratorChoice
  * @run main/othervm -Djava.security.egd=file:filename  SeedGeneratorChoice
  */