From ea82a852dd3122d66948c85456b7d5e41b656f18 Mon Sep 17 00:00:00 2001 From: Sibabrata Sahoo Date: Fri, 20 May 2016 09:57:01 -0700 Subject: [PATCH] 8157417: Some of SecureRandom test might get timed out in linux Reviewed-by: weijun --- .../SecureRandom/GetInstanceTest.java | 20 +++++++++---------- .../SecureRandom/MultiThreadTest.java | 2 +- .../SecureRandom/SerializedSeedTest.java | 2 +- .../SeedGenerator/SeedGeneratorChoice.java | 1 - 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/jdk/test/java/security/SecureRandom/GetInstanceTest.java b/jdk/test/java/security/SecureRandom/GetInstanceTest.java index 511188a7709..08477da847e 100644 --- a/jdk/test/java/security/SecureRandom/GetInstanceTest.java +++ b/jdk/test/java/security/SecureRandom/GetInstanceTest.java @@ -36,12 +36,9 @@ import java.security.NoSuchProviderException; 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 @@ public class GetInstanceTest { + "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,}) { diff --git a/jdk/test/java/security/SecureRandom/MultiThreadTest.java b/jdk/test/java/security/SecureRandom/MultiThreadTest.java index 17ae3377377..82c6d68dd94 100644 --- a/jdk/test/java/security/SecureRandom/MultiThreadTest.java +++ b/jdk/test/java/security/SecureRandom/MultiThreadTest.java @@ -41,7 +41,7 @@ import static java.lang.Math.*; * @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 { diff --git a/jdk/test/java/security/SecureRandom/SerializedSeedTest.java b/jdk/test/java/security/SecureRandom/SerializedSeedTest.java index ba4289ce4c7..9af7296c4ab 100644 --- a/jdk/test/java/security/SecureRandom/SerializedSeedTest.java +++ b/jdk/test/java/security/SecureRandom/SerializedSeedTest.java @@ -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; diff --git a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java index e6da6be10a1..93889729058 100644 --- a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java +++ b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java @@ -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 */