[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 <noreply@anthropic.com>
This commit is contained in:
clydebarrow
2026-10-19 14:40:08 +11:00
co-authored by Claude Opus 5.5
parent 627a418d88
commit 333090f803
@@ -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<uint8_t>(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_};