Merge changes I33d138ed,I0b7e9597 into main
* changes:
Have ByteBuffer.wrap() use the appropriate subarray
Move APF memory clear into its own function
diff --git a/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt b/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt
index 1a535b4..3b7ff83 100644
--- a/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt
+++ b/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt
@@ -419,14 +419,15 @@
packetReader.expectPingDropped()
}
+ fun clearApfMemory() = installProgram(ByteArray(caps.maximumApfProgramSize))
+
// APF integration is mostly broken before V
@IgnoreUpTo(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
@Test
fun testPrefilledMemorySlotsV4() {
// Test v4 memory slots on both v4 and v6 interpreters.
assumeApfVersionSupportAtLeast(4)
- // Clear the entire memory before starting this test
- installProgram(ByteArray(caps.maximumApfProgramSize))
+ clearApfMemory()
val gen = ApfV4Generator(4)
// If not ICMPv6 Echo Reply -> PASS
@@ -457,8 +458,7 @@
packetReader.expectPingReply()
val readResult = readProgram()
- val buffer = ByteBuffer.wrap(readResult)
- buffer.position(counterRegion)
+ val buffer = ByteBuffer.wrap(readResult, counterRegion, 20 /* length */)
expect.withMessage("PROGRAM_SIZE").that(buffer.getInt()).isEqualTo(program.size)
expect.withMessage("RAM_LEN").that(buffer.getInt()).isEqualTo(caps.maximumApfProgramSize)
expect.withMessage("IPV4_HEADER_SIZE").that(buffer.getInt()).isEqualTo(0)