harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r478840 - /harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java
Date Fri, 24 Nov 2006 11:47:10 GMT
Author: mloenko
Date: Fri Nov 24 03:47:09 2006
New Revision: 478840

URL: http://svn.apache.org/viewvc?view=rev&rev=478840
Log:
lower down probability of ONE MORE 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=478840&r1=478839&r2=478840
==============================================================================
--- 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
Fri Nov 24 03:47:09 2006
@@ -194,7 +194,6 @@
         SecureRandom sr1;    // these are needed to test new SecureRandom objects in loop
         SecureRandom sr2;    //
 
-        byte[] myBytes;
         byte[] myBytes1;
         byte[] myBytes2;
 
@@ -222,7 +221,7 @@
             }
 
             if ( flag ) {
-                // probability of false failure is 1.5*10^-5 per run
+                // probability of false failure is 1.5*10^-5 per run for i=1 or less for
i > 1
                 fail("TESTING RANDOM NUMBER GENERATOR QUALITY: IGNORE THIS FAILURE IF INTERMITTENT
:: i=" + i);
             }
         }
@@ -265,14 +264,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 for i=1 or less for
i > 1
+                fail("TESTING RANDOM NUMBER GENERATOR QUALITY: IGNORE THIS FAILURE IF INTERMITTENT
:: i=" + i);
             }
         }
 



Mime
View raw message