7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @summary Verify correctnes of the random generator from Utility.java 27 * @library /testlibrary 28 * @modules java.base/jdk.internal.misc 29 * java.management 30 * @run driver RandomGeneratorTest SAME_SEED 31 * @run driver RandomGeneratorTest NO_SEED 32 * @run driver RandomGeneratorTest DIFFERENT_SEED 33 */ 34 35 import java.io.FileWriter; 36 import java.io.IOException; 37 import java.io.PrintWriter; 38 import java.util.ArrayList; 39 import java.util.List; 40 import java.util.Random; 41 import jdk.test.lib.OutputAnalyzer; 42 import jdk.test.lib.ProcessTools; 43 import jdk.test.lib.Utils; 44 45 /** 46 * The test verifies correctness of work {@link jdk.test.lib.Utils#getRandomInstance()}. 47 * Test works in three modes: same seed provided, no seed provided and 48 * different seed provided. In the first case the test expects that all random numbers 49 * will be repeated in all next iterations. For other two modes test expects that 50 * randomly generated numbers differ from original. 51 */ 52 public class RandomGeneratorTest { 53 private static final String SEED_VM_OPTION = "-D" + Utils.SEED_PROPERTY_NAME + "="; 54 55 public static void main( String[] args) throws Throwable { 56 if (args.length == 0) { 57 throw new Error("TESTBUG: No test mode provided."); 58 } 59 SeedOption seedOpt = SeedOption.valueOf(args[0]); 60 List<String> jvmArgs = new ArrayList<String>(); 61 String optStr = seedOpt.getSeedOption(); 62 if (optStr != null) { | 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @summary Verify correctnes of the random generator from Utility.java 27 * @library /test/lib 28 * @modules java.base/jdk.internal.misc 29 * java.management 30 * @run driver RandomGeneratorTest SAME_SEED 31 * @run driver RandomGeneratorTest NO_SEED 32 * @run driver RandomGeneratorTest DIFFERENT_SEED 33 */ 34 35 import java.io.FileWriter; 36 import java.io.IOException; 37 import java.io.PrintWriter; 38 import java.util.ArrayList; 39 import java.util.List; 40 import java.util.Random; 41 import jdk.test.lib.process.OutputAnalyzer; 42 import jdk.test.lib.process.ProcessTools; 43 import jdk.test.lib.Utils; 44 45 /** 46 * The test verifies correctness of work {@link jdk.test.lib.Utils#getRandomInstance()}. 47 * Test works in three modes: same seed provided, no seed provided and 48 * different seed provided. In the first case the test expects that all random numbers 49 * will be repeated in all next iterations. For other two modes test expects that 50 * randomly generated numbers differ from original. 51 */ 52 public class RandomGeneratorTest { 53 private static final String SEED_VM_OPTION = "-D" + Utils.SEED_PROPERTY_NAME + "="; 54 55 public static void main( String[] args) throws Throwable { 56 if (args.length == 0) { 57 throw new Error("TESTBUG: No test mode provided."); 58 } 59 SeedOption seedOpt = SeedOption.valueOf(args[0]); 60 List<String> jvmArgs = new ArrayList<String>(); 61 String optStr = seedOpt.getSeedOption(); 62 if (optStr != null) { |