From 333090f8036c7d4bd8217bd02db5a64817a2b684 Mon Sep 17 00:00:00 2001 From: clydebarrow <2366188+clydebarrow@users.noreply.github.com> Date: Sun, 18 Oct 2026 20:12:22 +1100 Subject: [PATCH] [packet_interface] Keep App alive across the bridge tests The test main constructs App once, and later tests and its listener use it, so the fixture now replaces App in SetUp and constructs it again in TearDown, instead of constructing over a live App and leaving it destroyed. Co-Authored-By: Claude Opus 5.5 --- .../packet_interface/packet_interface_transport.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/components/packet_interface/packet_interface_transport.cpp b/tests/components/packet_interface/packet_interface_transport.cpp index fd85b367c93..5a7a17dead5 100644 --- a/tests/components/packet_interface/packet_interface_transport.cpp +++ b/tests/components/packet_interface/packet_interface_transport.cpp @@ -45,18 +45,22 @@ static Packet ping_packet(const char *hostname, uint32_t key) { return packet; } -// The test main does not construct App, which the transport's setup() reads the device name from +// Each test replaces App with a fresh one, which the transport's setup() reads the device name from class PacketInterfaceTransportTest : public ::testing::Test { protected: void SetUp() override { - new (&App) Application; + App.~Application(); + new (&App) Application(); static char name[] = "bridge-tests"; static char friendly_name[] = ""; App.pre_setup(name, sizeof(name) - 1, friendly_name, 0); this->bridge_.set_encryption_key(std::vector(32, 0xAA)); this->bridge_.setup(); } - void TearDown() override { App.~Application(); } + void TearDown() override { + App.~Application(); + new (&App) Application(); // later tests and the test listener use App + } FakeInterface link_; FakeLayer layer_{&this->link_};