diff --git a/tests/components/packet_interface/basic_session.cpp b/tests/components/packet_interface/basic_session.cpp index 665ada57d4a..bd62fb382ab 100644 --- a/tests/components/packet_interface/basic_session.cpp +++ b/tests/components/packet_interface/basic_session.cpp @@ -79,16 +79,20 @@ static void pump(Peer &a, Peer &b) { FAIL() << "Peers did not go quiet"; } -// The test main does not construct App; the keep-alive interval needs its scheduler +// Each test replaces App with a fresh one; the keep-alive interval needs its scheduler class BasicSessionTest : public ::testing::Test { protected: void SetUp() override { - new (&App) Application; + App.~Application(); + new (&App) Application(); static char name[] = "session-tests"; static char friendly_name[] = ""; App.pre_setup(name, sizeof(name) - 1, friendly_name, 0); } - void TearDown() override { App.~Application(); } + void TearDown() override { + App.~Application(); + new (&App) Application(); // later tests and the test listener use App + } static void set_time(uint32_t now) { LoopBlockingGuard guard{nullptr, nullptr, now}; } }; diff --git a/tests/components/packet_interface/xxtea_encryption.cpp b/tests/components/packet_interface/xxtea_encryption.cpp index 12956ade212..57b35badeec 100644 --- a/tests/components/packet_interface/xxtea_encryption.cpp +++ b/tests/components/packet_interface/xxtea_encryption.cpp @@ -74,16 +74,20 @@ struct Peer { std::vector received; }; -// The test main does not construct App as generated code does +// Each test replaces App with a fresh one class XxteaEncryptionTest : public ::testing::Test { protected: void SetUp() override { - new (&App) Application; + App.~Application(); + new (&App) Application(); static char name[] = "xxtea-tests"; static char friendly_name[] = ""; App.pre_setup(name, sizeof(name) - 1, friendly_name, 0); } - void TearDown() override { App.~Application(); } + void TearDown() override { + App.~Application(); + new (&App) Application(); // later tests and the test listener use App + } }; TEST_F(XxteaEncryptionTest, MaxPacketSizeAllowsForTrailerAndWords) {