Merge pull request #22397 from keithc-ca/ddrext · eclipse-openj9/openj9@bea4009
@@ -64,10 +64,10 @@ protected String exec(String ddrExtCmd, String[] arg) {
6464if (SetupConfig.getDDRContxt() != null) {
6565// this means we are running from ddr plugin
6666DDROutputStream mps = SetupConfig.getPrintStream();
67-log.debug("Execute command: !" + ddrExtCmd + argStr);
6867if (ddrExtCmd.startsWith("!") == false) {
6968ddrExtCmd = "!" + ddrExtCmd;
7069 }
70+log.debug("Execute command: " + ddrExtCmd + argStr);
7171currentCommand = "'" + ddrExtCmd + argStr + "'";
7272SetupConfig.getDDRContxt().execute(ddrExtCmd, arg,
7373SetupConfig.getPrintStream());
@@ -89,10 +89,10 @@ protected String exec(String ddrExtCmd, String[] arg) {
8989 }
9090if (app != null) {
9191DDROutputStream mps = SetupConfig.getPrintStream();
92-log.debug("Execute command: !" + ddrExtCmd + argStr);
9392if (ddrExtCmd.startsWith("!") == false) {
9493ddrExtCmd = "!" + ddrExtCmd;
9594 }
95+log.debug("Execute command: " + ddrExtCmd + argStr);
9696currentCommand = "'" + ddrExtCmd + argStr + "'";
9797app.execute(ddrExtCmd, arg);
9898output = mps.getOutBuffer().toString();
@@ -225,20 +225,20 @@ protected boolean validate(String output, String successKeys,
225225 }
226226 }
227227228-/* Performing exhaustive validation using all available structures (subcommands) in the output */
228+/* Performing exhaustive validation using all available structures (subcommands) in the output. */
229229if (goNextStep) {
230-int firstIndex = output.indexOf("!");
230+int firstIndex = output.indexOf('!');
231231String parentCmd = currentCommand;
232232boolean allNextCmdAlreadyCovered = true;
233233if (firstIndex != -1) { // if this output contains any !subcommand
234234ArrayList<String> structuresToRun = new ArrayList<>();
235-output = output.substring(output.indexOf("!") + 1); // chop off
235+output = output.substring(firstIndex + 1); // chop off
236236Scanner scanner = new Scanner(output).useDelimiter("!");
237237String structToRun = null;
238238String structAddress = null;
239239while (scanner.hasNext()) {
240240String nextToken = scanner.next();
241-String tokens[] = nextToken.split(" ");
241+String[] tokens = nextToken.split(" ");
242242if (tokens.length > 1) {
243243structToRun = tokens[0].trim();
244244if (coveredStructures.contains(structToRun) == false) {
@@ -260,7 +260,7 @@ protected boolean validate(String output, String successKeys,
260260 + parentCmd);
261261for (int i = 0; i < structuresToRun.size(); i++) {
262262currentCommand = structuresToRun.get(i);
263-log.info("Runing structure test with : !"
263+log.info("Running structure test with : !"
264264 + currentCommand);
265265String[] tokens = currentCommand.trim().split(" ");
266266String cmd = tokens[0];
@@ -274,9 +274,10 @@ protected boolean validate(String output, String successKeys,
274274continue;
275275 }
276276277-if (nxtOutput.contains("{")
278-&& nxtOutput.contains("}")
279-&& nxtOutput.indexOf("{") < nxtOutput.indexOf("}")) {
277+int opener = nxtOutput.indexOf('{');
278+int closer = nxtOutput.indexOf('}');
279+280+if ((0 <= opener) && (opener < closer)) {
280281String structPropertyPattern = ".*=.* 0x.*|<FAULT>";
281282Pattern pattern = Pattern.compile(structPropertyPattern);
282283Matcher matcher = pattern.matcher(nxtOutput);
@@ -291,7 +292,7 @@ && runCommonFailureTestForSubCmd(nxtOutput)) {
291292 } else {
292293log.info("Can not validate: " + currentCommand
293294 + " output is not a structure");
294-log.debug(nxtOutput);
295+log.error(nxtOutput);
295296 }
296297 }
297298currentCommand = parentCmd;
@@ -309,26 +310,32 @@ && runCommonFailureTestForSubCmd(nxtOutput)) {
309310 * @return
310311 */
311312private static String cleanse(String address) {
312-if (address.contains(Constants.NL)) {
313-address = address.substring(0, address.indexOf(Constants.NL));
314- }
315-316-/* We make sure we are in fact dealing with a hex value string */
313+/* Make sure we are in fact dealing with a hex value string. */
317314if (address.startsWith("0x") == false) {
318315return null;
319316 }
320317321-if (address.contains(",")) {
322-address = address.split(",")[0];
318+int index;
319+320+index = address.indexOf(Constants.NL);
321+if (index >= 0) {
322+address = address.substring(0, index);
323+ }
324+325+index = address.indexOf(',');
326+if (index >= 0) {
327+address = address.substring(0, index);
323328 }
324329325-if (address.contains("\t")) {
326-address = address.split("\t")[0];
330+index = address.indexOf('\t');
331+if (index >= 0) {
332+address = address.substring(0, index);
327333 }
328334329-if (address.endsWith(")") || address.endsWith(">")) {
335+if (address.endsWith(")") || address.endsWith(">") || address.endsWith(":")) {
330336address = address.substring(0, address.length() - 1);
331337 }
338+332339return address;
333340 }
334341