Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8251996: remove usage of PropertyResolvingWrapper in vm/compiler/comp…
…log/uninit

Reviewed-by: kvn, epavlova
  • Loading branch information
iignatev committed Aug 21, 2020
1 parent 256cb2b commit 49e4022c3c17feabe9573c90df735a6290488467
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 62 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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,24 +22,29 @@
*/
package vm.compiler.complog.share;

import java.io.*;
import java.util.*;
import java.util.regex.*;
import java.lang.reflect.*;
import java.lang.management.*;

import nsk.share.TestFailure;
import jdk.test.lib.Utils;
import nsk.share.TestBug;
import nsk.share.log.*;
import vm.share.options.*;
import vm.share.process.*;
import nsk.share.TestFailure;
import nsk.share.log.Log;
import nsk.share.log.LogSupport;
import vm.share.options.Option;
import vm.share.options.OptionSupport;
import vm.share.process.ProcessExecutor;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Test executor for all tests that require compilation log analysis.
* Next options should be passed to LogCompilationTest:
* <b>-testClass</b> test to be executed;
* <b>-testedJava</b> path to testing java binary;
* <b>-options</b> options that should be passed to testing java;
* <b>-parserClass</b> parser that will be used for compilation log analysis;
* <b>-timeout</b> timeout in secoonds.
*/
@@ -61,15 +66,12 @@ public class LogCompilationTest extends OptionSupport implements Runnable {
@Option(name="parserOptions", description="Options that will be passed to compilation log parser.", default_value="")
protected String parserOptions;

@Option(name="options", description="Options for tested java.")
protected String jvmOptions;

protected Log log = new LogSupport(System.out);
protected Log testLog;

public static final String compilationLog = "hotspot.log";

public static void main(String args[]) {
public static void main(String[] args) {
LogCompilationTest.setupAndRun(new LogCompilationTest(), args);
}

@@ -79,48 +81,45 @@ public void run() {
}

private String[] getJVMOptions() {
Matcher matcher = Pattern.compile("(\"[^\"]*\")|([^\\s\"]+(\"[^\"]*\")?)").
matcher(jvmOptions);
List<String> options = new LinkedList<String>();
while(matcher.find()) {
options.add(matcher.group());
}
List<String> options = new ArrayList<>();
Collections.addAll(options, Utils.getTestJavaOpts());
options.add("-XX:+UnlockDiagnosticVMOptions");
options.add("-XX:+LogCompilation");
options.add("-XX:LogFile="+compilationLog);
options.add("-XX:LogFile=" + compilationLog);
return options.toArray(new String[0]);
}

private LogCompilationParser getParser() {
try {
Class parser = Class.forName(parserClass);
Constructor ctor = parser.getConstructor();
return (LogCompilationParser)ctor.newInstance();
Class<?> parser = Class.forName(parserClass);
Constructor<?> ctor = parser.getConstructor();
return (LogCompilationParser) ctor.newInstance();
} catch (Throwable e) {
throw new TestBug("Parser could not be instantiated.",e);
throw new TestBug("Parser could not be instantiated.", e);
}
}

private void execute() {
String options[] = getJVMOptions();
String[] options = getJVMOptions();
ProcessExecutor executor = new ProcessExecutor();
try {
testLog = new LogSupport(new PrintStream(new FileOutputStream("test.log")));
} catch (FileNotFoundException e) {
throw new TestFailure("Can't create test log file.", e);
}
executor.logStdOutErr("Test>>",testLog);

executor.logStdOutErr("Test>>", testLog);
executor.addArg(testedJava);
executor.addArgs(options);
executor.addArg(testClass);
executor.start();
executor.waitFor(timeout*1000);
int exitCode = executor.waitFor(timeout * 1000);

if(executor.getResult()!=0) {
if(new File("hs_err_pid"+executor.getPid()+".log").exists()) {
throw new TestFailure("Test crashed.");
if (exitCode != 0) {
if (new File("hs_err_pid" + executor.getPid() + ".log").exists()) {
throw new TestFailure("Test crashed. Exit code: " + exitCode);
} else {
throw new TestFailure("Test exited with non-zero code.");
throw new TestFailure("Test exited with non-zero code: " + exitCode);
}
}
}

This file was deleted.

@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit001.uninit001
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit001.uninit001
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit002.uninit002
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit002.uninit002
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit003.uninit003
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit003.uninit003
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit004.uninit004
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit004.uninit004
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit005.uninit005
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit005.uninit005
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit006.uninit006
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit006.uninit006
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit007.uninit007
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit007.uninit007
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit008.uninit008
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit008.uninit008
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit009.uninit009
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit009.uninit009
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit010.uninit010
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit010.uninit010
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit011.uninit011
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit011.uninit011
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit012.uninit012
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit012.uninit012
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"
@@ -32,10 +32,9 @@
* @build vm.compiler.complog.share.LogCompilationTest
* vm.compiler.complog.uninit.uninit013.uninit013
* vm.compiler.complog.uninit.UninitializedTrapCounter
* @run main/othervm PropertyResolvingWrapper
* @run main/othervm
* vm.compiler.complog.share.LogCompilationTest
* -testedJava ${test.jdk}/bin/java
* -options "${test.vm.opts} ${test.java.opts}"
* -testClass vm.compiler.complog.uninit.uninit013.uninit013
* -parserClass vm.compiler.complog.uninit.UninitializedTrapCounter
* -parserOptions "-classFilter=.*uninit.*"

0 comments on commit 49e4022

Please sign in to comment.