22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 package jdk.jfr.event.metadata; |
25 package jdk.jfr.event.metadata; |
26 |
26 |
27 import java.io.File; |
|
28 import java.io.IOException; |
27 import java.io.IOException; |
29 import java.lang.reflect.Field; |
28 import java.lang.reflect.Field; |
30 import java.nio.file.Files; |
29 import java.nio.file.Files; |
31 import java.nio.file.Path; |
30 import java.nio.file.Path; |
32 import java.nio.file.Paths; |
31 import java.nio.file.Paths; |
38 import java.util.stream.Stream; |
37 import java.util.stream.Stream; |
39 |
38 |
40 import jdk.jfr.EventType; |
39 import jdk.jfr.EventType; |
41 import jdk.jfr.Experimental; |
40 import jdk.jfr.Experimental; |
42 import jdk.jfr.FlightRecorder; |
41 import jdk.jfr.FlightRecorder; |
|
42 import jdk.test.lib.Utils; |
43 import jdk.test.lib.jfr.EventNames; |
43 import jdk.test.lib.jfr.EventNames; |
44 import jdk.test.lib.Utils; |
|
45 |
44 |
46 /** |
45 /** |
47 * @test Check for JFR events not covered by tests |
46 * @test Check for JFR events not covered by tests |
48 * @key jfr |
47 * @key jfr |
49 * @requires vm.hasJFR |
48 * @requires vm.hasJFR |
53 public class TestLookForUntestedEvents { |
52 public class TestLookForUntestedEvents { |
54 private static final Path jfrTestRoot = Paths.get(Utils.TEST_SRC).getParent().getParent(); |
53 private static final Path jfrTestRoot = Paths.get(Utils.TEST_SRC).getParent().getParent(); |
55 private static final String MSG_SEPARATOR = "=========================="; |
54 private static final String MSG_SEPARATOR = "=========================="; |
56 private static Set<String> jfrEventTypes = new HashSet<>(); |
55 private static Set<String> jfrEventTypes = new HashSet<>(); |
57 |
56 |
58 private static final Set<String> knownEventsMissingFromEventNames = new HashSet<>( |
|
59 Arrays.asList( |
|
60 // The Z* events below should be marked as experimental; see: JDK-8213966 |
|
61 "ZStatisticsSampler", "ZStatisticsCounter", |
|
62 "ZPageAllocation", "ZThreadPhase" |
|
63 ) |
|
64 ); |
|
65 |
|
66 private static final Set<String> hardToTestEvents = new HashSet<>( |
57 private static final Set<String> hardToTestEvents = new HashSet<>( |
67 Arrays.asList( |
58 Arrays.asList( |
68 "DataLoss", "IntFlag", "ReservedStackActivation", |
59 "DataLoss", "IntFlag", "ReservedStackActivation", |
69 "DoubleFlag", "UnsignedLongFlagChanged", "IntFlagChanged", |
60 "DoubleFlag", "UnsignedLongFlagChanged", "IntFlagChanged", |
70 "UnsignedIntFlag", "UnsignedIntFlagChanged", "DoubleFlagChanged") |
61 "UnsignedIntFlag", "UnsignedIntFlagChanged", "DoubleFlagChanged") |
144 String eventName = (String) f.get(null); |
135 String eventName = (String) f.get(null); |
145 eventName = eventName.replace(EventNames.PREFIX, ""); |
136 eventName = eventName.replace(EventNames.PREFIX, ""); |
146 eventsFromEventNamesClass.add(eventName); |
137 eventsFromEventNamesClass.add(eventName); |
147 } |
138 } |
148 } |
139 } |
149 |
|
150 // Account for the events that are known to be missing from the EventNames.java |
|
151 eventsFromEventNamesClass.addAll(knownEventsMissingFromEventNames); |
|
152 |
140 |
153 if (!jfrEventTypes.equals(eventsFromEventNamesClass)) { |
141 if (!jfrEventTypes.equals(eventsFromEventNamesClass)) { |
154 String exceptionMsg = "Events declared in jdk.test.lib.jfr.EventNames differ " + |
142 String exceptionMsg = "Events declared in jdk.test.lib.jfr.EventNames differ " + |
155 "from events returned by FlightRecorder.getEventTypes()"; |
143 "from events returned by FlightRecorder.getEventTypes()"; |
156 print(MSG_SEPARATOR); |
144 print(MSG_SEPARATOR); |