jdk.test.lib.Platform Java Examples
The following examples show how to use
jdk.test.lib.Platform.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GTestWrapper.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Throwable { // gtestLauncher is located in <test_image>/hotspot/gtest/<vm_variant>/ // nativePath points either to <test_image>/hotspot/jtreg/native or to <test_image>/hotspot/gtest Path nativePath = Paths.get(System.getProperty("test.nativepath")); String jvmVariantDir = getJVMVariantSubDir(); // let's assume it's <test_image>/hotspot/gtest Path path = nativePath.resolve(jvmVariantDir); if (!path.toFile().exists()) { // maybe it is <test_image>/hotspot/jtreg/native path = nativePath.getParent() .getParent() .resolve("gtest") .resolve(jvmVariantDir); } if (!path.toFile().exists()) { throw new Error("TESTBUG: the library has not been found in " + nativePath); } path = path.resolve("gtestLauncher" + (Platform.isWindows() ? ".exe" : "")); ProcessTools.executeCommand(new String[] { path.toString(), "-jdk", System.getProperty("test.jdk") }).shouldHaveExitValue(0); }
Example #2
Source File: ReserveMemory.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().readReservedMemory(); throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!"); } ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "ReserveMemory", "test"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (Platform.isWindows()) { output.shouldContain("EXCEPTION_ACCESS_VIOLATION"); } else if (Platform.isOSX()) { output.shouldContain("SIGBUS"); } else { output.shouldContain("SIGSEGV"); } }
Example #3
Source File: RunUnitTestsConcurrently.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws InterruptedException { if (!Platform.isDebugBuild() || !Platform.is64bit()) { return; } wb = WhiteBox.getWhiteBox(); System.out.println("Starting threads"); int threads = Integer.valueOf(args[0]); timeout = Long.valueOf(args[1]); timeStamp = System.currentTimeMillis(); Thread[] threadsArray = new Thread[threads]; for (int i = 0; i < threads; i++) { threadsArray[i] = new Thread(new Worker()); threadsArray[i].start(); } for (int i = 0; i < threads; i++) { threadsArray[i].join(); } System.out.println("Quitting test."); }
Example #4
Source File: AttachWithStalePidFile.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) throws Exception { // this test is only valid on non-Windows platforms if(Platform.isWindows()) { System.out.println("This test is only valid on non-Windows platforms."); return; } // Since there might be stale pid-files owned by different // users on the system we may need to retry the test in case we // are unable to remove the existing file. int retries = 5; while(!runTest() && --retries > 0); if(retries == 0) { throw new RuntimeException("Test failed after 5 retries. " + "Remove any /tmp/.java_pid* files and retry."); } }
Example #5
Source File: JMapHProfLargeHeapTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { if (!Platform.shouldSAAttach()) { System.out.println("SA attach not expected to work - test skipped."); return; } // All heap dumps should create 1.0.2 file format testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_2); /** * This test was deliberately commented out since the test system lacks * support to handle the requirements for this kind of heap size in a * good way. If or when it becomes possible to run this kind of tests in * the test environment the test should be enabled again. * */ // Large heap 2,2 gigabytes, should create 1.0.2 file format // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2); }
Example #6
Source File: BasicLauncherTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { if (!Platform.shouldSAAttach()) { // Silently skip the test if we don't have enough permissions to attach System.err.println("Error! Insufficient permissions to attach."); return; } launchCLHSDB(); launch("compiler detected", null, "jmap", "--clstats"); launchJStack(); launch("compiler detected", null, "jmap"); launch("Java System Properties", "System Properties info not available", "jinfo"); launch("java.threads", null, "jsnap"); // The test throws RuntimeException on error. // IOException is thrown if LingeredApp can't start because of some bad // environment condition System.out.println("Test PASSED"); }
Example #7
Source File: TestPrintMdo.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main (String... args) throws Exception { LingeredApp app = null; if (!Platform.shouldSAAttach()) { System.out.println( "SA attach not expected to work - test skipped."); return; } try { List<String> vmArgs = new ArrayList<String>(); vmArgs.add("-XX:+ProfileInterpreter"); vmArgs.addAll(Utils.getVmOptions()); app = LingeredApp.startApp(vmArgs); System.out.println ("Started LingeredApp with pid " + app.getPid()); startClhsdbForPrintMdo(app.getPid()); verifyPrintMdoOutput(); } finally { LingeredApp.stopApp(app); } }
Example #8
Source File: CompressedClassPointers.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { if (!Platform.is64bit()) { // Can't test this on 32 bit, just pass System.out.println("Skipping test on 32bit"); return; } // Solaris 10 can't mmap compressed oops space without a base if (Platform.isSolaris()) { String name = System.getProperty("os.version"); if (name.equals("5.10")) { System.out.println("Skipping test on Solaris 10"); return; } } smallHeapTest(); smallHeapTestWith3G(); largeHeapTest(); largePagesTest(); heapBaseMinAddressTest(); sharingTest(); }
Example #9
Source File: AssertSafepointCheckConsistency2.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().assertMatchingSafepointCalls(false, false); } if (Platform.isDebugBuild()){ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "AssertSafepointCheckConsistency2", "test"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("assert").shouldContain("never"); } }
Example #10
Source File: AssertSafepointCheckConsistency1.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().assertMatchingSafepointCalls(true, true); } if (Platform.isDebugBuild()){ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "AssertSafepointCheckConsistency1", "test"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("assert").shouldContain("always"); } }
Example #11
Source File: CompilerUtils.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns available compilation levels * * @return int array with compilation levels */ public static int[] getAvailableCompilationLevels() { if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) { return new int[0]; } if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) { Long flagValue = WhiteBox.getWhiteBox() .getIntxVMFlag("TieredStopAtLevel"); int maxLevel = flagValue.intValue(); Asserts.assertEQ(new Long(maxLevel), flagValue, "TieredStopAtLevel has value out of int capacity"); return IntStream.rangeClosed(1, maxLevel).toArray(); } else { if (Platform.isServer() && !Platform.isEmulatedClient()) { return new int[]{4}; } if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) { return new int[]{1}; } } return new int[0]; }
Example #12
Source File: AssertSafepointCheckConsistency3.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().assertMatchingSafepointCalls(false, true); } if (Platform.isDebugBuild()){ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "AssertSafepointCheckConsistency3", "test"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("assert"); output.shouldNotContain("never"); output.shouldNotContain("always"); } }
Example #13
Source File: TestInstanceKlassSize.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { if (!Platform.shouldSAAttach()) { System.out.println("SA attach not expected to work - test skipped."); return; } if (args == null || args.length == 0) { System.out.println ("No args run. Starting with args now."); startMeWithArgs(); } else { String[] SAInstanceKlassNames = new String[] { "java.lang.Object", "java.util.Vector", "sun.util.PreHashedMap", "java.lang.String", "java.lang.Thread", "java.lang.Byte" }; SAInstanceKlassSize(Integer.parseInt(args[0]), SAInstanceKlassNames); } }
Example #14
Source File: TestMutuallyExclusivePlatformPredicates.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Verifies that all predicates defined in * {@link jdk.test.lib.Platform} were either tested or * explicitly ignored. */ private static void verifyCoverage() { Set<String> allMethods = new HashSet<>(); for (MethodGroup group : MethodGroup.values()) { allMethods.addAll(group.methodNames); } for (Method m : Platform.class.getMethods()) { if (m.getParameterCount() == 0 && m.getReturnType() == boolean.class) { Asserts.assertTrue(allMethods.contains(m.getName()), "All Platform's methods with signature '():Z' should " + "be tested "); } } }
Example #15
Source File: TestNativeLibrariesEvent.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static List<String> getExpectedLibs() throws Throwable { String libTemplate = null; if (Platform.isSolaris()) { libTemplate = "lib%s.so"; } else if (Platform.isWindows()) { libTemplate = "%s.dll"; } else if (Platform.isOSX()) { libTemplate = "lib%s.dylib"; } else if (Platform.isLinux()) { libTemplate = "lib%s.so"; } if (libTemplate == null) { throw new Exception("Unsupported OS"); } List<String> libs = new ArrayList<String>(); String[] names = { "jvm", "java", "zip" }; for (String name : names) { libs.add(String.format(libTemplate, name)); } return libs; }
Example #16
Source File: TestAESIntrinsicsOnSupportedConfig.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Test checks following situation: <br/> * UseAES flag is set to true, UseSSE flag is set to 2, * Platform should support UseSSE (x86 or x64) <br/> * TestAESMain is executed <br/> * Expected result: UseAESIntrinsics flag is set to false <br/> * Output shouldn't contain intrinsics usage <br/> * * @throws Throwable */ private void testUseAESUseSSE2() throws Throwable { if (Platform.isX86() || Platform.isX64()) { OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( prepareArguments(prepareBooleanFlag(AESIntrinsicsBase .USE_AES_INTRINSICS, true), prepareNumericFlag(AESIntrinsicsBase.USE_SSE, 2))); final String errorMessage = "Case testUseAESUseSSE2 failed"; verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, AESIntrinsicsBase.AES_INTRINSIC}, errorMessage, outputAnalyzer); verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage, outputAnalyzer); verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", errorMessage, outputAnalyzer); verifyOptionValue(AESIntrinsicsBase.USE_SSE, "2", errorMessage, outputAnalyzer); } }
Example #17
Source File: DockerTestUtils.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Build a docker image that contains JDK under test. * The jdk will be placed under the "/jdk/" folder inside the docker file system. * * @param imageName name of the image to be created, including version tag * @param dockerfile name of the dockerfile residing in the test source; * we check for a platform specific dockerfile as well * and use this one in case it exists * @param buildDirName name of the docker build/staging directory, which will * be created in the jtreg's scratch folder * @throws Exception */ public static void buildJdkDockerImage(String imageName, String dockerfile, String buildDirName) throws Exception { Path buildDir = Paths.get(".", buildDirName); if (Files.exists(buildDir)) { throw new RuntimeException("The docker build directory already exists: " + buildDir); } // check for the existance of a platform specific docker file as well String platformSpecificDockerfile = dockerfile + "-" + Platform.getOsArch(); if (Files.exists(Paths.get(Utils.TEST_SRC, platformSpecificDockerfile))) { dockerfile = platformSpecificDockerfile; } Path jdkSrcDir = Paths.get(Utils.TEST_JDK); Path jdkDstDir = buildDir.resolve("jdk"); Files.createDirectories(jdkDstDir); // Copy JDK-under-test tree to the docker build directory. // This step is required for building a docker image. Files.walkFileTree(jdkSrcDir, new CopyFileVisitor(jdkSrcDir, jdkDstDir)); buildDockerImage(imageName, Paths.get(Utils.TEST_SRC, dockerfile), buildDir); }
Example #18
Source File: RangeCheck.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { if (!Platform.isDebugBuild()) { System.out.println("Testing assert which requires a debug build. Passing silently."); return; } ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( true, "-Xmx32m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert DummyClassWithMainRangeCheck.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldMatch("assert\\(byte_offset < p_size\\) failed: Unsafe access: offset \\d+ > object's size \\d+"); }
Example #19
Source File: TestAESIntrinsicsOnSupportedConfig.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Test checks following situation: <br/> * UseAES flag is set to false, UseVIS flag is set to 2, * Platform should support UseVIS (sparc) <br/> * TestAESMain is executed <br/> * Expected result: UseAESIntrinsics flag is set to false <br/> * Output shouldn't contain intrinsics usage <br/> * * @throws Throwable */ private void testNoUseAESUseVIS2() throws Throwable { if (Platform.isSparc()) { OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( prepareArguments(prepareBooleanFlag(AESIntrinsicsBase .USE_AES, false), prepareNumericFlag(AESIntrinsicsBase.USE_VIS, 2))); final String errorMessage = "Case testNoUseAESUseVIS2 failed"; verifyOutput(null, new String[]{AESIntrinsicsBase.CIPHER_INTRINSIC, AESIntrinsicsBase.AES_INTRINSIC}, errorMessage, outputAnalyzer); verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage, outputAnalyzer); verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", errorMessage, outputAnalyzer); verifyOptionValue(AESIntrinsicsBase.USE_VIS, "2", errorMessage, outputAnalyzer); } }
Example #20
Source File: TestNativeLibrariesEvent.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static List<String> getExpectedLibs() throws Throwable { String libTemplate = null; if (Platform.isSolaris()) { libTemplate = "lib%s.so"; } else if (Platform.isWindows()) { libTemplate = "%s.dll"; } else if (Platform.isOSX()) { libTemplate = "lib%s.dylib"; } else if (Platform.isLinux()) { libTemplate = "lib%s.so"; } if (libTemplate == null) { throw new Exception("Unsupported OS"); } List<String> libs = new ArrayList<String>(); String[] names = { "jvm", "java", "zip" }; for (String name : names) { libs.add(String.format(libTemplate, name)); } return libs; }
Example #21
Source File: TestUnstableIfTrap.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static boolean isMethodCompiledByC2(Method m) { boolean isTiered = WB.getBooleanVMFlag("TieredCompilation"); boolean isMethodCompiled = WB.isMethodCompiled(m); boolean isMethodCompiledAtMaxTier = WB.getMethodCompilationLevel(m) == MAX_TIER; return Platform.isServer() && !Platform.isEmulatedClient() && isMethodCompiled && (!isTiered || isMethodCompiledAtMaxTier); }
Example #22
Source File: LocalLongTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String... args) throws Exception { if (Platform.is64bit()) { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xint", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED", "LocalLongHelper"); OutputAnalyzer o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); } }
Example #23
Source File: BMIUnsupportedCPUTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void runTestCases() throws Throwable { if (Platform.isX86() || Platform.isX64()) { unsupportedX86CPUTestCases(); } else { unsupportedNonX86CPUTestCases(); } }
Example #24
Source File: CtwTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected void compile(String[] args) throws Exception { // concat CTW_COMMAND and args w/o 0th element String[] cmd = Arrays.copyOf(CTW_COMMAND, CTW_COMMAND.length + args.length - 1); System.arraycopy(args, 1, cmd, CTW_COMMAND.length, args.length - 1); if (Platform.isWindows()) { // '*' has to be escaped on windows for (int i = 0; i < cmd.length; ++i) { cmd[i] = cmd[i].replace("*", "\"*\""); } } ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmd); OutputAnalyzer output = new OutputAnalyzer(pb.start()); dump(output, "compile"); output.shouldHaveExitValue(0); }
Example #25
Source File: LoadAgentDcmdTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Build name of shared object according to platform rules */ public static String sharedObjectName(String name) { if (Platform.isWindows()) { return name + ".dll"; } if (Platform.isOSX()) { return "lib" + name + ".dylib"; } return "lib" + name + ".so"; }
Example #26
Source File: TestHeapDumpForInvokeDynamic.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main (String... args) throws Exception { String heapDumpFileName = "lambdaHeapDump.bin"; if (!Platform.shouldSAAttach()) { System.out.println( "SA attach not expected to work - test skipped."); return; } File heapDumpFile = new File(heapDumpFileName); if (heapDumpFile.exists()) { heapDumpFile.delete(); } try { List<String> vmArgs = new ArrayList<String>(); vmArgs.add("-XX:+UsePerfData"); vmArgs.addAll(Utils.getVmOptions()); theApp = new LingeredAppWithInvokeDynamic(); LingeredApp.startApp(vmArgs, theApp); attachDumpAndVerify(heapDumpFileName, theApp.getPid()); } finally { LingeredApp.stopApp(theApp); } }
Example #27
Source File: LoadAgentDcmdTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * return path to library inside jdk tree */ public static String jdkLibPath() { if (Platform.isWindows()) { return "bin"; } return "lib"; }
Example #28
Source File: TestLargePagesFlags.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String [] args) throws Exception { if (!Platform.isLinux()) { System.out.println("Skipping. TestLargePagesFlags has only been implemented for Linux."); return; } testUseTransparentHugePages(); testUseHugeTLBFS(); testUseSHM(); testCombinations(); }
Example #29
Source File: CreateCoredumpOnCrash.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { runTest("-XX:-CreateCoredumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped"); if (Platform.isWindows()) { // The old CreateMinidumpOnCrash option should still work runTest("-XX:-CreateMinidumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped"); } else { runTest("-XX:+CreateCoredumpOnCrash").shouldNotContain("CreateCoredumpOnCrash turned off, no core file dumped"); } }
Example #30
Source File: TestOnError.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { if (!Platform.isDebugBuild()) { System.out.println("Test requires a non-product build - skipping"); return; } String msg = "Test Succeeded"; // Execute the VM so that a ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=12", // trigger potential SEGV "-XX:OnError=echo " + msg, TestOnError.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); /* Actual output will include: # # -XX:OnError="echo Test Succeeded" # Executing /bin/sh -c "echo Test Succeeded"... Test Succeeded So we don't want to match on the "# Executing ..." line, and they both get written to stdout. */ output.stdoutShouldMatch("^" + msg); // match start of line only System.out.println("PASSED"); }