|
1 | 1 | /* |
2 | | - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -40,6 +40,7 @@ public class Automatic { |
40 | 40 | public static final int MINUTES_TO_WAIT = Integer.getInteger("jdk.test.lib.jittester", 3); |
41 | 41 |
|
42 | 42 | private static Pair<IRNode, IRNode> generateIRTree(String name) { |
| 43 | + ProductionLimiter.resetTimer(); |
43 | 44 | SymbolTable.removeAll(); |
44 | 45 | TypeList.removeAll(); |
45 | 46 |
|
@@ -117,34 +118,41 @@ public static void main(String[] args) { |
117 | 118 | List<TestsGenerator> generators = getTestGenerators(); |
118 | 119 | do { |
119 | 120 | double start = System.currentTimeMillis(); |
120 | | - System.out.print("[" + LocalTime.now() + "] |"); |
121 | | - String name = "Test_" + counter; |
122 | | - Pair<IRNode, IRNode> irTree = generateIRTree(name); |
123 | | - System.out.printf(" %8d |", counter); |
124 | | - long maxWaitTime = TimeUnit.MINUTES.toMillis(MINUTES_TO_WAIT); |
125 | | - double generationTime = System.currentTimeMillis() - start; |
126 | | - System.out.printf(" %8.0f |", generationTime); |
127 | | - start = System.currentTimeMillis(); |
128 | | - Thread generatorThread = new Thread(() -> { |
129 | | - for (TestsGenerator generator : generators) { |
| 121 | + try { |
| 122 | + System.out.print("[" + LocalTime.now() + "] |"); |
| 123 | + String name = "Test_" + counter; |
| 124 | + Pair<IRNode, IRNode> irTree = generateIRTree(name); |
| 125 | + System.out.printf(" %8d |", counter); |
| 126 | + long maxWaitTime = TimeUnit.MINUTES.toMillis(MINUTES_TO_WAIT); |
| 127 | + double generationTime = System.currentTimeMillis() - start; |
| 128 | + System.out.printf(" %8.0f |", generationTime); |
| 129 | + start = System.currentTimeMillis(); |
| 130 | + Thread generatorThread = new Thread(() -> { |
| 131 | + for (TestsGenerator generator : generators) { |
130 | 132 | generator.accept(irTree.first, irTree.second); |
| 133 | + } |
| 134 | + }); |
| 135 | + generatorThread.start(); |
| 136 | + try { |
| 137 | + generatorThread.join(maxWaitTime); |
| 138 | + } catch (InterruptedException ie) { |
| 139 | + throw new Error("Test generation interrupted: " + ie, ie); |
131 | 140 | } |
132 | | - }); |
133 | | - generatorThread.start(); |
134 | | - try { |
135 | | - generatorThread.join(maxWaitTime); |
136 | | - } catch (InterruptedException ie) { |
137 | | - throw new Error("Test generation interrupted: " + ie, ie); |
138 | | - } |
139 | | - if (generatorThread.isAlive()) { |
140 | | - // maxTime reached, so, proceed to next test generation |
141 | | - generatorThread.interrupt(); |
142 | | - } else { |
143 | | - double runningTime = System.currentTimeMillis() - start; |
144 | | - System.out.printf(" %8.0f |%n", runningTime); |
145 | | - if (runningTime < maxWaitTime) { |
146 | | - ++counter; |
| 141 | + if (generatorThread.isAlive()) { |
| 142 | + // maxTime reached, so, proceed to next test generation |
| 143 | + generatorThread.interrupt(); |
| 144 | + } else { |
| 145 | + double runningTime = System.currentTimeMillis() - start; |
| 146 | + System.out.printf(" %8.0f |%n", runningTime); |
| 147 | + if (runningTime < maxWaitTime) { |
| 148 | + ++counter; |
| 149 | + } |
147 | 150 | } |
| 151 | + } catch (RuntimeException ignored) { |
| 152 | + // Generation failures happen due to nature of fuzzing test generators, |
| 153 | + // such errors are ignored. |
| 154 | + System.out.println("Test_" + counter + " ignored, generation failed due to " + |
| 155 | + ignored.getMessage()); |
148 | 156 | } |
149 | 157 | } while (counter < ProductionParams.numberOfTests.value()); |
150 | 158 | } |
|
0 commit comments