Skip to content
Permalink
Browse files

8241530: com/sun/jdi tests fail due to network issues on OSX 10.15

Reviewed-by: amenkov, sspitsyn
  • Loading branch information
Daniil Titov committed Apr 6, 2020
1 parent 843a862 commit ba26538cefb3e60ef16448345bd944845fd70a82
@@ -604,9 +604,9 @@ java/io/pathNames/GeneralWin32.java 8180264 windows-
com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all
com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all

sun/management/jdp/JdpDefaultsTest.java 8241530 macosx-all
sun/management/jdp/JdpJmxRemoteDynamicPortTest.java 8241530 macosx-all
sun/management/jdp/JdpSpecificAddressTest.java 8241530 macosx-all
sun/management/jdp/JdpDefaultsTest.java 8241865 macosx-all
sun/management/jdp/JdpJmxRemoteDynamicPortTest.java 8241865 macosx-all
sun/management/jdp/JdpSpecificAddressTest.java 8241865 macosx-all

############################################################################

@@ -920,9 +920,6 @@ com/sun/jdi/NashornPopFrameTest.java 8225620 generic-

com/sun/jdi/InvokeHangTest.java 8218463 linux-all

com/sun/jdi/JdwpAttachTest.java 8241530 macosx-all
com/sun/jdi/JdwpListenTest.java 8241530 macosx-all

############################################################################

# jdk_time
@@ -25,18 +25,13 @@
import com.sun.jdi.VirtualMachine;
import com.sun.jdi.connect.Connector;
import com.sun.jdi.connect.ListeningConnector;
import jdk.test.lib.Platform;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Utils;

import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -60,7 +55,7 @@
private static boolean testFailedAttach = false;

public static void main(String[] args) throws Exception {
List<InetAddress> addresses = getAddresses();
List<InetAddress> addresses = Utils.getAddressesWithSymbolicAndNumericScopes();

boolean ipv4EnclosedTested = false;
boolean ipv6EnclosedTested = false;
@@ -148,77 +143,6 @@ private static void attachTest(String listenAddress, String connectAddress, bool
}
}

private static void addAddr(List<InetAddress> list, InetAddress addr) {
log(" - (" + addr.getClass().getSimpleName() + ") " + addr.getHostAddress());
list.add(addr);
}

private static boolean isTeredo(Inet6Address addr) {
// Teredo prefix is 2001::/32 (i.e. first 4 bytes are 2001:0000)
byte[] bytes = addr.getAddress();
return bytes[0] == 0x20 && bytes[1] == 0x01 && bytes[2] == 0x00 && bytes[3] == 0x00;
}

private static List<InetAddress> getAddresses() {
List<InetAddress> result = new LinkedList<>();
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface iface = networkInterfaces.nextElement();
try {
if (iface.isUp()) {
Enumeration<InetAddress> addresses = iface.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress addr = addresses.nextElement();
// Java reports link local addresses with symbolic scope,
// but on Windows java.net.NetworkInterface generates its own scope names
// which are incompatible with native Windows routines.
// So on Windows test only addresses with numeric scope.
// On other platforms test both symbolic and numeric scopes.
if (addr instanceof Inet6Address) {
Inet6Address addr6 = (Inet6Address)addr;
// Teredo clients cause intermittent errors on listen ("bind failed")
// and attach ("no route to host").
// Teredo is supposed to be a temporary measure, but some test machines have it.
if (isTeredo(addr6)) {
continue;
}
NetworkInterface scopeIface = addr6.getScopedInterface();
if (scopeIface != null && scopeIface.getName() != null) {
// On some test machines VPN creates link local addresses
// which we cannot connect to.
// Skip them.
if (scopeIface.isPointToPoint()) {
continue;
}

try {
// the same address with numeric scope
addAddr(result, Inet6Address.getByAddress(null, addr6.getAddress(), addr6.getScopeId()));
} catch (UnknownHostException e) {
// cannot happen!
throw new RuntimeException("Unexpected", e);
}

if (Platform.isWindows()) {
// don't add addresses with symbolic scope
continue;
}
}
}
addAddr(result, addr);
}
}
} catch (SocketException e) {
log("Interface " + iface.getDisplayName() + ": failed to get addresses");
}
}
} catch (SocketException e) {
log("Interface enumeration error: " + e);
}
return result;
}

private static String LISTEN_CONNECTOR = "com.sun.jdi.SocketListen";

private static ListeningConnector getListenConnector() {
@@ -26,19 +26,14 @@
import com.sun.jdi.connect.AttachingConnector;
import com.sun.jdi.connect.Connector;
import com.sun.jdi.connect.IllegalConnectorArgumentsException;
import jdk.test.lib.Platform;
import jdk.test.lib.Utils;
import lib.jdb.Debuggee;

import java.io.IOException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

@@ -58,10 +53,11 @@
private static boolean allowNegativeTesting = false;

public static void main(String[] args) throws Exception {
List<InetAddress> addresses = getAddresses();
List<InetAddress> addresses = Utils.getAddressesWithSymbolicAndNumericScopes();

boolean ipv4EnclosedTested = false;
boolean ipv6EnclosedTested = false;

for (InetAddress listen: addresses) {
for (InetAddress attach: addresses) {
// can connect only from the same address
@@ -114,77 +110,6 @@ private static void listenTest(String listenAddress, String connectAddress, bool
log("PASSED");
}

private static void addAddr(List<InetAddress> list, InetAddress addr) {
log(" - (" + addr.getClass().getSimpleName() + ") " + addr.getHostAddress());
list.add(addr);
}

private static boolean isTeredo(Inet6Address addr) {
// Teredo prefix is 2001::/32 (i.e. first 4 bytes are 2001:0000)
byte[] bytes = addr.getAddress();
return bytes[0] == 0x20 && bytes[1] == 0x01 && bytes[2] == 0x00 && bytes[3] == 0x00;
}

private static List<InetAddress> getAddresses() {
List<InetAddress> result = new LinkedList<>();
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface iface = networkInterfaces.nextElement();
try {
if (iface.isUp()) {
Enumeration<InetAddress> addresses = iface.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress addr = addresses.nextElement();
// Java reports link local addresses with symbolic scope,
// but on Windows java.net.NetworkInterface generates its own scope names
// which are incompatible with native Windows routines.
// So on Windows test only addresses with numeric scope.
// On other platforms test both symbolic and numeric scopes.
if (addr instanceof Inet6Address) {
Inet6Address addr6 = (Inet6Address)addr;
// Teredo clients cause intermittent errors on listen ("bind failed")
// and attach ("no route to host").
// Teredo is supposed to be a temporary measure, but some test machines have it.
if (isTeredo(addr6)) {
continue;
}
NetworkInterface scopeIface = addr6.getScopedInterface();
if (scopeIface != null && scopeIface.getName() != null) {
// On some test machines VPN creates link local addresses
// which we cannot connect to.
// Skip them.
if (scopeIface.isPointToPoint()) {
continue;
}

try {
// the same address with numeric scope
addAddr(result, Inet6Address.getByAddress(null, addr6.getAddress(), addr6.getScopeId()));
} catch (UnknownHostException e) {
// cannot happen!
throw new RuntimeException("Unexpected", e);
}

if (Platform.isWindows()) {
// don't add addresses with symbolic scope
continue;
}
}
}
addAddr(result, addr);
}
}
} catch (SocketException e) {
log("Interface " + iface.getDisplayName() + ": failed to get addresses");
}
}
} catch (SocketException e) {
log("Interface enumeration error: " + e);
}
return result;
}

private static String ATTACH_CONNECTOR = "com.sun.jdi.SocketAttach";
// cache socket attaching connector
private static AttachingConnector attachingConnector;
@@ -26,6 +26,7 @@
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
@@ -45,6 +46,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Random;
@@ -307,6 +309,37 @@ public static InetSocketAddress refusingEndpoint() {
throw new RuntimeException("Unable to find system port that is refusing connections");
}

/**
* Returns local addresses with symbolic and numeric scopes
*/
public static List<InetAddress> getAddressesWithSymbolicAndNumericScopes() {
List<InetAddress> result = new LinkedList<>();
try {
NetworkConfiguration conf = NetworkConfiguration.probe();
conf.ip4Addresses().forEach(result::add);
// Java reports link local addresses with symbolic scope,
// but on Windows java.net.NetworkInterface generates its own scope names
// which are incompatible with native Windows routines.
// So on Windows test only addresses with numeric scope.
// On other platforms test both symbolic and numeric scopes.
conf.ip6Addresses().forEach(addr6 -> {
try {
result.add(Inet6Address.getByAddress(null, addr6.getAddress(), addr6.getScopeId()));
} catch (UnknownHostException e) {
// cannot happen!
throw new RuntimeException("Unexpected", e);
}
if (!Platform.isWindows()) {
result.add(addr6);
}
});
} catch (IOException e) {
// cannot happen!
throw new RuntimeException("Unexpected", e);
}
return result;
}

/**
* Returns the free port on the local host.
*

0 comments on commit ba26538

Please sign in to comment.