equal
deleted
inserted
replaced
52 */ |
52 */ |
53 public class JdwpListenTest { |
53 public class JdwpListenTest { |
54 |
54 |
55 private static final boolean IsWindows = System.getProperty("os.name").toLowerCase().contains("windows"); |
55 private static final boolean IsWindows = System.getProperty("os.name").toLowerCase().contains("windows"); |
56 |
56 |
|
57 // Set to true to allow testing of attach from wrong address (expected to fail). |
|
58 // It's off by default as it causes test time increase and test interference (see JDK-8231915). |
|
59 private static boolean allowNegativeTesting = false; |
|
60 |
57 public static void main(String[] args) throws Exception { |
61 public static void main(String[] args) throws Exception { |
58 List<InetAddress> addresses = getAddresses(); |
62 List<InetAddress> addresses = getAddresses(); |
59 |
63 |
60 boolean ipv4EnclosedTested = false; |
64 boolean ipv4EnclosedTested = false; |
61 boolean ipv6EnclosedTested = false; |
65 boolean ipv6EnclosedTested = false; |
85 |
89 |
86 private static void listenTest(String listenAddress, String connectAddress, boolean expectedResult) |
90 private static void listenTest(String listenAddress, String connectAddress, boolean expectedResult) |
87 throws IOException { |
91 throws IOException { |
88 log("\nTest: listen at " + listenAddress + ", attaching from " + connectAddress |
92 log("\nTest: listen at " + listenAddress + ", attaching from " + connectAddress |
89 + ", expected: " + (expectedResult ? "SUCCESS" : "FAILURE")); |
93 + ", expected: " + (expectedResult ? "SUCCESS" : "FAILURE")); |
|
94 if (!expectedResult && !allowNegativeTesting) { |
|
95 log("SKIPPED: negative testing is disabled"); |
|
96 return; |
|
97 } |
|
98 |
90 log("Starting listening debuggee at " + listenAddress); |
99 log("Starting listening debuggee at " + listenAddress); |
91 try (Debuggee debuggee = Debuggee.launcher("HelloWorld").setAddress(listenAddress + ":0").launch()) { |
100 try (Debuggee debuggee = Debuggee.launcher("HelloWorld").setAddress(listenAddress + ":0").launch()) { |
92 log("Debuggee is listening on " + listenAddress + ":" + debuggee.getAddress()); |
101 log("Debuggee is listening on " + listenAddress + ":" + debuggee.getAddress()); |
93 log("Connecting from " + connectAddress + ", expected: " + (expectedResult ? "SUCCESS" : "FAILURE")); |
102 log("Connecting from " + connectAddress + ", expected: " + (expectedResult ? "SUCCESS" : "FAILURE")); |
94 try { |
103 try { |
101 if (expectedResult) { |
110 if (expectedResult) { |
102 throw new RuntimeException("ERROR: failed to attach", ex); |
111 throw new RuntimeException("ERROR: failed to attach", ex); |
103 } |
112 } |
104 } |
113 } |
105 } |
114 } |
|
115 log("PASSED"); |
106 } |
116 } |
107 |
117 |
108 private static void addAddr(List<InetAddress> list, InetAddress addr) { |
118 private static void addAddr(List<InetAddress> list, InetAddress addr) { |
109 log(" - (" + addr.getClass().getSimpleName() + ") " + addr.getHostAddress()); |
119 log(" - (" + addr.getClass().getSimpleName() + ") " + addr.getHostAddress()); |
110 list.add(addr); |
120 list.add(addr); |