8220673: Add test library support for determining platform IP support

Reviewed-by: dfuchs, chegar
This commit is contained in:
Arthur Eubanks 2019-04-16 13:06:23 -07:00 committed by Arthur Eubanks
parent c709e1cbf0
commit 0bb6328356
57 changed files with 461 additions and 75 deletions

@ -23,6 +23,7 @@
/**
* @test
* @library /test/lib
* @modules java.management java.base/java.io:+open java.base/java.net:+open
* @run main/othervm UnreferencedDatagramSockets
* @run main/othervm -Djava.net.preferIPv4Stack=true UnreferencedDatagramSockets
@ -51,6 +52,8 @@ import java.util.concurrent.TimeUnit;
import com.sun.management.UnixOperatingSystemMXBean;
import jdk.test.lib.net.IPSupport;
public class UnreferencedDatagramSockets {
/**
@ -103,6 +106,7 @@ public class UnreferencedDatagramSockets {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
// Create and close a DatagramSocket to warm up the FD count for side effects.
try (DatagramSocket s = new DatagramSocket(0)) {

@ -0,0 +1,40 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8220673
* @library /test/lib
* @build jdk.test.lib.net.IPSupport
* @summary Ensure IPSupport works under a security manager.
* @run main/othervm/policy=MinimumPermissions.policy MinimumPermissions
*/
import jdk.test.lib.net.IPSupport;
public class MinimumPermissions {
public static void main(String[] args) {
IPSupport.skipIfCurrentConfigurationIsInvalid();
}
}

@ -0,0 +1,28 @@
//
// Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License version 2 only, as
// published by the Free Software Foundation.
//
// This code is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// version 2 for more details (a copy is included in the LICENSE file that
// accompanied this code).
//
// You should have received a copy of the GNU General Public License version
// 2 along with this work; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
// or visit www.oracle.com if you need additional information or have any
// questions.
//
grant codeBase "file:${test.classes}/../../../../test/lib/-" {
permission java.net.SocketPermission "localhost:0", "listen,resolve";
permission java.util.PropertyPermission "java.net.preferIPv4Stack", "read";
};

@ -27,6 +27,7 @@
/* @test
* @bug 7163874 8133015
* @library /test/lib
* @summary InetAddress.isReachable is returning false
* for InetAdress 0.0.0.0 and ::0
* @run main PingThis
@ -40,41 +41,26 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import jdk.test.lib.net.IPSupport;
public class PingThis {
private static boolean hasIPv6() throws Exception {
List<NetworkInterface> nics = Collections.list(NetworkInterface
.getNetworkInterfaces());
for (NetworkInterface nic : nics) {
List<InetAddress> addrs = Collections.list(nic.getInetAddresses());
for (InetAddress addr : addrs) {
if (addr instanceof Inet6Address)
return true;
}
}
return false;
}
public static void main(String args[]) throws Exception {
if (System.getProperty("os.name").startsWith("Windows")) {
return;
}
IPSupport.skipIfCurrentConfigurationIsInvalid();
boolean preferIPv4Stack = "true".equals(System
.getProperty("java.net.preferIPv4Stack"));
List<String> addrs = new ArrayList<String>();
InetAddress inetAddress = null;
addrs.add("0.0.0.0");
if (!preferIPv4Stack) {
if (hasIPv6()) {
addrs.add("::0");
}
if (IPSupport.hasIPv4()) {
addrs.add("0.0.0.0");
}
if (IPSupport.hasIPv6()) {
addrs.add("::0");
}
for (String addr : addrs) {
inetAddress = InetAddress.getByName(addr);
InetAddress inetAddress = InetAddress.getByName(addr);
System.out.println("The target ip is "
+ inetAddress.getHostAddress());
boolean isReachable = inetAddress.isReachable(3000);

@ -24,6 +24,7 @@
/**
* @test
* @bug 8016521
* @library /test/lib
* @summary InetAddress should not always re-order addresses returned from name
* service
* @run main/othervm -Djava.net.preferIPv6Addresses=false PreferIPv6AddressesTest
@ -38,6 +39,7 @@ import java.nio.channels.DatagramChannel;
import java.util.Arrays;
import java.util.stream.IntStream;
import static java.lang.System.out;
import jdk.test.lib.net.IPSupport;
public class PreferIPv6AddressesTest {
@ -50,7 +52,6 @@ public class PreferIPv6AddressesTest {
System.getProperty("java.net.preferIPv6Addresses", "false");
public static void main(String args[]) throws IOException {
InetAddress addrs[];
try {
addrs = InetAddress.getAllByName(HOST_NAME);
@ -66,7 +67,7 @@ public class PreferIPv6AddressesTest {
.filter(x -> addrs[x] instanceof Inet6Address)
.findFirst().orElse(-1);
out.println("IPv6 supported: " + IPv6Supported());
out.println("IPv6 supported: " + IPSupport.hasIPv6());
out.println("Addresses: " + Arrays.asList(addrs));
if (preferIPV6Address.equalsIgnoreCase("true") && firstIPv6Address != -1) {
@ -81,10 +82,10 @@ public class PreferIPv6AddressesTest {
assertAllv6Addresses(addrs, off, addrs.length);
assertLoopbackAddress(Inet4Address.class);
assertAnyLocalAddress(Inet4Address.class);
} else if (preferIPV6Address.equalsIgnoreCase("system") && IPv6Supported()) {
} else if (preferIPV6Address.equalsIgnoreCase("system") && IPSupport.hasIPv6()) {
assertLoopbackAddress(Inet6Address.class);
assertAnyLocalAddress(Inet6Address.class);
} else if (preferIPV6Address.equalsIgnoreCase("system") && !IPv6Supported()) {
} else if (preferIPV6Address.equalsIgnoreCase("system") && !IPSupport.hasIPv6()) {
assertLoopbackAddress(Inet4Address.class);
assertAnyLocalAddress(Inet4Address.class);
}
@ -120,13 +121,4 @@ public class PreferIPv6AddressesTest {
throw new RuntimeException("Expected " + expectedType
+ ", got " + anyAddr.getClass());
}
static boolean IPv6Supported() throws IOException {
try {
DatagramChannel.open(StandardProtocolFamily.INET6);
return true;
} catch (UnsupportedOperationException x) {
return false;
}
}
}

@ -24,6 +24,7 @@
/**
* @test
* @bug 4531817 8026245
* @library /test/lib
* @summary Inet[46]Address.localHost need doPrivileged
* @run main/othervm GetLocalHostWithSM
* @run main/othervm -Djava.net.preferIPv4Stack=true GetLocalHostWithSM
@ -38,9 +39,12 @@ import java.security.Principal;
import java.security.PrivilegedExceptionAction;
import java.util.*;
import jdk.test.lib.net.IPSupport;
public class GetLocalHostWithSM {
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
// try setting the local hostname
InetAddress localHost = InetAddress.getLocalHost();

@ -28,6 +28,7 @@ import java.net.MulticastSocket;
import java.net.NetworkInterface;
import jdk.test.lib.NetworkConfiguration;
import jdk.test.lib.net.IPSupport;
/**
* @test
@ -42,6 +43,7 @@ import jdk.test.lib.NetworkConfiguration;
public class JoinLeave {
public static void main(String args[]) throws IOException {
IPSupport.skipIfCurrentConfigurationIsInvalid();
InetAddress ip4Group = InetAddress.getByName("224.80.80.80");
InetAddress ip6Group = InetAddress.getByName("ff02::a");

@ -24,10 +24,12 @@
/*
* @test
* @bug 4742177
* @library /test/lib
* @summary Re-test IPv6 (and specifically MulticastSocket) with latest Linux & USAGI code
*/
import java.util.*;
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class NoLoopbackPackets {
private static String osname;
@ -38,34 +40,12 @@ public class NoLoopbackPackets {
return osname.contains("Windows");
}
private static boolean hasIPv6() throws Exception {
List<NetworkInterface> nics = Collections.list(
NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nic : nics) {
if (!nic.isLoopback()) {
List<InetAddress> addrs = Collections.list(nic.getInetAddresses());
for (InetAddress addr : addrs) {
if (addr instanceof Inet6Address) {
return true;
}
}
}
}
return false;
}
public static void main(String[] args) throws Exception {
if (isWindows()) {
System.out.println("The test only run on non-Windows OS. Bye.");
return;
}
if (!hasIPv6()) {
System.out.println("No IPv6 available. Bye.");
return;
}
MulticastSocket msock = null;
List<SocketAddress> failedGroups = new ArrayList<SocketAddress>();
Sender sender = null;
@ -77,9 +57,16 @@ public class NoLoopbackPackets {
// 224.1.1.1, ::ffff:224.1.1.2, and ff02::1:1
//
List<SocketAddress> groups = new ArrayList<SocketAddress>();
groups.add(new InetSocketAddress(InetAddress.getByName("224.1.1.1"), port));
groups.add(new InetSocketAddress(InetAddress.getByName("::ffff:224.1.1.2"), port));
groups.add(new InetSocketAddress(InetAddress.getByName("ff02::1:1"), port));
if (IPSupport.hasIPv4()) {
groups.add(new InetSocketAddress(InetAddress.getByName("224.1.1.1"), port));
}
if (IPSupport.hasIPv6()) {
groups.add(new InetSocketAddress(InetAddress.getByName("::ffff:224.1.1.2"), port));
groups.add(new InetSocketAddress(InetAddress.getByName("ff02::1:1"), port));
}
if (groups.isEmpty()) {
System.err.println("Nothing to test: there are no network interfaces");
}
sender = new Sender(groups);
new Thread(sender).start();

@ -23,6 +23,7 @@
/* @test
* @bug 8014499
* @library /test/lib
* @summary Test for interference when two sockets are bound to the same
* port but joined to different multicast groups
* @run main Promiscuous
@ -32,6 +33,7 @@
import java.io.IOException;
import static java.lang.System.out;
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class Promiscuous {
@ -113,6 +115,8 @@ public class Promiscuous {
}
public static void main(String args[]) throws IOException {
IPSupport.skipIfCurrentConfigurationIsInvalid();
String os = System.getProperty("os.name");
// Requires IP_MULTICAST_ALL on Linux (new since 2.6.31) so skip

@ -27,6 +27,7 @@ import java.net.MulticastSocket;
import java.net.NetworkInterface;
import jdk.test.lib.NetworkConfiguration;
import jdk.test.lib.net.IPSupport;
/**
* @test
@ -41,6 +42,7 @@ import jdk.test.lib.NetworkConfiguration;
public class SetGetNetworkInterfaceTest {
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
NetworkConfiguration nc = NetworkConfiguration.probe();
try (MulticastSocket ms = new MulticastSocket()) {
nc.multicastInterfaces(true).forEach(nif -> setGetNetworkInterface(ms, nif));

@ -29,6 +29,7 @@ import java.net.MulticastSocket;
import java.net.SocketTimeoutException;
import jdk.test.lib.NetworkConfiguration;
import jdk.test.lib.net.IPSupport;
/**
* @test
@ -158,6 +159,8 @@ public class Test {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
Test t = new Test();
if (args.length == 0) {

@ -23,6 +23,7 @@
/**
* @test
* @library /test/lib
* @modules java.management java.base/java.io:+open java.base/java.net:+open
* @run main/othervm -Djava.net.preferIPv4Stack=true UnreferencedMulticastSockets
* @run main/othervm UnreferencedMulticastSockets
@ -50,6 +51,8 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import jdk.test.lib.net.IPSupport;
import com.sun.management.UnixOperatingSystemMXBean;
public class UnreferencedMulticastSockets {
@ -104,6 +107,7 @@ public class UnreferencedMulticastSockets {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
// Create and close a MulticastSocket to warm up the FD count for side effects.
try (MulticastSocket s = new MulticastSocket(0)) {

@ -24,12 +24,13 @@
/* @test
* @bug 8081678 8131155
* @summary Tests for stream returning methods
* @library /lib/testlibrary/bootlib
* @library /lib/testlibrary/bootlib /test/lib
* @build java.base/java.util.stream.OpTestCase
* @run testng/othervm NetworkInterfaceStreamTest
* @run testng/othervm -Djava.net.preferIPv4Stack=true NetworkInterfaceStreamTest
*/
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import java.net.InetAddress;
@ -43,10 +44,17 @@ import java.util.stream.OpTestCase;
import java.util.stream.Stream;
import java.util.stream.TestData;
import jdk.test.lib.net.IPSupport;
public class NetworkInterfaceStreamTest extends OpTestCase {
private final static boolean IS_WINDOWS = System.getProperty("os.name").startsWith("Windows");
@BeforeTest
void setup() {
IPSupport.skipIfCurrentConfigurationIsInvalid();
}
@Test
public void testNetworkInterfaces() throws SocketException {
Supplier<Stream<NetworkInterface>> ss = () -> {

@ -23,6 +23,7 @@
/* @test
* @bug 4405354 6594296 8058216
* @library /test/lib
* @run main Test
* @run main/othervm -Djava.net.preferIPv4Stack=true Test
* @summary Basic tests for NetworkInterface
@ -30,11 +31,13 @@
import java.net.NetworkInterface;
import java.net.InetAddress;
import java.util.Enumeration;
import jdk.test.lib.net.IPSupport;
public class Test {
static final boolean isWindows = System.getProperty("os.name").startsWith("Windows");
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
Enumeration nifs = NetworkInterface.getNetworkInterfaces();

@ -24,6 +24,7 @@
/*
* @test
* @bug 8067105
* @library /test/lib
* @summary Socket returned by ServerSocket.accept() is inherited by child process on Windows
* @author Chris Hegarty
*/
@ -36,6 +37,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import jdk.test.lib.net.IPSupport;
public class AcceptInheritHandle {
@ -81,7 +83,9 @@ public class AcceptInheritHandle {
static void testJavaNetServerSocket() throws Exception {
test(ServerSocketProducer.JAVA_NET);
test(ServerSocketProducer.JAVA_NET, "-Djava.net.preferIPv4Stack=true");
if (IPSupport.hasIPv4()) {
test(ServerSocketProducer.JAVA_NET, "-Djava.net.preferIPv4Stack=true");
}
}
static void testNioServerSocketChannel() throws Exception {
test(ServerSocketProducer.NIO_CHANNELS);

@ -23,6 +23,7 @@
/**
* @test
* @library /test/lib
* @modules java.management java.base/java.io:+open java.base/java.net:+open
* @run main/othervm UnreferencedSockets
* @run main/othervm -Djava.net.preferIPv4Stack=true UnreferencedSockets
@ -51,6 +52,8 @@ import java.util.concurrent.TimeUnit;
import com.sun.management.UnixOperatingSystemMXBean;
import jdk.test.lib.net.IPSupport;
public class UnreferencedSockets {
/**
@ -107,6 +110,7 @@ public class UnreferencedSockets {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
// Create and close a ServerSocket to warm up the FD count for side effects.
try (ServerSocket s = new ServerSocket(0)) {

@ -24,6 +24,7 @@
/*
* @test
* @bug 4507501
* @library /test/lib
* @summary Test various methods that should throw IAE when passed improper
* SocketAddress
* @run main AddressTest
@ -31,6 +32,7 @@
*/
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class AddressTest {
class MySocketAddress extends SocketAddress {
@ -153,6 +155,7 @@ public class AddressTest {
}
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
new AddressTest();
}
}

@ -24,6 +24,7 @@
/**
* @test
* @bug 6210227
* @library /test/lib
* @summary REGRESSION: Socket.getLocalAddress() returns address of 0.0.0.0 on outbound TCP
* @run main B6210227
* @run main/othervm -Djava.net.preferIPv4Stack=true B6210227
@ -31,10 +32,13 @@
import java.util.*;
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class B6210227 {
public static void main(String[] args) throws Exception
{
IPSupport.skipIfCurrentConfigurationIsInvalid();
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();

@ -24,6 +24,7 @@
/*
* @test
* @bug 4091859 8189366
* @library /test/lib
* @summary Test Socket.available()
* @run main CloseAvailable
* @run main/othervm -Djava.net.preferIPv4Stack=true CloseAvailable
@ -31,11 +32,14 @@
import java.net.*;
import java.io.*;
import jdk.test.lib.net.IPSupport;
public class CloseAvailable {
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
testClose();
testEOF(true);

@ -24,6 +24,7 @@
/*
* @test
* @bug 4176738
* @library /test/lib
* @summary Make sure a deadlock situation
* would not occur
* @run main DeadlockTest
@ -32,9 +33,12 @@
import java.net.*;
import java.io.*;
import jdk.test.lib.net.IPSupport;
public class DeadlockTest {
public static void main(String [] argv) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
ServerSocket ss = new ServerSocket(0);
Socket clientSocket = new Socket();

@ -24,6 +24,7 @@
/*
* @test
* @bug 4106601 8026245 8071424
* @library /test/lib
* @run main/othervm GetLocalAddress
* @run main/othervm -Djava.net.preferIPv4Stack=true GetLocalAddress
* @run main/othervm -Djava.net.preferIPv6Addresses=true GetLocalAddress
@ -32,6 +33,7 @@
*/
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class GetLocalAddress implements Runnable {
static ServerSocket ss;
@ -39,6 +41,8 @@ public class GetLocalAddress implements Runnable {
static int port;
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
testBindNull();
boolean error = true;

@ -24,6 +24,7 @@
/*
* @test
* @bug 6370908 8220663
* @library /test/lib
* @summary Add support for HTTP_CONNECT proxy in Socket class
* @modules java.base/sun.net.www
* @run main HttpProxy
@ -44,6 +45,7 @@ import java.net.Socket;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.List;
import jdk.test.lib.net.IPSupport;
import sun.net.www.MessageHeader;
public class HttpProxy {
@ -52,6 +54,8 @@ public class HttpProxy {
static final int SO_TIMEOUT = 15000;
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
String host;
int port;
ConnectProxyTunnelServer proxy = null;

@ -23,6 +23,7 @@
/* @test
* @bug 6598160
* @library /test/lib
* @summary Windows IPv6 Socket implementation doesn't set the handle to not inherit
* @author Chris Hegarty
* @run main InheritHandle
@ -33,6 +34,7 @@ import java.net.BindException;
import java.net.ServerSocket;
import java.io.File;
import java.io.IOException;
import jdk.test.lib.net.IPSupport;
/**
* This test is only really applicable to Windows machines that are running IPv6, but
@ -45,6 +47,8 @@ public class InheritHandle
"bin" + File.separator + "java";
public static void main(String[] args) {
IPSupport.skipIfCurrentConfigurationIsInvalid();
if (args.length == 1) {
doWait();
} else {

@ -24,6 +24,7 @@
/*
* @test
* @bug 4508149
* @library /test/lib
* @summary Setting ServerSocket.setSoTimeout shouldn't cause
* the timeout to be inherited by accepted connections
* @run main InheritTimeout
@ -32,6 +33,7 @@
import java.net.*;
import java.io.InputStream;
import jdk.test.lib.net.IPSupport;
public class InheritTimeout {
@ -92,6 +94,7 @@ public class InheritTimeout {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
new InheritTimeout();
}
}

@ -24,6 +24,7 @@
/**
* @test
* @bug 4796166
* @library /test/lib
* @summary Linger interval delays usage of released file descriptor
* @run main LingerTest
* @run main/othervm -Djava.net.preferIPv4Stack=true LingerTest
@ -31,6 +32,7 @@
import java.net.*;
import java.io.*;
import jdk.test.lib.net.IPSupport;
public class LingerTest {
@ -105,6 +107,8 @@ public class LingerTest {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
InetAddress loopback = InetAddress.getLoopbackAddress();
ServerSocket ss = new ServerSocket(0, 50, loopback);

@ -24,6 +24,7 @@
/*
* @test
* @bug 4469866
* @library /test/lib
* @summary Connecting to a link-local IPv6 address should not
* causes a SocketException to be thrown.
* @library /test/lib
@ -33,12 +34,13 @@
* @run main/othervm -Djava.net.preferIPv4Stack=true LinkLocal
*/
import jdk.test.lib.NetworkConfiguration;
import java.net.*;
import java.util.List;
import java.util.stream.Collectors;
import jdk.test.lib.NetworkConfiguration;
import jdk.test.lib.net.IPSupport;
public class LinkLocal {
static int testCount = 0;
@ -120,6 +122,7 @@ public class LinkLocal {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
/*
* If an argument is provided ensure that it's

@ -24,12 +24,15 @@
/*
* @test
* @bug 4097826
* @library /test/lib
* @summary SOCKS support inadequate
* @run main/timeout=40/othervm -DsocksProxyHost=nonexistant ProxyCons
* @run main/timeout=40/othervm -DsocksProxyHost=nonexistant -Djava.net.preferIPv4Stack=true ProxyCons
*/
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class ProxyCons {
class Server extends Thread {
ServerSocket server;
@ -77,6 +80,8 @@ public class ProxyCons {
}
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
ProxyCons c = new ProxyCons();
c.test();
}

@ -22,13 +22,16 @@
*/
/*
* @test
* @bug 4468997
* @library /test/lib
* @summary SO_LINGER is ignored on Windows with Winsock 2
* @run main RST
* @run main/othervm -Djava.net.preferIPv4Stack=true RST
*/
import java.net.*;
import java.io.*;
import jdk.test.lib.net.IPSupport;
public class RST implements Runnable {
@ -77,6 +80,8 @@ public class RST implements Runnable {
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
new RST();
}
}

@ -24,6 +24,7 @@
/**
* @test
* @bug 4169831
* @library /test/lib
* @summary test timeout on a socket read
* @run main/timeout=15 ReadTimeout
* @run main/othervm/timeout=15 -Djava.net.preferIPv4Stack=true ReadTimeout
@ -31,9 +32,12 @@
import java.net.*;
import java.io.*;
import jdk.test.lib.net.IPSupport;
public class ReadTimeout {
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
InetAddress sin = null;
Socket soc = null,soc1 = null;
InputStream is = null;

@ -24,6 +24,7 @@
/*
* @test
* @bug 8201510
* @library /test/lib
* @summary Make sure IPv6 addresses are rejected when the System option
* java.net.preferIPv4Stack is set to true
* @run main/othervm -Djava.net.preferIPv4Stack=true RejectIPv6
@ -33,10 +34,13 @@ import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import jdk.test.lib.net.IPSupport;
public class RejectIPv6 {
public static void main(String [] argv) throws Throwable {
IPSupport.skipIfCurrentConfigurationIsInvalid();
ServerSocket serverSocket = new ServerSocket(0);
serverSocket.setSoTimeout(1000);
int serverPort = serverSocket.getLocalPort();

@ -24,17 +24,21 @@
/*
* @test
* @bug 4151834
* @library /test/lib
* @summary Test Socket.setSoLinger
* @run main SetSoLinger
* @run main/othervm -Djava.net.preferIPv4Stack=true SetSoLinger
*/
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class SetSoLinger {
static final int LINGER = 65546;
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
int value;
InetAddress addr = InetAddress.getLocalHost();
ServerSocket ss = new ServerSocket(0);

@ -24,6 +24,7 @@
/*
* @test
* @bug 7014860
* @library /test/lib
* @summary Socket.getInputStream().available() not clear for
* case that connection is shutdown for reading
* @run main ShutdownInput
@ -38,11 +39,14 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import jdk.test.lib.net.IPSupport;
public class ShutdownInput {
static boolean failed = false;
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
InetAddress iaddr = InetAddress.getLocalHost();
try ( ServerSocket ss = new ServerSocket(0);

@ -24,6 +24,7 @@
/*
* @test
* @bug 6223635
* @library /test/lib
* @summary Code hangs at connect call even when Timeout is specified
* @run main SocksConnectTimeout
* @run main/othervm -Djava.net.preferIPv4Stack=true SocksConnectTimeout
@ -39,6 +40,7 @@ import java.io.IOException;
import java.io.Closeable;
import java.util.concurrent.Phaser;
import java.util.concurrent.TimeUnit;
import jdk.test.lib.net.IPSupport;
public class SocksConnectTimeout {
static ServerSocket serverSocket;
@ -48,6 +50,8 @@ public class SocksConnectTimeout {
static int failed, passed;
public static void main(String[] args) {
IPSupport.skipIfCurrentConfigurationIsInvalid();
try {
serverSocket = new ServerSocket(0);

@ -24,6 +24,7 @@
/*
* @test
* @bug 6505016
* @library /test/lib
* @summary Socket spec should clarify what getInetAddress/getPort/etc return
* after the Socket is closed
* @run main TestAfterClose
@ -32,12 +33,15 @@
import java.net.*;
import java.io.*;
import jdk.test.lib.net.IPSupport;
public class TestAfterClose
{
static int failCount;
public static void main(String[] args) {
IPSupport.skipIfCurrentConfigurationIsInvalid();
try {
InetAddress loopback = InetAddress.getLoopbackAddress();
ServerSocket ss = new ServerSocket(0, 0, loopback);

@ -23,6 +23,7 @@
/*
* @test
* @bug 4408755
* @library /test/lib
* @summary This tests whether it's possible to get some informations
* out of a closed socket. This is for backward compatibility
* purposes.
@ -31,10 +32,13 @@
*/
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class TestClose {
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
ServerSocket ss;
Socket s;
InetAddress ad1, ad2;

@ -24,6 +24,7 @@
/**
* @test
* @bug 6404388
* @library /test/lib
* @summary VISTA: Socket setTcpNoDelay & setKeepAlive working incorrectly
* @run main TestTcpNoDelay
* @run main/othervm -Djava.net.preferIPv4Stack=true TestTcpNoDelay
@ -31,10 +32,13 @@
import java.net.*;
import java.io.IOException;
import jdk.test.lib.net.IPSupport;
public class TestTcpNoDelay
{
public static void main(String[] args) {
IPSupport.skipIfCurrentConfigurationIsInvalid();
try {
Socket socket = new Socket();
boolean on = socket.getTcpNoDelay();

@ -24,15 +24,19 @@
/**
* @test
* @bug 4163126
* @library /test/lib
* @summary test to see if timeout hangs
* @run main/timeout=15 Timeout
* @run main/othervm/timeout=15 -Djava.net.preferIPv4Stack=true Timeout
*/
import java.net.*;
import java.io.*;
import jdk.test.lib.net.IPSupport;
public class Timeout {
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
boolean success = false;
ServerSocket sock = new ServerSocket(0);
try {

@ -24,6 +24,7 @@
/*
* @test
* @bug 4511783
* @library /test/lib
* @summary Test that setTrafficClass/getTraffiClass don't
* throw an exception
* @run main TrafficClass
@ -32,6 +33,7 @@
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import jdk.test.lib.net.IPSupport;
public class TrafficClass {
@ -61,6 +63,7 @@ public class TrafficClass {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
DatagramSocket ds = new DatagramSocket();
testDatagramSocket(ds);

@ -24,6 +24,7 @@
/*
* @test
* @bug 4092038
* @library /test/lib
* @summary TCP Urgent data support
* @run main UrgentDataTest
* @run main/othervm -Djava.net.preferIPv4Stack=true UrgentDataTest
@ -31,6 +32,7 @@
import java.net.*;
import java.io.*;
import jdk.test.lib.net.IPSupport;
public class UrgentDataTest {
@ -51,6 +53,8 @@ public class UrgentDataTest {
}
public static void main (String args[]) {
IPSupport.skipIfCurrentConfigurationIsInvalid();
try {
UrgentDataTest test = new UrgentDataTest ();
if (args.length == 0) {

@ -24,11 +24,13 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import jdk.test.lib.net.IPSupport;
import static java.util.concurrent.CompletableFuture.*;
/*
* @test
* @bug 4344135
* @library /test/lib
* @summary Check that {Socket,ServerSocket,DatagramSocket}.close will
* cause any thread blocked on the socket to throw a SocketException.
* @run main AsyncClose
@ -38,6 +40,7 @@ import static java.util.concurrent.CompletableFuture.*;
public class AsyncClose {
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
AsyncCloseTest tests[] = {
new Socket_getInputStream_read(),

@ -24,6 +24,7 @@
/*
* @test
* @bug 4511404
* @library /test/lib
* @summary Check that a broken pipe error doesn't throw an exception
* indicating the socket is closed.
* @run main BrokenPipe
@ -31,6 +32,7 @@
*/
import java.io.*;
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class BrokenPipe {
@ -53,6 +55,8 @@ public class BrokenPipe {
}
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
ServerSocket ss = new ServerSocket(0);
Socket client = new Socket(InetAddress.getLocalHost(),
ss.getLocalPort());

@ -24,6 +24,7 @@
/*
* @test
* @bug 4476378
* @library /test/lib
* @summary Check the specific behaviour of the setReuseAddress(boolean)
* method.
* @run main Basic
@ -36,6 +37,7 @@
* -Djava.net.preferIPv4Stack=true Basic
*/
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class Basic {
@ -226,6 +228,7 @@ public class Basic {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
new Basic();
}

@ -24,6 +24,7 @@
/*
* @test
* @bug 4476378
* @library /test/lib
* @summary Check that SO_REUSEADDR allows a server to restart
* after a crash.
* @run main Restart
@ -36,6 +37,7 @@
* -Djava.net.preferIPv4Stack=true Restart
*/
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class Restart {
@ -47,6 +49,8 @@ public class Restart {
*/
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
ServerSocket ss = new ServerSocket(0);
Socket s1 = null, s2 = null;
try {

@ -24,6 +24,7 @@
/*
* @test
* @bug 4681556
* @library /test/lib
* @summary Wrong text if a read is performed on a socket after it
* has been closed
* @run main SocketClosedException
@ -32,6 +33,7 @@
import java.io.*;
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class SocketClosedException {
static void doServerSide() throws Exception {
@ -61,6 +63,7 @@ public class SocketClosedException {
static Exception serverException = null;
public static void main(String[] args) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
serverSocket = new ServerSocket(0);
startServer();
try {

@ -24,6 +24,7 @@
/**
* @test
* @bug 4158021
* @library /test/lib
* @summary cannot distinguish Thread.interrupt and Socket.setSoTimeout exceptions
* @run main SocketTimeout
* @run main/othervm -Djava.net.preferIPv4Stack=true SocketTimeout
@ -31,11 +32,13 @@
import java.net.*;
import java.io.*;
import jdk.test.lib.net.IPSupport;
public class SocketTimeout {
static final int TIMEOUT = 1000;
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
InetAddress sin = InetAddress.getLocalHost();
Socket soc = null,soc1 = null;
InputStream is = null;

@ -24,6 +24,7 @@
/*
* @test
* @bug 8148609
* @library /test/lib
* @summary Assert that the set of socket options are immutable
* @run testng/othervm ImmutableOptions
* @run testng/othervm -Djava.net.preferIPv4Stack=true ImmutableOptions
@ -34,6 +35,8 @@ import java.io.OutputStream;
import java.net.*;
import java.util.Set;
import jdk.test.lib.net.IPSupport;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@ -41,6 +44,7 @@ public class ImmutableOptions {
@BeforeTest
void setupServerSocketFactory() throws IOException {
IPSupport.skipIfCurrentConfigurationIsInvalid();
ServerSocket.setSocketFactory(new ServerSocketImplFactory());
}

@ -23,6 +23,7 @@
/*
* @test
* @library /test/lib
* @bug 8170920
* @run main MinimumRcvBufferSize
* @run main/othervm -Djava.net.preferIPv4Stack=true MinimumRcvBufferSize
@ -30,10 +31,13 @@
import java.nio.channels.*;
import java.net.*;
import jdk.test.lib.net.IPSupport;
public class MinimumRcvBufferSize {
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
boolean error = false;
ServerSocketChannel channel = ServerSocketChannel.open();
int before = channel.getOption(StandardSocketOptions.SO_RCVBUF);

@ -24,6 +24,7 @@
/*
* @test
* @bug 8036979 8072384 8044773
* @library /test/lib
* @requires !vm.graal.enabled
* @run main/othervm -Xcheck:jni OptionsTest
* @run main/othervm -Xcheck:jni -Djava.net.preferIPv4Stack=true OptionsTest
@ -33,6 +34,7 @@
import java.lang.reflect.Method;
import java.net.*;
import java.util.*;
import jdk.test.lib.net.IPSupport;
public class OptionsTest {
@ -278,6 +280,7 @@ public class OptionsTest {
}
public static void main(String args[]) throws Exception {
IPSupport.skipIfCurrentConfigurationIsInvalid();
doSocketTests();
doServerSocketTests();
doDgSocketTests();

@ -25,10 +25,12 @@ import java.io.IOException;
import java.net.*;
import java.util.Set;
import static java.lang.System.out;
import jdk.test.lib.net.IPSupport;
/*
* @test
* @bug 8143923
* @library /test/lib
* @summary java.net socket supportedOptions set depends on call order
* @run main/othervm SupportedOptionsSet first
* @run main/othervm SupportedOptionsSet second
@ -42,6 +44,8 @@ import static java.lang.System.out;
public class SupportedOptionsSet {
public static void main(String[] args) throws IOException {
IPSupport.skipIfCurrentConfigurationIsInvalid();
if (args[0].equals("first"))
first();
else if (args[0].equals("second"))

@ -27,9 +27,12 @@ import java.net.*;
import java.util.ArrayList;
import java.util.List;
import jdk.test.lib.net.IPSupport;
/*
* @test
* @bug 8143554 8044773
* @library /test/lib
* @summary Test checks that UnsupportedOperationException for unsupported
* SOCKET_OPTIONS is thrown by both getOption() and setOption() methods.
* @requires !vm.graal.enabled
@ -69,6 +72,8 @@ public class UnsupportedOptionsTest {
}
public static void main(String[] args) throws IOException {
IPSupport.skipIfCurrentConfigurationIsInvalid();
Socket s = new Socket();
ServerSocket ss = new ServerSocket();
DatagramSocket ds = new DatagramSocket();

@ -23,6 +23,7 @@
/* @test
* @bug 7161881
* @library /test/lib
* @run main/othervm -Djava.net.preferIPv6Addresses=true BindNull
* @summary Make sure the bind method uses an ipv4 address for the null case
* when the DatagramChannel is connected to an IPv4 socket and
@ -32,19 +33,22 @@
import java.io.*;
import java.net.*;
import java.nio.channels.*;
import jdk.test.lib.net.IPSupport;
public class BindNull {
public static void main(String[] args) throws IOException {
try (DatagramChannel dc = DatagramChannel.open()) {
dc.bind(null);
}
try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET)) {
dc.bind(null);
if (IPSupport.hasIPv4()) {
try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET)) {
dc.bind(null);
}
}
try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET6)) {
dc.bind(null);
} catch (UnsupportedOperationException uoe) {
// IPv6 not available
if (IPSupport.hasIPv6()) {
try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET6)) {
dc.bind(null);
}
}
}
}

@ -23,6 +23,7 @@
/* @test
* @bug 7132924
* @library /test/lib
* @key intermittent
* @summary Test DatagramChannel.disconnect when DatagramChannel is connected to an IPv4 socket
* @run main Disconnect
@ -33,19 +34,32 @@ import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.io.IOException;
import jdk.test.lib.net.IPSupport;
public class Disconnect {
public static void main(String[] args) throws IOException {
IPSupport.skipIfCurrentConfigurationIsInvalid();
// test with default protocol family
try (DatagramChannel dc = DatagramChannel.open()) {
test(dc);
test(dc);
}
// test with IPv4 only
try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET)) {
test(dc);
test(dc);
if (IPSupport.hasIPv4()) {
// test with IPv4 only
try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET)) {
test(dc);
test(dc);
}
}
if (IPSupport.hasIPv6()) {
// test with IPv6 only
try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET6)) {
test(dc);
test(dc);
}
}
}

@ -42,6 +42,7 @@ import java.io.IOException;
import java.util.stream.Collectors;
import jdk.test.lib.NetworkConfiguration;
import jdk.test.lib.net.IPSupport;
public class MulticastSendReceiveTests {
@ -239,6 +240,8 @@ public class MulticastSendReceiveTests {
}
public static void main(String[] args) throws IOException {
IPSupport.skipIfCurrentConfigurationIsInvalid();
NetworkConfiguration config = NetworkConfiguration.probe();
// multicast groups used for the test

@ -43,6 +43,7 @@ import java.io.IOException;
import java.util.stream.Collectors;
import jdk.test.lib.NetworkConfiguration;
import jdk.test.lib.net.IPSupport;
public class Promiscuous {
@ -192,6 +193,8 @@ public class Promiscuous {
}
public static void main(String[] args) throws IOException {
IPSupport.skipIfCurrentConfigurationIsInvalid();
String os = System.getProperty("os.name");
// Requires IP_MULTICAST_ALL on Linux (new since 2.6.31) so skip

@ -22,6 +22,7 @@
*/
/* @test
* @library /test/lib
* @bug 6435300
* @summary Check using IPv6 address does not crash the VM
* @run main/othervm UseDGWithIPv6
@ -35,6 +36,8 @@ import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
import java.nio.channels.UnsupportedAddressTypeException;
import jdk.test.lib.net.IPSupport;
public class UseDGWithIPv6 {
static String[] targets = {
"3ffe:e00:811:b::21:5",
@ -45,6 +48,8 @@ public class UseDGWithIPv6 {
public static void main(String[] args) throws IOException
{
IPSupport.skipIfCurrentConfigurationIsInvalid();
ByteBuffer data = ByteBuffer.wrap("TESTING DATA".getBytes());
DatagramChannel dgChannel = DatagramChannel.open();

@ -23,6 +23,7 @@
/**
* @test
* @library /test/lib
* @requires (os.family == "linux" | os.family == "mac" | os.family == "windows")
* @bug 8209152
* @run main PrintSupportedOptions
@ -33,6 +34,8 @@ import java.io.IOException;
import java.net.SocketOption;
import java.nio.channels.*;
import jdk.test.lib.net.IPSupport;
public class PrintSupportedOptions {
@FunctionalInterface
@ -41,6 +44,8 @@ public class PrintSupportedOptions {
}
public static void main(String[] args) throws IOException {
IPSupport.skipIfCurrentConfigurationIsInvalid();
test(() -> SocketChannel.open());
test(() -> ServerSocketChannel.open());
test(() -> DatagramChannel.open());

@ -0,0 +1,147 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.test.lib.net;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UncheckedIOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.concurrent.Callable;
import jtreg.SkippedException;
/**
* Determines Internet Protocol version support at the TCP socket level.
*/
public class IPSupport {
private static final boolean hasIPv4;
private static final boolean hasIPv6;
private static final boolean preferIPv4Stack;
static {
try {
InetAddress loopbackIPv4 = InetAddress.getByAddress(
new byte[] {0x7F, 0x00, 0x00, 0x01});
InetAddress loopbackIPv6 = InetAddress.getByAddress(
new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01});
hasIPv4 = runPrivilegedAction(() -> hasAddress(loopbackIPv4));
hasIPv6 = runPrivilegedAction(() -> hasAddress(loopbackIPv6));
} catch (UnknownHostException e) {
throw new AssertionError(e);
}
preferIPv4Stack = runPrivilegedAction(() -> Boolean.parseBoolean(
System.getProperty("java.net.preferIPv4Stack")));
if (!preferIPv4Stack && !hasIPv4 && !hasIPv6) {
throw new AssertionError("IPv4 and IPv6 both not available and java.net.preferIPv4Stack is not true");
}
}
private static boolean hasAddress(InetAddress address) {
try (Socket socket = new Socket()) {
socket.bind(new InetSocketAddress(address, 0));
return true;
} catch (SocketException se) {
return false;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
private static <T> T runPrivilegedAction(Callable<T> callable) {
try {
PrivilegedExceptionAction<T> pa = () -> callable.call();
return AccessController.doPrivileged(pa);
} catch (PrivilegedActionException pae) {
throw new UncheckedIOException((IOException) pae.getCause());
}
}
private IPSupport() { }
/**
* Whether or not IPv4 is supported.
*/
public static final boolean hasIPv4() {
return hasIPv4;
}
/**
* Whether or not IPv6 is supported.
*/
public static final boolean hasIPv6() {
return hasIPv6;
}
/**
* Whether or not the "java.net.preferIPv4Stack" system property is set.
*/
public static final boolean preferIPv4Stack() {
return preferIPv4Stack;
}
/**
* Whether or not the current networking configuration is valid or not.
*
* If preferIPv4Stack is true but there is no IPv4 support, the configuration is invalid.
*/
public static final boolean currentConfigurationIsValid() {
return hasIPv4() || hasIPv6();
}
/**
* Throws a jtreg.SkippedException if the current networking configuration is invalid.
*/
public static void skipIfCurrentConfigurationIsInvalid() throws SkippedException {
if (!currentConfigurationIsValid()) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
ps.println("Invalid networking configuration");
printPlatformSupport(ps);
throw new SkippedException(os.toString());
}
}
/**
* Prints the platform supported configurations.
*/
public static void printPlatformSupport(PrintStream out) {
out.println("IPSupport - IPv4: " + hasIPv4());
out.println("IPSupport - IPv6: " + hasIPv6());
out.println("preferIPv4Stack: " + preferIPv4Stack());
}
}