Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue related to teardown of some App Tests #33654

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/app/tests/AppTestContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ void AppContext::SetUpTestSuite()

void AppContext::TearDownTestSuite()
{
// Some test suites finish with unprocessed work left in the platform manager event queue.
// This can particularly be a problem when this unprocessed work involves reporting engine runs,
// since those can take a while and cause later tests to not reach their queued work before
// their timeouts hit. This is only an issue in setups where all unit tests are compiled into
// a single file (e.g. nRF CI (Zephyr native_posix)).
//
// Work around this issue by doing a DrainAndServiceIO() here to attempt to flush out any queued-up work.
//
// TODO: Solve the underlying issue where test suites leave unprocessed work. Or is this actually
// the right solution?
LoopbackMessagingContext::DrainAndServiceIO();

chip::DeviceLayer::PlatformMgr().Shutdown();
LoopbackMessagingContext::TearDownTestSuite();
}
Expand Down
14 changes: 2 additions & 12 deletions src/app/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ chip_test_suite_using_nltest("tests") {
output_name = "libAppTests"

test_sources = [
"TestAclAttribute.cpp",
"TestAclEvent.cpp",
"TestAttributeAccessInterfaceCache.cpp",
"TestAttributePathExpandIterator.cpp",
Expand Down Expand Up @@ -151,6 +152,7 @@ chip_test_suite_using_nltest("tests") {
"TestPendingResponseTrackerImpl.cpp",
"TestPowerSourceCluster.cpp",
"TestReadInteraction.cpp",
"TestReportScheduler.cpp",
"TestReportingEngine.cpp",
"TestStatusIB.cpp",
"TestStatusResponseMessage.cpp",
Expand All @@ -164,8 +166,6 @@ chip_test_suite_using_nltest("tests") {
test_sources += [ "TestFailSafeContext.cpp" ]
}

test_sources += [ "TestAclAttribute.cpp" ]

# DefaultICDClientStorage assumes that raw AES key is used by the application
if (chip_crypto != "psa") {
test_sources += [ "TestDefaultICDClientStorage.cpp" ]
Expand All @@ -189,16 +189,6 @@ chip_test_suite_using_nltest("tests") {
test_sources += [ "TestEventLogging.cpp" ]
}

# The platform manager is not properly clearing queues in test teardown, which results in
# DrainIO calls not being able to run in expected time (5seconds) if unprocessed reported engine
# runs are remaining, causing tests to crash in Open IoT SDK and Zephyr tests since they are
# running all tests in one file. We need to figure out how to properly clean the event queues
# before enabling this test for these platforms.
if (chip_device_platform != "nrfconnect" &&
chip_device_platform != "openiotsdk") {
test_sources += [ "TestReportScheduler.cpp" ]
}

cflags = [ "-Wconversion" ]

public_deps = [
Expand Down
Loading