1 /* 2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 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 package com.oracle.java.testlibrary; 25 26 import static com.oracle.java.testlibrary.Asserts.assertTrue; 27 import java.io.BufferedReader; 28 import java.io.File; 29 import java.io.FileReader; 30 import java.io.IOException; 31 import java.lang.reflect.Field; 32 import java.net.InetAddress; 33 import java.net.ServerSocket; 34 import java.net.UnknownHostException; 35 import java.nio.file.Files; 36 import java.nio.file.Path; 37 import java.nio.file.Paths; 38 import java.util.ArrayList; 39 import java.util.Arrays; 40 import java.util.Collections; 41 import java.util.List; 42 import java.util.Random; 43 import java.util.function.BooleanSupplier; 44 import java.util.concurrent.TimeUnit; 45 import java.util.regex.Matcher; 46 import java.util.regex.Pattern; 55 /** 56 * Returns the sequence used by operating system to separate lines. 57 */ 58 public static final String NEW_LINE = System.getProperty("line.separator"); 59 60 /** 61 * Returns the value of 'test.vm.opts'system property. 62 */ 63 public static final String VM_OPTIONS = System.getProperty("test.vm.opts", "").trim(); 64 65 /** 66 * Returns the value of 'test.java.opts'system property. 67 */ 68 public static final String JAVA_OPTIONS = System.getProperty("test.java.opts", "").trim(); 69 70 private static Unsafe unsafe = null; 71 72 /** 73 * Defines property name for seed value. 74 */ 75 public static final String SEED_PROPERTY_NAME = "com.oracle.java.testlibrary.random.seed"; 76 77 /* (non-javadoc) 78 * Random generator with (or without) predefined seed. Depends on 79 * "com.oracle.java.testlibrary.random.seed" property value. 80 */ 81 private static volatile Random RANDOM_GENERATOR; 82 83 /** 84 * Contains the seed value used for {@link java.util.Random} creation. 85 */ 86 public static final long SEED = Long.getLong(SEED_PROPERTY_NAME, new Random().nextLong()); 87 /** 88 * Returns the value of 'test.timeout.factor' system property 89 * converted to {@code double}. 90 */ 91 public static final double TIMEOUT_FACTOR; 92 static { 93 String toFactor = System.getProperty("test.timeout.factor", "1.0"); 94 TIMEOUT_FACTOR = Double.parseDouble(toFactor); 95 } 96 97 /** 98 * Returns the value of JTREG default test timeout in milliseconds 99 * converted to {@code long}. | 1 /* 2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 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 package jdk.test.lib; 25 26 import static jdk.test.lib.Asserts.assertTrue; 27 import java.io.BufferedReader; 28 import java.io.File; 29 import java.io.FileReader; 30 import java.io.IOException; 31 import java.lang.reflect.Field; 32 import java.net.InetAddress; 33 import java.net.ServerSocket; 34 import java.net.UnknownHostException; 35 import java.nio.file.Files; 36 import java.nio.file.Path; 37 import java.nio.file.Paths; 38 import java.util.ArrayList; 39 import java.util.Arrays; 40 import java.util.Collections; 41 import java.util.List; 42 import java.util.Random; 43 import java.util.function.BooleanSupplier; 44 import java.util.concurrent.TimeUnit; 45 import java.util.regex.Matcher; 46 import java.util.regex.Pattern; 55 /** 56 * Returns the sequence used by operating system to separate lines. 57 */ 58 public static final String NEW_LINE = System.getProperty("line.separator"); 59 60 /** 61 * Returns the value of 'test.vm.opts'system property. 62 */ 63 public static final String VM_OPTIONS = System.getProperty("test.vm.opts", "").trim(); 64 65 /** 66 * Returns the value of 'test.java.opts'system property. 67 */ 68 public static final String JAVA_OPTIONS = System.getProperty("test.java.opts", "").trim(); 69 70 private static Unsafe unsafe = null; 71 72 /** 73 * Defines property name for seed value. 74 */ 75 public static final String SEED_PROPERTY_NAME = "jdk.test.lib.random.seed"; 76 77 /* (non-javadoc) 78 * Random generator with (or without) predefined seed. Depends on 79 * "jdk.test.lib.random.seed" property value. 80 */ 81 private static volatile Random RANDOM_GENERATOR; 82 83 /** 84 * Contains the seed value used for {@link java.util.Random} creation. 85 */ 86 public static final long SEED = Long.getLong(SEED_PROPERTY_NAME, new Random().nextLong()); 87 /** 88 * Returns the value of 'test.timeout.factor' system property 89 * converted to {@code double}. 90 */ 91 public static final double TIMEOUT_FACTOR; 92 static { 93 String toFactor = System.getProperty("test.timeout.factor", "1.0"); 94 TIMEOUT_FACTOR = Double.parseDouble(toFactor); 95 } 96 97 /** 98 * Returns the value of JTREG default test timeout in milliseconds 99 * converted to {@code long}. |