Skip to content

Commit

Permalink
Resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost committed Apr 22, 2022
1 parent 1145ead commit e545fdf
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/app/tests/TestCommandInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,6 @@ void TestCommandInteraction::TestCommandHandlerWithProcessReceivedEmptyDataMsg(n
chip::isCommandDispatched = false;
GenerateInvokeRequest(apSuite, apContext, commandDatabuf, false /*aNeedCommandData*/, messageIsTimed);
err = commandHandler.ProcessInvokeRequest(std::move(commandDatabuf), transactionIsTimed);
ctx.DrainAndServiceIO();
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite, chip::isCommandDispatched == (messageIsTimed == transactionIsTimed));
}
Expand Down
16 changes: 0 additions & 16 deletions src/app/tests/TestWriteInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,21 +276,6 @@ void TestWriteInteraction::TestWriteHandler(nlTestSuite * apSuite, void * apCont

TestContext & ctx = *static_cast<TestContext *>(apContext);

//
// We have to enable async dispatch here to ensure that the exchange
// gets correctly closed out in the test below. Otherwise, the following happens:
//
// 1. WriteHandler generates a response upon OnWriteRequest being called.
// 2. Since there is no matching active client-side exchange for that request, the IM engine
// handles it incorrectly and treats it like an unsolicited message.
// 3. It is invalid to receive a WriteResponse as an unsolicited message so it correctly sends back
// a StatusResponse containing an error to that message.
// 4. Without unwinding the existing call stack, a response is received on the same exchange that the handler
// generated a WriteResponse on. This exchange should have been closed in a normal execution model, but in
// a synchronous model, the exchange is still open, and the status response is sent to the WriteHandler.
// 5. WriteHandler::OnMessageReceived is invoked, and it correctly asserts.
//

constexpr bool allBooleans[] = { true, false };
for (auto messageIsTimed : allBooleans)
{
Expand Down Expand Up @@ -327,7 +312,6 @@ void TestWriteInteraction::TestWriteHandler(nlTestSuite * apSuite, void * apCont
NL_TEST_ASSERT(apSuite, status == Status::UnsupportedAccess);
}

ctx.DrainAndServiceIO();
ctx.DrainAndServiceIO();

Messaging::ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr();
Expand Down
4 changes: 2 additions & 2 deletions src/messaging/ReliableMessageContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ class ReliableMessageContext
kFlagWillSendMessage = (1u << 8),

/// When set, we have had Close() or Abort() called on us already.
kFlagClosed = (1u << 10),
kFlagClosed = (1u << 9),

/// When set, signifies that the exchange is requesting Sleepy End Device fast-polling mode.
kFlagFastPollingMode = (1u << 11),
kFlagFastPollingMode = (1u << 10),
};

BitFlags<Flags> mFlags; // Internal state flags
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/tests/MessagingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class MessagingContext : public PlatformMemoryUser
Optional<Transport::OutgoingGroupSession> mSessionBobToFriends;
};

// LoopbackMessagingContext enriches MessagingContext with a async loopback transport
// LoopbackMessagingContext enriches MessagingContext with an async loopback transport
class LoopbackMessagingContext : public LoopbackTransportManager, public MessagingContext
{
public:
Expand Down
5 changes: 3 additions & 2 deletions src/transport/raw/tests/NetworkTestHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ namespace Test {
class IOContext
{
public:
IOContext() {}

/// Initialize the underlying layers and test suite pointer
CHIP_ERROR Init();

Expand Down Expand Up @@ -65,6 +63,8 @@ class LoopbackTransportDelegate
{
public:
virtual ~LoopbackTransportDelegate() {}

// Called by the loopback transport when it drops a message due to a nonzero mNumMessagesToDrop.
virtual void OnMessageDropped() {}
};

Expand All @@ -74,6 +74,7 @@ class LoopbackTransport : public Transport::Base
void InitLoopbackTransport(System::Layer * systemLayer) { mSystemLayer = systemLayer; }
void ShutdownLoopbackTransport()
{
// Packets are allocated from platform memory, we should release them before Platform::MemoryShutdown
while (!mPendingMessageQueue.empty())
mPendingMessageQueue.pop();
}
Expand Down
7 changes: 1 addition & 6 deletions src/transport/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ import("//build_overrides/nlunit_test.gni")

import("${chip_root}/build/chip/chip_test_suite.gni")

static_library("helpers") {
output_name = "libTestTransportHelpers"
output_dir = "${root_out_dir}/lib"

source_set("helpers") {
sources = [ "LoopbackTransportManager.h" ]

cflags = [ "-Wconversion" ]

public_deps = [
"${chip_root}/src/transport:transport",
"${chip_root}/src/transport/raw",
Expand Down
2 changes: 1 addition & 1 deletion src/transport/tests/LoopbackTransportManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class LoopbackTransportManager
}

private:
TransportMgr<LoopbackTransport> mTransportManager;
Test::IOContext mIOContext;
TransportMgr<LoopbackTransport> mTransportManager;
};

} // namespace Test
Expand Down

0 comments on commit e545fdf

Please sign in to comment.