From 9ed841724c879e6a4396dbc9f970f9aa6b5f3015 Mon Sep 17 00:00:00 2001 From: Yuyang Huang Date: Thu, 13 Feb 2025 11:23:35 +0900 Subject: [PATCH] Add edge case test for invalid program length in apf_run(). This commit updates the testPrefilledMemorySlotsV4() test to include an edge case where an invalid program length is passed to apf_run() due to a firmware program update. Bug: 395545572 Test: TH Change-Id: I678615139ab6b115cd851ffa8336459988c50ef6 --- tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt b/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt index ee2e7db8df..65b35dc265 100644 --- a/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt +++ b/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt @@ -591,6 +591,13 @@ class ApfIntegrationTest { val program = gen.generate() assertThat(program.size).isLessThan(counterRegion) + val randomProgram = ByteArray(1) { 0 } + + ByteArray(counterRegion - 1).also { Random.nextBytes(it) } + // There are known firmware bugs where they calculate the number of non-zero bytes within + // the program to determine the program length. Modify the test to first install a longer + // program before installing a program that do the program length check. This should help us + // catch these types of firmware bugs in CTS. (b/395545572) + installAndVerifyProgram(randomProgram) installAndVerifyProgram(program) // Trigger the program by sending a ping and waiting on the reply.