8215568: Refactor SA clhsdb tests to use ClhsdbLauncher
Summary: Refactoring the SA tests which test clhsdb commands to use ClhsdbLauncher for uniformity and ease of maintainence
Reviewed-by: jcbeyler, dholmes
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java Tue Feb 05 00:43:38 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -171,7 +171,7 @@
"_nofast_getfield",
"_nofast_putfield",
"Constant Pool of",
- "public static void main(java.lang.String[])",
+ "public static void main\\(java.lang.String\\[\\]\\)",
"Bytecode",
"invokevirtual",
"checkcast",
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java Tue Feb 05 00:43:38 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -95,7 +95,7 @@
"_nofast_getfield",
"_nofast_putfield",
"Constant Pool of",
- "public static void main(java.lang.String[])",
+ "public static void main\\(java.lang.String\\[\\]\\)",
"Bytecode",
"invokevirtual",
"checkcast",
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java Tue Feb 05 00:43:38 2019 +0530
@@ -27,7 +27,6 @@
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.Platform;
import jdk.test.lib.Utils;
import jtreg.SkippedException;
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java Tue Feb 05 00:43:38 2019 +0530
@@ -62,7 +62,7 @@
"instance of Oop for java/lang/Class");
tokensMap.put("Method*=", "Type is Method");
tokensMap.put("(a java.lang.ref.ReferenceQueue$Lock)",
- "instance of Oop for java/lang/ref/ReferenceQueue$Lock");
+ "instance of Oop for java/lang/ref/ReferenceQueue\\$Lock");
String[] lines = jstackOutput.split("\\R");
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java Tue Feb 05 00:43:38 2019 +0530
@@ -72,14 +72,15 @@
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put(cmdStr, List.of(
- "public static void main(java.lang.String[])",
+ "public static void main\\(java\\.lang\\.String\\[\\]\\)",
"Holder Class",
"public class jdk.test.lib.apps.LingeredApp @",
+ "public class jdk\\.test\\.lib\\.apps\\.LingeredApp @",
"Bytecode",
"line bci bytecode",
"Exception Table",
"start bci end bci handler bci catch type",
- "Constant Pool of [public class jdk.test.lib.apps.LingeredApp @"));
+ "Constant Pool of \\[public class jdk\\.test\\.lib\\.apps\\.LingeredApp @"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException e) {
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java Tue Feb 05 00:43:38 2019 +0530
@@ -26,7 +26,6 @@
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
@@ -57,11 +56,11 @@
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("jstack -v", List.of(
"No deadlocks found",
- "Common-Cleaner",
+ "Common\\-Cleaner",
"Signal Dispatcher",
- "java.lang.ref.Finalizer$FinalizerThread.run",
+ "java.lang.ref.Finalizer\\$FinalizerThread.run",
"java.lang.ref.Reference",
- "Method*",
+ "Method\\*",
"LingeredApp.main"));
test.run(theApp.getPid(), cmds, expStrMap, null);
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbLauncher.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbLauncher.java Tue Feb 05 00:43:38 2019 +0530
@@ -145,7 +145,7 @@
List<String> expectedStr = expectedStrMap.get(cmd);
if (expectedStr != null) {
for (String exp : expectedStr) {
- out.shouldContain(exp);
+ out.shouldMatch(exp);
}
}
}
@@ -154,7 +154,7 @@
List<String> unExpectedStr = unExpectedStrMap.get(cmd);
if (unExpectedStr != null) {
for (String unExp : unExpectedStr) {
- out.shouldNotContain(unExp);
+ out.shouldNotMatch(unExp);
}
}
}
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java Tue Feb 05 00:43:38 2019 +0530
@@ -26,7 +26,6 @@
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java Tue Feb 05 00:43:38 2019 +0530
@@ -56,11 +56,11 @@
expStrMap.put("printall", List.of(
"aload_0",
"Constant Pool of",
- "public static void main(java.lang.String[])",
+ "public static void main\\(java.lang.String\\[\\]\\)",
"Bytecode",
- "[enum] class Song [signature Ljava/lang/Enum<LSong;>;]",
- "Method java.lang.Object clone()",
- "public static Song[] values()",
+ "\\[enum\\] class Song \\[signature Ljava/lang/Enum\\<LSong;\\>;\\]",
+ "Method java.lang.Object clone\\(\\)",
+ "public static Song\\[\\] values\\(\\)",
"invokevirtual",
"checkcast",
"Field Song HAVANA",
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java Tue Feb 05 00:43:38 2019 +0530
@@ -26,7 +26,6 @@
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
@@ -71,7 +70,7 @@
expStrMap.put("printstatics Threads", List.of(
"Static fields of Threads",
"_number_of_threads", "_number_of_non_daemon_threads",
- "JavaThread* Threads"));
+ "JavaThread\\* Threads"));
expStrMap.put("printstatics Universe", List.of(
"Static fields of Universe",
"uintptr_t Universe::_verify_oop_mask",
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java Tue Feb 05 00:43:38 2019 +0530
@@ -26,7 +26,6 @@
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java Tue Feb 05 00:43:38 2019 +0530
@@ -79,7 +79,7 @@
// words[0] and words[1] represent the start and end addresses
String cmd = "scanoops " + words[0] + " " + words[1];
expStrMap = new HashMap<>();
- expStrMap.put(cmd, List.of("[Ljava/lang/String"));
+ expStrMap.put(cmd, List.of("\\[Ljava/lang/String"));
test.run(theApp.getPid(), List.of(cmd), expStrMap, null);
} catch (SkippedException e) {
throw e;
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java Tue Feb 05 00:43:38 2019 +0530
@@ -80,7 +80,7 @@
expStrMap.put(cmd, List.of
("java/lang/Object", "java/lang/Class", "java/lang/Thread",
- "java/lang/String", "[B", "[I"));
+ "java/lang/String", "\\[B", "\\[I"));
// Test the 'type' option also
// scanoops <start addr> <end addr> java/lang/String
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java Tue Feb 05 00:43:38 2019 +0530
@@ -58,16 +58,16 @@
Map<String, List<String>> expStrMap = new HashMap<>();
expStrMap.put("source clhsdb_cmd_file", List.of(
"No deadlocks found",
- "Common-Cleaner",
+ "Common\\-Cleaner",
"Signal Dispatcher",
- "java.lang.ref.Finalizer$FinalizerThread.run",
+ "java.lang.ref.Finalizer\\$FinalizerThread.run",
"java.lang.ref.Reference",
- "Method*",
+ "Method\\*",
"LingeredApp.main",
"Available commands:",
- "attach pid | exec core",
- "intConstant [ name [ value ] ]",
- "type [ type [ name super isOop isInteger isUnsigned size ] ]"));
+ "attach pid \\| exec core",
+ "intConstant \\[ name \\[ value \\] \\]",
+ "type \\[ type \\[ name super isOop isInteger isUnsigned size \\] \\]"));
Map<String, List<String>> unExpStrMap = new HashMap<>();
unExpStrMap.put("source clhsdb_cmd_file", List.of(
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java Tue Feb 05 00:43:38 2019 +0530
@@ -51,7 +51,7 @@
Map<String, List<String>> expStrMap = new HashMap<>();
// Check for the presence of the usage string
- expStrMap.put("thread", List.of( "Usage: thread { -a | id }"));
+ expStrMap.put("thread", List.of( "Usage: thread \\{ \\-a \\| id \\}"));
expStrMap.put("thread -a", List.of(
"State: BLOCKED",
"Stack in use by Java",
@@ -69,7 +69,7 @@
Map<String, List<String>> unExpStrMap = new HashMap<>();
unExpStrMap.put(
"thread -a",
- List.of("Couldn't find thread -a"));
+ List.of("Couldn't find thread \\-a"));
String consolidatedOutput = test.run(
theApp.getPid(),
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java Tue Feb 05 00:43:38 2019 +0530
@@ -26,7 +26,6 @@
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
--- a/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java Tue Feb 05 00:43:38 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,19 +22,12 @@
*/
import java.util.ArrayList;
-import java.util.Scanner;
import java.util.List;
-import java.io.File;
-import java.io.IOException;
-import java.util.stream.Collectors;
-import java.io.OutputStream;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.JDKToolLauncher;
-import jdk.test.lib.Platform;
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Utils;
-import jdk.test.lib.Asserts;
+import java.util.Map;
+import java.util.HashMap;
+import jtreg.SkippedException;
/**
* @test
@@ -45,117 +38,39 @@
public class TestClhsdbJstackLock {
- private static final String JSTACK_OUT_FILE = "jstack_out.txt";
-
- private static void verifyJStackOutput() throws Exception {
-
- Exception unexpected = null;
- File jstackFile = new File(JSTACK_OUT_FILE);
- Asserts.assertTrue(jstackFile.exists() && jstackFile.isFile(),
- "File with jstack output not created: " +
- jstackFile.getAbsolutePath());
+ public static void main (String... args) throws Exception {
+ System.out.println("Starting TestClhsdbJstackLock test");
+ LingeredAppWithLock app = null;
try {
- Scanner scanner = new Scanner(jstackFile);
-
- boolean classLockOwnerFound = false;
- boolean classLockWaiterFound = false;
- boolean objectLockOwnerFound = false;
- boolean primitiveLockOwnerFound = false;
-
- while (scanner.hasNextLine()) {
- String line = scanner.nextLine();
- System.out.println(line);
-
- if (line.contains("missing reason for ")) {
- unexpected = new RuntimeException("Unexpected msg: missing reason for ");
- break;
- }
- if (line.matches("^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Class for LingeredAppWithLock\\)$")) {
- classLockOwnerFound = true;
- }
- if (line.matches("^\\s+- waiting to lock <0x[0-9a-f]+> \\(a java\\.lang\\.Class for LingeredAppWithLock\\)$")) {
- classLockWaiterFound = true;
- }
- if (line.matches("^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Thread\\)$")) {
- objectLockOwnerFound = true;
- }
- if (line.matches("^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Class for int\\)$")) {
- primitiveLockOwnerFound = true;
- }
- }
-
- if (!classLockOwnerFound || !classLockWaiterFound ||
- !objectLockOwnerFound || !primitiveLockOwnerFound) {
- unexpected = new RuntimeException(
- "classLockOwnerFound = " + classLockOwnerFound +
- ", classLockWaiterFound = " + classLockWaiterFound +
- ", objectLockOwnerFound = " + objectLockOwnerFound +
- ", primitiveLockOwnerFound = " + primitiveLockOwnerFound);
- }
- if (unexpected != null) {
- throw unexpected;
- }
- } catch (Exception ex) {
- throw new RuntimeException("Test ERROR " + ex, ex);
- } finally {
- jstackFile.delete();
- }
- }
-
- private static void startClhsdbForLock(long lingeredAppPid) throws Exception {
-
- Process p;
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
- launcher.addToolArg("clhsdb");
- launcher.addToolArg("--pid");
- launcher.addToolArg(Long.toString(lingeredAppPid));
-
- ProcessBuilder pb = new ProcessBuilder();
- pb.command(launcher.getCommand());
- System.out.println(pb.command().stream().collect(Collectors.joining(" ")));
-
- try {
- p = pb.start();
- } catch (Exception attachE) {
- throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
- }
-
- // Issue the 'jstack' input at the clhsdb prompt.
- OutputStream input = p.getOutputStream();
- String str = "jstack > " + JSTACK_OUT_FILE + "\nquit\n";
- try {
- input.write(str.getBytes());
- input.flush();
- } catch (IOException ioe) {
- throw new Error("Problem issuing the jstack command: " + str, ioe);
- }
-
- OutputAnalyzer output = new OutputAnalyzer(p);
-
- try {
- p.waitFor();
- } catch (InterruptedException ie) {
- p.destroyForcibly();
- throw new Error("Problem awaiting the child process: " + ie, ie);
- }
-
- output.shouldHaveExitValue(0);
- }
-
- public static void main (String... args) throws Exception {
-
- LingeredApp app = null;
-
- try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
app = new LingeredAppWithLock();
LingeredApp.startApp(vmArgs, app);
- System.out.println ("Started LingeredApp with pid " + app.getPid());
- startClhsdbForLock(app.getPid());
- verifyJStackOutput();
+
+ System.out.println ("Started LingeredAppWithLock with pid " + app.getPid());
+
+ List<String> cmds = List.of("jstack");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ Map<String, List<String>> unExpStrMap = new HashMap<>();
+ expStrMap.put("jstack", List.of(
+ "^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Class for LingeredAppWithLock\\)$",
+ "^\\s+- waiting to lock <0x[0-9a-f]+> \\(a java\\.lang\\.Class for LingeredAppWithLock\\)$",
+ "^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Thread\\)$",
+ "^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Class for int\\)$"));
+ unExpStrMap.put("jstack", List.of(
+ "missing reason for "));
+ test.run(app.getPid(), cmds, expStrMap, unExpStrMap);
+ } catch (SkippedException se) {
+ throw se;
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(app);
}
+
+ System.out.println("Test PASSED");
}
}
+
--- a/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java Tue Feb 05 00:43:38 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,11 @@
import java.util.ArrayList;
import java.util.List;
-import java.io.IOException;
-import java.util.stream.Collectors;
-import java.io.OutputStream;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.JDKToolLauncher;
-import jdk.test.lib.Platform;
-import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Utils;
+import java.util.Map;
+import java.util.HashMap;
+import jtreg.SkippedException;
/**
* @test
@@ -44,96 +41,45 @@
public class TestIntConstant {
- private static void testClhsdbForIntConstant(
- long lingeredAppPid,
- String commandString,
- String[] expectedOutputStrings) throws Exception {
-
- Process p;
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
- launcher.addToolArg("clhsdb");
- launcher.addToolArg("--pid");
- launcher.addToolArg(Long.toString(lingeredAppPid));
-
- ProcessBuilder pb = new ProcessBuilder();
- pb.command(launcher.getCommand());
- pb.redirectError(ProcessBuilder.Redirect.INHERIT);
- System.out.println(
- pb.command().stream().collect(Collectors.joining(" ")));
-
- try {
- p = pb.start();
- } catch (Exception attachE) {
- throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
- }
-
- // Issue the 'intConstant' inputs at the clhsdb prompt.
- OutputStream input = p.getOutputStream();
+ public static void main (String... args) throws Exception {
+ System.out.println("Starting TestIntConstant test");
+ LingeredApp app = null;
try {
- input.write((commandString + "\n").getBytes());
- input.write("quit\n".getBytes());
- input.flush();
- } catch (IOException ioe) {
- throw new Error("Problem issuing the intConstant command: " +
- commandString + ioe);
- }
-
- OutputAnalyzer output = new OutputAnalyzer(p);
-
- System.out.println("Awaiting process completion");
- try {
- p.waitFor();
- } catch (InterruptedException ie) {
- p.destroyForcibly();
- throw new Error("Problem awaiting the child process: " + ie);
- }
-
- output.shouldHaveExitValue(0);
- System.out.println(output.getOutput());
- for (String expectedOutputString: expectedOutputStrings) {
- output.shouldContain(expectedOutputString);
- }
- }
-
- public static void testIntConstant() throws Exception {
- LingeredApp app = null;
-
- try {
- List<String> vmArgs = new ArrayList<String>();
- vmArgs.addAll(Utils.getVmOptions());
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
app = LingeredApp.startApp(vmArgs);
+
System.out.println ("Started LingeredApp with pid " + app.getPid());
+ List<String> cmds = List.of("intConstant",
+ "intConstant _temp_constant 45",
+ "intConstant _temp_constant");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+
// Strings to check for in the output of 'intConstant'. The
// 'intConstant' command prints out entries from the
// 'gHotSpotVMIntConstants', which is a table of integer constants,
// with names and the values derived from enums and #define preprocessor
// macros in hotspot.
- String[] defaultOutputStrings =
- {"CollectedHeap::G1 4",
+ expStrMap.put("intConstant", List.of(
+ "CollectedHeap::G1 4",
"RUNNABLE 2",
"Deoptimization::Reason_class_check 4",
"InstanceKlass::_misc_is_unsafe_anonymous 32",
"Generation::ParNew 1",
- "_thread_uninitialized 0"};
- String[] tempConstantString = {"intConstant _temp_constant 45"};
- testClhsdbForIntConstant(app.getPid(), "intConstant", defaultOutputStrings);
- testClhsdbForIntConstant(
- app.getPid(),
- "intConstant _temp_constant 45\nintConstant _temp_constant",
- tempConstantString);
- } finally {
- LingeredApp.stopApp(app);
- }
- }
-
- public static void main (String... args) throws Exception {
-
- try {
- testIntConstant();
- } catch (Exception e) {
- throw new Error("Test failed with " + e);
+ "_thread_uninitialized 0"));
+ expStrMap.put("intConstant _temp_constant", List.of(
+ "intConstant _temp_constant 45"));
+ test.run(app.getPid(), cmds, expStrMap, null);
+ } catch (SkippedException se) {
+ throw se;
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
+ } finally {
+ LingeredApp.stopApp(app);
}
+ System.out.println("Test PASSED");
}
}
--- a/test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java Tue Feb 05 00:43:38 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,19 +22,12 @@
*/
import java.util.ArrayList;
-import java.util.Scanner;
import java.util.List;
-import java.io.File;
-import java.io.IOException;
-import java.util.stream.Collectors;
-import java.io.OutputStream;
+import java.util.Map;
+import java.util.HashMap;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.JDKToolLauncher;
-import jdk.test.lib.Platform;
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Utils;
-import jdk.test.lib.Asserts;
+import jtreg.SkippedException;
/**
* @test
@@ -47,119 +40,40 @@
public class TestPrintMdo {
- private static final String PRINTMDO_OUT_FILE = "printmdo_out.txt";
-
- private static void verifyPrintMdoOutput() throws Exception {
-
- Exception unexpected = null;
- File printMdoFile = new File(PRINTMDO_OUT_FILE);
- Asserts.assertTrue(printMdoFile.exists() && printMdoFile.isFile(),
- "File with printmdo output not created: " +
- printMdoFile.getAbsolutePath());
- try {
- Scanner scanner = new Scanner(printMdoFile);
-
- String unexpectedMsg =
- "One or more of 'VirtualCallData', 'CounterData', " +
- "'ReceiverTypeData', 'bci', 'MethodData' " +
- "or 'java/lang/Object' not found";
- boolean knownClassFound = false;
- boolean knownProfileDataTypeFound = false;
- boolean knownTokensFound = false;
-
- while (scanner.hasNextLine()) {
- String line = scanner.nextLine();
- line = line.trim();
- System.out.println(line);
-
- if (line.contains("missing reason for ")) {
- unexpected = new RuntimeException("Unexpected msg: missing reason for ");
- break;
- }
- if (line.contains("VirtualCallData") ||
- line.contains("CounterData") ||
- line.contains("ReceiverTypeData")) {
- knownProfileDataTypeFound = true;
- }
- if (line.contains("bci") ||
- line.contains("MethodData")) {
- knownTokensFound = true;
- }
- if (line.contains("java/lang/Object")) {
- knownClassFound = true;
- }
- }
- if ((knownClassFound == false) ||
- (knownTokensFound == false) ||
- (knownProfileDataTypeFound == false)) {
- unexpected = new RuntimeException(unexpectedMsg);
- }
- if (unexpected != null) {
- throw unexpected;
- }
- } catch (Exception ex) {
- throw new RuntimeException("Test ERROR " + ex, ex);
- } finally {
- printMdoFile.delete();
- }
- }
-
- private static void startClhsdbForPrintMdo(long lingeredAppPid) throws Exception {
-
- Process p;
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
- launcher.addToolArg("clhsdb");
- launcher.addToolArg("--pid");
- launcher.addToolArg(Long.toString(lingeredAppPid));
-
- ProcessBuilder pb = new ProcessBuilder();
- pb.command(launcher.getCommand());
- System.out.println(
- pb.command().stream().collect(Collectors.joining(" ")));
-
- try {
- p = pb.start();
- } catch (Exception attachE) {
- throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
- }
-
- // Issue the 'printmdo' input at the clhsdb prompt.
- OutputStream input = p.getOutputStream();
- String str = "printmdo -a > " + PRINTMDO_OUT_FILE + "\nquit\n";
- try {
- input.write(str.getBytes());
- input.flush();
- } catch (IOException ioe) {
- throw new Error("Problem issuing the printmdo command: " + str, ioe);
- }
-
- OutputAnalyzer output = new OutputAnalyzer(p);
-
- try {
- p.waitFor();
- } catch (InterruptedException ie) {
- p.destroyForcibly();
- throw new Error("Problem awaiting the child process: " + ie, ie);
- }
-
- output.shouldHaveExitValue(0);
- }
-
public static void main (String... args) throws Exception {
+ System.out.println("Starting TestPrintMdo test");
LingeredApp app = null;
-
try {
+ ClhsdbLauncher test = new ClhsdbLauncher();
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();
+ List<String> cmds = List.of("printmdo -a");
+
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ Map<String, List<String>> unExpStrMap = new HashMap<>();
+ expStrMap.put("printmdo -a", List.of(
+ "VirtualCallData",
+ "CounterData",
+ "ReceiverTypeData",
+ "bci",
+ "MethodData",
+ "java/lang/Object"));
+ unExpStrMap.put("printmdo -a", List.of(
+ "missing reason for "));
+ test.run(app.getPid(), cmds, expStrMap, unExpStrMap);
+ } catch (SkippedException se) {
+ throw se;
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(app);
}
+
+ System.out.println("Test PASSED");
}
}
--- a/test/hotspot/jtreg/serviceability/sa/TestType.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/TestType.java Tue Feb 05 00:43:38 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,11 @@
import java.util.ArrayList;
import java.util.List;
-import java.io.IOException;
-import java.util.stream.Collectors;
-import java.io.OutputStream;
+import java.util.Map;
+import java.util.HashMap;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.JDKToolLauncher;
-import jdk.test.lib.Platform;
-import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Utils;
+import jtreg.SkippedException;
/**
* @test
@@ -44,84 +41,41 @@
public class TestType {
- private static void testClhsdbForType(
- long lingeredAppPid,
- String commandString,
- String[] expectedOutputStrings) throws Exception {
-
- Process p;
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
- launcher.addToolArg("clhsdb");
- launcher.addToolArg("--pid");
- launcher.addToolArg(Long.toString(lingeredAppPid));
+ public static void main (String... args) throws Exception {
- ProcessBuilder pb = new ProcessBuilder();
- pb.command(launcher.getCommand());
- System.out.println(
- pb.command().stream().collect(Collectors.joining(" ")));
-
- try {
- p = pb.start();
- } catch (Exception attachE) {
- throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
- }
-
- // Issue the 'type' commands at the clhsdb prompt.
- OutputStream input = p.getOutputStream();
+ System.out.println("Starting TestType test");
+ LingeredApp app = null;
try {
- input.write((commandString + "\n").getBytes());
- input.write("quit\n".getBytes());
- input.flush();
- } catch (IOException ioe) {
- throw new Error("Problem issuing the 'type' command ", ioe);
- }
-
- OutputAnalyzer output = new OutputAnalyzer(p);
+ ClhsdbLauncher test = new ClhsdbLauncher();
+ List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
- try {
- p.waitFor();
- } catch (InterruptedException ie) {
- p.destroyForcibly();
- throw new Error("Problem awaiting the child process: " + ie);
- }
-
- output.shouldHaveExitValue(0);
- System.out.println(output.getOutput());
+ app = LingeredApp.startApp(vmArgs);
+ System.out.println ("Started LingeredApp with pid " + app.getPid());
+ List<String> cmds = List.of("type", "type InstanceKlass");
- for (String expectedOutputString: expectedOutputStrings) {
- output.shouldContain(expectedOutputString);
- }
- }
-
- public static void main (String... args) throws Exception {
- LingeredApp app = null;
-
- try {
- List<String> vmArgs = new ArrayList<String>();
- vmArgs.addAll(Utils.getVmOptions());
+ Map<String, List<String>> expStrMap = new HashMap<>();
// Strings to check for in the output of 'type'. The 'type'
// command prints out entries from 'gHotSpotVMTypes', which
// is a table containing the hotspot types, their supertypes,
// sizes, etc, which are of interest to the SA.
- String[] defaultOutputStrings =
- {"type G1CollectedHeap CollectedHeap",
- "type ConstantPoolCache MetaspaceObj",
- "type ConstantPool Metadata",
- "type CompilerThread JavaThread",
- "type CardGeneration Generation",
- "type ArrayKlass Klass",
- "type InstanceKlass Klass"};
+ expStrMap.put("type", List.of(
+ "type G1CollectedHeap CollectedHeap",
+ "type ConstantPoolCache MetaspaceObj",
+ "type ConstantPool Metadata",
+ "type CompilerThread JavaThread",
+ "type CardGeneration Generation",
+ "type ArrayKlass Klass",
+ "type InstanceKlass Klass"));
// String to check for in the output of "type InstanceKlass"
- String[] instanceKlassOutputString = {"type InstanceKlass Klass"};
-
- app = LingeredApp.startApp(vmArgs);
- System.out.println ("Started LingeredApp with pid " + app.getPid());
- testClhsdbForType(app.getPid(), "type", defaultOutputStrings);
- testClhsdbForType(app.getPid(),
- "type InstanceKlass",
- instanceKlassOutputString);
+ expStrMap.put("type InstanceKlass", List.of("type InstanceKlass Klass"));
+ test.run(app.getPid(), cmds, expStrMap, null);
+ } catch (SkippedException se) {
+ throw se;
+ } catch (Exception ex) {
+ throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(app);
}
+ System.out.println("Test PASSED");
}
}
--- a/test/hotspot/jtreg/serviceability/sa/TestUniverse.java Mon Feb 04 17:35:38 2019 -0800
+++ b/test/hotspot/jtreg/serviceability/sa/TestUniverse.java Tue Feb 05 00:43:38 2019 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,10 @@
import java.util.ArrayList;
import java.util.List;
-import java.io.IOException;
-import java.util.stream.Collectors;
-import java.io.OutputStream;
+import java.util.Map;
+import java.util.HashMap;
import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.JDKToolLauncher;
-import jdk.test.lib.Platform;
-import jdk.test.lib.process.OutputAnalyzer;
+import jtreg.SkippedException;
/**
* @test
@@ -62,72 +59,40 @@
private static void testClhsdbForUniverse(long lingeredAppPid,
String gc) throws Exception {
- Process p;
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
- launcher.addToolArg("clhsdb");
- launcher.addToolArg("--pid");
- launcher.addToolArg(Long.toString(lingeredAppPid));
-
- ProcessBuilder pb = new ProcessBuilder();
- pb.command(launcher.getCommand());
- System.out.println(
- pb.command().stream().collect(Collectors.joining(" ")));
-
- try {
- p = pb.start();
- } catch (Exception attachE) {
- throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
- }
+ ClhsdbLauncher launcher = new ClhsdbLauncher();
+ List<String> cmds = List.of("universe");
+ Map<String, List<String>> expStrMap = new HashMap<>();
+ List<String> expStrings = new ArrayList<String>();
+ expStrings.add("Heap Parameters");
- // Issue the 'universe' command at the clhsdb prompt.
- OutputStream input = p.getOutputStream();
- try {
- input.write("universe\n".getBytes());
- input.write("quit\n".getBytes());
- input.flush();
- } catch (IOException ioe) {
- throw new Error("Problem issuing the 'universe' command ", ioe);
+ if (gc.contains("UseZGC")) {
+ expStrings.add("ZHeap");
}
-
- OutputAnalyzer output = new OutputAnalyzer(p);
-
- try {
- p.waitFor();
- } catch (InterruptedException ie) {
- p.destroyForcibly();
- throw new Error("Problem awaiting the child process: " + ie, ie);
- }
- if (gc.contains("UseZGC")) {
- output.shouldContain("ZHeap");
- }
-
- output.shouldHaveExitValue(0);
- System.out.println(output.getOutput());
-
- output.shouldContain("Heap Parameters");
if (gc.contains("G1GC")) {
- output.shouldContain("garbage-first heap");
- output.shouldContain("region size");
- output.shouldContain("G1 Young Generation:");
- output.shouldContain("regions =");
+ expStrings.add("garbage-first heap");
+ expStrings.add("region size");
+ expStrings.add("G1 Young Generation:");
+ expStrings.add("regions =");
}
if (gc.contains("UseConcMarkSweepGC")) {
- output.shouldContain("Gen 1: concurrent mark-sweep generation");
+ expStrings.add("Gen 1: concurrent mark-sweep generation");
}
if (gc.contains("UseSerialGC")) {
- output.shouldContain("Gen 1: old");
+ expStrings.add("Gen 1: old");
}
if (gc.contains("UseParallelGC")) {
- output.shouldContain("ParallelScavengeHeap");
- output.shouldContain("PSYoungGen");
- output.shouldContain("eden");
+ expStrings.add("ParallelScavengeHeap");
+ expStrings.add("PSYoungGen");
+ expStrings.add("eden");
}
if (gc.contains("UseEpsilonGC")) {
- output.shouldContain("Epsilon heap");
- output.shouldContain("reserved");
- output.shouldContain("committed");
- output.shouldContain("used");
+ expStrings.add("Epsilon heap");
+ expStrings.add("reserved");
+ expStrings.add("committed");
+ expStrings.add("used");
}
+ expStrMap.put("universe", expStrings);
+ launcher.run(lingeredAppPid, cmds, expStrMap, null);
}
public static void test(String gc) throws Exception {
@@ -145,8 +110,8 @@
}
}
-
public static void main (String... args) throws Exception {
+ System.out.println("Starting TestUniverse test");
try {
test("-XX:+UseG1GC");
test("-XX:+UseParallelGC");
@@ -158,7 +123,11 @@
}
test("-XX:+UseEpsilonGC");
}
+ } catch (SkippedException se) {
+ throw se;
} catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
throw new Error("Test failed with " + e);
}
}