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
This commit is contained in:
Yuyang Huang 2025-02-13 11:23:35 +09:00
commit 9ed841724c

View file

@ -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.