< prev index next >

test/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java

Print this page
rev 12859 : 8178835: CTW Runner should check that all classes have been compiled
Reviewed-by: duke

*** 21,40 **** --- 21,43 ---- * questions. */ package sun.hotspot.tools.ctw; + import jdk.test.lib.Asserts; import jdk.test.lib.Utils; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.util.Pair; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; + import java.util.concurrent.Executor; + import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Collectors;
*** 95,105 **** } } private void startCtwforAllClasses() { ! long classStart = 0; boolean done = false; while (!done) { String[] cmd = cmd(classStart); try { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( --- 98,111 ---- } } private void startCtwforAllClasses() { ! long classStart = 0L; ! long classCount = classCount(); ! Asserts.assertGreaterThan(classCount, 0L, ! targetPath + " does not have any classes"); boolean done = false; while (!done) { String[] cmd = cmd(classStart); try { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
*** 121,130 **** --- 127,146 ---- System.out.printf("%s %dms END : exit code = %d%n", phase, TimeUnit.NANOSECONDS.toMillis(System.nanoTime()), exitCode); Pair<String, Long> lastClass = getLastClass(out); if (exitCode == 0) { + long lastIndex = lastClass == null ? -1 : lastClass.second; + if (lastIndex != classCount) { + errors.add(new Error(phase + ": Unexpected zero exit code" + + "before finishing all compilations." + + " lastClass[" + lastIndex + + "] != classCount[" + classCount + "]")); + } else { + System.out.println("Executed CTW for all " + classCount + + " classes in " + targetPath); + } done = true; } else { if (lastClass == null) { errors.add(new Error(phase + ": failed during preload" + " with classStart = " + classStart));
*** 142,151 **** --- 158,172 ---- throw new Error("failed to run from " + classStart, e); } } } + private long classCount() { + return PathHandler.create(targetPath.toString(), Runnable::run) + .classCount(); + } + private Pair<String, Long> getLastClass(Path errFile) { try { String line = Files.newBufferedReader(errFile) .lines() .filter(IS_CLASS_LINE)
*** 164,174 **** return null; } private String[] cmd(long classStart) { String phase = phaseName(classStart); ! return new String[]{ "-Xbatch", "-XX:-UseCounterDecay", "-XX:-ShowMessageBoxOnError", "-XX:+UnlockDiagnosticVMOptions", // define phase start --- 185,195 ---- return null; } private String[] cmd(long classStart) { String phase = phaseName(classStart); ! return new String[] { "-Xbatch", "-XX:-UseCounterDecay", "-XX:-ShowMessageBoxOnError", "-XX:+UnlockDiagnosticVMOptions", // define phase start
< prev index next >