am 6a5ea762: am 2212f189: Merge "Normalize ipv6.cts.PingTest#testLoopbackPing\'s packet size" into lmp-sprout-dev
* commit '6a5ea762de6b16d9f0fe211d58d442eef7610cfb':
Normalize ipv6.cts.PingTest#testLoopbackPing's packet size
diff --git a/tests/tests/net/src/android/net/ipv6/cts/PingTest.java b/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
index e9bfb43..eddb416 100644
--- a/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
+++ b/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
@@ -53,6 +53,9 @@
/** Maximum size of the packets we're using to test. */
private static final int MAX_SIZE = 4096;
+ /** Size of the ICMPv6 header. */
+ private static final int ICMP_HEADER_SIZE = 8;
+
/** Number of packets to test. */
private static final int NUM_PACKETS = 10;
@@ -65,7 +68,7 @@
* Returns a byte array containing an ICMPv6 echo request with the specified payload length.
*/
private byte[] pingPacket(int payloadLength) {
- byte[] packet = new byte[payloadLength + 8];
+ byte[] packet = new byte[payloadLength + ICMP_HEADER_SIZE];
new Random().nextBytes(packet);
System.arraycopy(PING_HEADER, 0, packet, 0, PING_HEADER.length);
return packet;
@@ -155,7 +158,7 @@
assertEquals("localhost/::1", ipv6Loopback.toString());
for (int i = 0; i < NUM_PACKETS; i++) {
- byte[] packet = pingPacket((int) (Math.random() * MAX_SIZE));
+ byte[] packet = pingPacket((int) (Math.random() * (MAX_SIZE - ICMP_HEADER_SIZE)));
FileDescriptor s = createPingSocket();
// Use both recvfrom and read().
sendPing(s, ipv6Loopback, packet);