author | sballal |
Thu, 16 Nov 2017 09:26:48 +0530 | |
changeset 47899 | f113d1ef7bed |
child 48160 | 599f67f3c6d6 |
permissions | -rw-r--r-- |
47899
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
1 |
/* |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
4 |
* |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
8 |
* |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
13 |
* accompanied this code). |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
14 |
* |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
18 |
* |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
21 |
* questions. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
22 |
*/ |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
23 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
24 |
import java.io.IOException; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
25 |
import java.io.OutputStream; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
26 |
import java.util.List; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
27 |
import java.util.Map; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
28 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
29 |
import jdk.test.lib.apps.LingeredApp; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
30 |
import jdk.test.lib.Platform; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
31 |
import jdk.test.lib.JDKToolLauncher; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
32 |
import jdk.test.lib.process.OutputAnalyzer; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
33 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
34 |
/** |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
35 |
* This is a framework to run 'jhsdb clhsdb' commands. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
36 |
* See open/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java for |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
37 |
* an example of how to write a test. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
38 |
*/ |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
39 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
40 |
public class ClhsdbLauncher { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
41 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
42 |
private Process toolProcess; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
43 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
44 |
public void ClhsdbLauncher() { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
45 |
toolProcess = null; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
46 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
47 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
48 |
/** |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
49 |
* |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
50 |
* Launches 'jhsdb clhsdb' and attaches to the Lingered App process. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
51 |
* @param lingeredAppPid - pid of the Lingered App or one its sub-classes. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
52 |
*/ |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
53 |
private void attach(long lingeredAppPid) |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
54 |
throws IOException { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
55 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
56 |
System.out.println("Starting clhsdb against " + lingeredAppPid); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
57 |
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
58 |
launcher.addToolArg("clhsdb"); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
59 |
launcher.addToolArg("--pid=" + Long.toString(lingeredAppPid)); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
60 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
61 |
ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
62 |
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
63 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
64 |
toolProcess = processBuilder.start(); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
65 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
66 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
67 |
/** |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
68 |
* |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
69 |
* Runs 'jhsdb clhsdb' commands and checks for expected and unexpected strings. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
70 |
* @param commands - clhsdb commands to execute. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
71 |
* @param expectedStrMap - Map of expected strings per command which need to |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
72 |
* be checked in the output of the command. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
73 |
* @param unExpectedStrMap - Map of unexpected strings per command which should |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
74 |
* not be present in the output of the command. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
75 |
* @return Output of the commands as a String. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
76 |
*/ |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
77 |
private String runCmd(List<String> commands, |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
78 |
Map<String, List<String>> expectedStrMap, |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
79 |
Map<String, List<String>> unExpectedStrMap) |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
80 |
throws IOException, InterruptedException { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
81 |
String output; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
82 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
83 |
if (commands == null) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
84 |
throw new RuntimeException("CLHSDB command must be provided\n"); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
85 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
86 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
87 |
try (OutputStream out = toolProcess.getOutputStream()) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
88 |
for (String cmd : commands) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
89 |
out.write((cmd + "\n").getBytes()); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
90 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
91 |
out.write("quit\n".getBytes()); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
92 |
out.flush(); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
93 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
94 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
95 |
OutputAnalyzer oa = new OutputAnalyzer(toolProcess); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
96 |
try { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
97 |
toolProcess.waitFor(); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
98 |
} catch (InterruptedException ie) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
99 |
toolProcess.destroyForcibly(); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
100 |
throw new Error("Problem awaiting the child process: " + ie); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
101 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
102 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
103 |
oa.shouldHaveExitValue(0); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
104 |
output = oa.getOutput(); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
105 |
System.out.println(output); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
106 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
107 |
String[] parts = output.split("hsdb>"); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
108 |
for (String cmd : commands) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
109 |
int index = commands.indexOf(cmd) + 1; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
110 |
OutputAnalyzer out = new OutputAnalyzer(parts[index]); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
111 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
112 |
if (expectedStrMap != null) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
113 |
List<String> expectedStr = expectedStrMap.get(cmd); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
114 |
if (expectedStr != null) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
115 |
for (String exp : expectedStr) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
116 |
out.shouldContain(exp); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
117 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
118 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
119 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
120 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
121 |
if (unExpectedStrMap != null) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
122 |
List<String> unExpectedStr = unExpectedStrMap.get(cmd); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
123 |
if (unExpectedStr != null) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
124 |
for (String unExp : unExpectedStr) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
125 |
out.shouldNotContain(unExp); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
126 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
127 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
128 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
129 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
130 |
return output; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
131 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
132 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
133 |
/** |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
134 |
* |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
135 |
* Launches 'jhsdb clhsdb', attaches to the Lingered App, executes the commands, |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
136 |
* checks for expected and unexpected strings. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
137 |
* @param lingeredAppPid - pid of the Lingered App or one its sub-classes. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
138 |
* @param commands - clhsdb commands to execute. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
139 |
* @param expectedStrMap - Map of expected strings per command which need to |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
140 |
* be checked in the output of the command. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
141 |
* @param unExpectedStrMap - Map of unexpected strings per command which should |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
142 |
* not be present in the output of the command. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
143 |
* @return Output of the commands as a String. |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
144 |
*/ |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
145 |
public String run(long lingeredAppPid, |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
146 |
List<String> commands, |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
147 |
Map<String, List<String>> expectedStrMap, |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
148 |
Map<String, List<String>> unExpectedStrMap) |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
149 |
throws IOException, InterruptedException { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
150 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
151 |
if (!Platform.shouldSAAttach()) { |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
152 |
// Silently skip the test if we don't have enough permissions to attach |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
153 |
System.out.println("SA attach not expected to work - test skipped."); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
154 |
return null; |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
155 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
156 |
|
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
157 |
attach(lingeredAppPid); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
158 |
return runCmd(commands, expectedStrMap, unExpectedStrMap); |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
159 |
} |
f113d1ef7bed
8190198: SA: Framework for writing 'jhsdb clhsdb' commands tests and testcases for some of the commands
sballal
parents:
diff
changeset
|
160 |
} |