Skip to content

Commit c57111b

Browse files
committed
malva: Fix NetworkInterface#isLoopback test
Signed-off-by: Pekka Enberg <penberg@kernel.org>
1 parent d1675b7 commit c57111b

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ CLASSES += src/malva/java/lang/StringTest.class
2424
CLASSES += src/malva/java/lang/RuntimeTest.class
2525
CLASSES += src/malva/java/lang/SystemTest.class
2626
CLASSES += src/malva/java/lang/ThrowableTest.class
27+
CLASSES += src/malva/java/net/InetAddressTest.class
2728
CLASSES += src/malva/java/net/NetworkInterfaceTest.class
2829

2930
SRC := $(patsubst %.class,%.java,$(CLASSES))
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package malva.java.net;
2+
3+
import java.net.InetAddress;
4+
import malva.TestCase;
5+
6+
public class InetAddressTest extends TestCase {
7+
public static void testIsLoopback() throws Exception {
8+
assertTrue (InetAddress.getByName("127.0.0.1").isLoopbackAddress());
9+
assertFalse(InetAddress.getByName("192.168.0.1").isLoopbackAddress());
10+
}
11+
12+
public static void main(String[] args) throws Exception {
13+
testIsLoopback();
14+
}
15+
}

src/malva/java/net/NetworkInterfaceTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,8 @@ public static void testGetMTU() throws Exception {
6868
}
6969

7070
public static void testIsLoopback() throws Exception {
71-
for (NetworkInterface iface : getNetworkInterfaces()) {
72-
if (iface.isLoopback()) {
73-
for (InetAddress addr : getInetAddresses(iface)) {
74-
assertTrue(addr.isLoopbackAddress());
75-
}
76-
}
77-
}
71+
assertTrue (NetworkInterface.getByName("127.0.0.1").isLoopback());
72+
assertFalse(NetworkInterface.getByName("192.168.0.1").isLoopback());
7873
}
7974

8075
public static void testToString() throws Exception {
@@ -116,8 +111,6 @@ public static void main(String[] args) throws Exception {
116111
testGetByName();
117112
testGetByInetAddress();
118113
testGetMTU();
119-
// FIXME: BROKEN
120-
// testIsLoopback();
121114
testToString();
122115
}
123116
}

0 commit comments

Comments
 (0)