You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/11/24 08:16:29 UTC
svn commit: r478786 -
/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java
Author: mloenko
Date: Thu Nov 23 23:16:22 2006
New Revision: 478786
URL: http://svn.apache.org/viewvc?view=rev&rev=478786
Log:
lower down probability of intermittent failure in the test
see also HARMONY-2284
[classlib][drlvm][security] intermittent failures of security module tests
Modified:
harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java
Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java?view=diff&rev=478786&r1=478785&r2=478786
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java Thu Nov 23 23:16:22 2006
@@ -30,8 +30,8 @@
*/
public class SHA1PRNG_SecureRandomTest extends TestCase {
- private static final int LENGTH = 100; // constant defining loop limit
- private static final int INCR = 10; // constant defining loop increment
+ private static final int LENGTH = 20; // constant defining loop limit
+ private static final int INCR = 2; // constant defining loop increment
private static final String algorithm = "SHA1PRNG"; // algorithm's name
private static final String provider = "Crypto"; // provider's name
@@ -207,14 +207,23 @@
myBytes1 = new byte[i];
myBytes2 = new byte[i];
+
sr1.nextBytes(myBytes1);
sr2.nextBytes(myBytes2);
+ for ( int j = 0; j < i; j++ ) {
+ flag &= myBytes1[j] == myBytes2[j];
+ }
+ // check again to avoid intermittent failures
+ sr1.nextBytes(myBytes1);
+ sr2.nextBytes(myBytes2);
for ( int j = 0; j < i; j++ ) {
flag &= myBytes1[j] == myBytes2[j];
}
+
if ( flag ) {
- fail("unexpected: myBytes1[] == myBytes2[] :: i=" + i);
+ // probability of false failure is 1.5*10^-5 per run
+ fail("TESTING RANDOM NUMBER GENERATOR QUALITY: IGNORE THIS FAILURE IF INTERMITTENT :: i=" + i);
}
}
}