Fwd: RFR (XS) JDK-8051861 [TESTBUG] test "java/math/BigInteger/BigIntegerTest.java" does not hold Random value to have a possibility to reproduce it

vasily stolbov vasily.stolbov at oracle.com
Mon Aug 4 14:01:49 UTC 2014




-------- Original Message --------
Subject: 	RFR (XS) JDK-8051861 [TESTBUG] test 
"java/math/BigInteger/BigIntegerTest.java" does not hold Random value to 
have a possibility to reproduce it
Date: 	Mon, 04 Aug 2014 17:45:02 +0400
From: 	vasily stolbov <vasily.stolbov at oracle.com>
Organization: 	Oracle Corporation
To: 	core-libs-dev at openjdk.java.net




Hi,

Please review and help me with integration:

Problem:
java.math.BigInteger.BigIntegerTest  uses java.math.Random(), so we have
no possibility to reproduce it.

Solution:
Test gets start random seed   from environment variable.
If this variable not exists,  test write current random seed   to log.

Bug: https://bugs.openjdk.java.net/browse/JDK-8051861
Fix: (in attachment)

Best regards, Vasily









-------------- next part --------------
diff -r 08d0c4b1a48d test/java/math/BigInteger/BigIntegerTest.java
--- a/test/java/math/BigInteger/BigIntegerTest.java	Wed Jul 02 10:03:40 2014 +0100
+++ b/test/java/math/BigInteger/BigIntegerTest.java	Fri Jul 25 19:22:05 2014 +0400
@@ -34,6 +34,8 @@
 import java.io.FileOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.lang.Long;
+import java.lang.System;
 import java.math.BigInteger;
 import java.util.Random;
 
@@ -944,8 +946,23 @@
      *
      */
     public static void main(String[] args) throws Exception {
+      //reproducibility fix
+        String seed = System.getProperty("startseed");
+        if(seed!=null){
+            rnd.setSeed(Long.valueOf(seed).longValue());
+            System.err.println("Seed: " + seed);
+        }else{
+            Long currentSeed = rnd.nextLong();
+            System.err.println("Seed: " + currentSeed);
+            rnd.setSeed(currentSeed);
+        }
+
+
+
 
         // Some variables for sizing test numbers in bits
+
+
         int order1 = ORDER_MEDIUM;
         int order2 = ORDER_SMALL;
         int order3 = ORDER_KARATSUBA;



More information about the core-libs-dev mailing list