From 2b7bf2836bb9833b1a2170898e2fc1d7d4f7f043 Mon Sep 17 00:00:00 2001 From: Tadayoshi MIURA <11958457+t-miura@users.noreply.github.com> Date: Sun, 23 Aug 2026 21:10:29 +0900 Subject: [PATCH] fix(test): remove brittle pointer comparison in test_radio In test_beginSending_oversizedPayloadAbortsSafely, reallocating a packet and asserting TEST_ASSERT_EQUAL_PTR(p, reallocated) assumes malloc() immediately recycles the previously freed address. On CI (env:coverage), AddressSanitizer (-fsanitize=address) places freed blocks into a quarantine zone, causing subsequent allocations to yield a new address and failing the assertion. Remove the brittle pointer equality assertion and dummy reallocation. Packet release is already validated at test teardown by LeakSanitizer (LSan). --- test/test_radio/test_main.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/test_radio/test_main.cpp b/test/test_radio/test_main.cpp index f8a701f2a38..5ab6edf747d 100644 --- a/test/test_radio/test_main.cpp +++ b/test/test_radio/test_main.cpp @@ -419,6 +419,7 @@ static void test_regionPresetMap_unsetCarriesUserprefsIntent() static void test_beginSending_oversizedPayloadAbortsSafely() { + // Allocate a packet and set required header fields meshtastic_MeshPacket *p = packetPool.allocZeroed(); TEST_ASSERT_NOT_NULL(p); p->from = 0x12345678; @@ -426,19 +427,19 @@ static void test_beginSending_oversizedPayloadAbortsSafely() p->id = 0x10203040; p->which_payload_variant = meshtastic_MeshPacket_encrypted_tag; - // Set encrypted size larger than sizeof(radioBuffer.payload) (which is 256 - sizeof(PacketHeader)) + // Set encrypted size larger than radioBuffer.payload capacity to trigger rejection p->encrypted.size = testRadio->getRadioBufferPayloadCapacity() + 10; + // Call beginSending with the oversized packet size_t result = testRadio->beginSendingPublic(p); + // Verify the send was rejected (returns 0) TEST_ASSERT_EQUAL_UINT(0, result); + + // Verify sendingPacket was NOT set (packet was not queued) TEST_ASSERT_NULL(testRadio->getSendingPacket()); - // Verify rejected packet was released to packetPool and its slot is reusable - meshtastic_MeshPacket *reallocated = packetPool.allocZeroed(); - TEST_ASSERT_NOT_NULL(reallocated); - TEST_ASSERT_EQUAL_PTR(p, reallocated); - packetPool.release(reallocated); + // LeakSanitizer on CI will automatically detect if p wasn't released to packetPool } void setUp(void)