Skip to content

Commit 972f1f3

Browse files
authored
Merge pull request #2160 from ControlSystemStudio/ipv6_test
Option to `ignore_local_ipv6`
2 parents 7075906 + d84aecf commit 972f1f3

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

core/pva/src/test/java/org/epics/pva/common/NetworkTest.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2021 Oak Ridge National Laboratory.
2+
* Copyright (c) 2021-2022 Oak Ridge National Laboratory.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -26,6 +26,10 @@
2626
@SuppressWarnings("nls")
2727
public class NetworkTest
2828
{
29+
// If running on a host that does not support IPv6,
30+
// ignore the checks that require a local "::1" IPv6 address
31+
private static boolean ignore_local_ipv6 = Boolean.parseBoolean(System.getProperty("ignore_local_ipv6"));
32+
2933
@Test
3034
public void testBroadcastAddresses() throws Exception
3135
{
@@ -112,7 +116,8 @@ public void testIPv6() throws Exception
112116
.map(iface -> iface.getHostAddress())
113117
.collect(Collectors.joining(", "));
114118
System.out.println("Interface addresses: " + iface_addr);
115-
assertTrue(iface_addr.contains("0:0:0:0:0:0:0:1"));
119+
if (! ignore_local_ipv6)
120+
assertTrue(iface_addr.contains("0:0:0:0:0:0:0:1"));
116121
assertFalse(addr.isBroadcast());
117122
}
118123
}
@@ -125,17 +130,22 @@ public void testAddressList() throws Exception
125130
final List<AddressInfo> infos = Network.parseAddresses(spec, PVASettings.EPICS_PVA_BROADCAST_PORT);
126131
for (AddressInfo info : infos)
127132
System.out.println(info);
128-
assertEquals(4, infos.size());
133+
if (! ignore_local_ipv6)
134+
assertEquals(4, infos.size());
129135

130136
assertTrue(infos.get(0).getAddress().getAddress() instanceof Inet4Address);
131137
assertTrue(infos.get(1).getAddress().getAddress() instanceof Inet6Address);
132138
assertTrue(infos.get(2).getAddress().getAddress() instanceof Inet4Address);
133-
assertTrue(infos.get(3).getAddress().getAddress() instanceof Inet6Address);
134139

135140
assertTrue(((Inet4Address)infos.get(2).getAddress().getAddress()).isMulticastAddress());
136-
assertTrue(((Inet6Address)infos.get(3).getAddress().getAddress()).isMulticastAddress());
137141

138142
assertTrue(infos.get(2).getInterface() != null);
139-
assertTrue(infos.get(3).getInterface() != null);
143+
144+
if (! ignore_local_ipv6)
145+
{
146+
assertTrue(infos.get(3).getAddress().getAddress() instanceof Inet6Address);
147+
assertTrue(((Inet6Address)infos.get(3).getAddress().getAddress()).isMulticastAddress());
148+
assertTrue(infos.get(3).getInterface() != null);
149+
}
140150
}
141151
}

0 commit comments

Comments
 (0)