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

Add controller tests to the build. #10729

Merged
merged 3 commits into from
Nov 15, 2021
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
5 changes: 4 additions & 1 deletion src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ if (chip_build_tests) {
if (chip_device_platform != "nrfconnect" &&
chip_device_platform != "efr32") {
# TODO(#10447): Controller test has HF on EFR32.
deps += [ "${chip_root}/src/controller/tests" ]
deps += [
"${chip_root}/src/controller/tests",
"${chip_root}/src/controller/tests/data_model",
]
}

if (current_os != "zephyr" && current_os != "mbed" &&
Expand Down
1 change: 0 additions & 1 deletion src/controller/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ chip_test_suite("tests") {
"${chip_root}/src/app/common:cluster-objects",
"${chip_root}/src/app/tests:helpers",
"${chip_root}/src/controller",
"${chip_root}/src/controller/tests/data_model:interaction-tests",
"${chip_root}/src/messaging/tests:helpers",
"${chip_root}/src/transport/raw/tests:helpers",
"${nlunit_test_root}:nlunit-test",
Expand Down
4 changes: 2 additions & 2 deletions src/controller/tests/data_model/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import("//build_overrides/nlunit_test.gni")
import("${chip_root}/build/chip/chip_test_suite.gni")
import("${chip_root}/src/platform/device.gni")

chip_test_suite("interaction-tests") {
output_name = "libInteractionTests"
chip_test_suite("data_model") {
output_name = "libDataModelTests"

if (chip_device_platform != "mbed" && chip_device_platform != "efr32") {
test_sources = [ "TestCommands.cpp" ]
Expand Down
22 changes: 19 additions & 3 deletions src/controller/tests/data_model/TestCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*
*/

#include "app/data-model/NullObject.h"
#include <app-common/zap-generated/cluster-objects.h>
#include <app/AppBuildConfig.h>
#include <app/InteractionModelEngine.h>
Expand Down Expand Up @@ -223,8 +224,13 @@ void TestCommandInteraction::TestDataResponse(nlTestSuite * apSuite, void * apCo

void TestCommandInteraction::TestSuccessNoDataResponse(nlTestSuite * apSuite, void * apContext)
{
struct FakeRequest : public TestCluster::Commands::TestSimpleArgumentRequest::Type
{
using ResponseType = DataModel::NullObjectType;
};

TestContext & ctx = *static_cast<TestContext *>(apContext);
TestCluster::Commands::TestSimpleArgumentRequest::Type request;
FakeRequest request;
auto sessionHandle = ctx.GetSessionBobToAlice();

bool onSuccessWasCalled = false;
Expand Down Expand Up @@ -257,8 +263,13 @@ void TestCommandInteraction::TestSuccessNoDataResponse(nlTestSuite * apSuite, vo

void TestCommandInteraction::TestAsyncResponse(nlTestSuite * apSuite, void * apContext)
{
struct FakeRequest : public TestCluster::Commands::TestSimpleArgumentRequest::Type
{
using ResponseType = DataModel::NullObjectType;
};

TestContext & ctx = *static_cast<TestContext *>(apContext);
TestCluster::Commands::TestSimpleArgumentRequest::Type request;
FakeRequest request;
auto sessionHandle = ctx.GetSessionBobToAlice();

bool onSuccessWasCalled = false;
Expand Down Expand Up @@ -342,8 +353,13 @@ void TestCommandInteraction::TestFailure(nlTestSuite * apSuite, void * apContext

void TestCommandInteraction::TestSuccessNoDataResponseWithClusterStatus(nlTestSuite * apSuite, void * apContext)
{
struct FakeRequest : public TestCluster::Commands::TestSimpleArgumentRequest::Type
{
using ResponseType = DataModel::NullObjectType;
};

TestContext & ctx = *static_cast<TestContext *>(apContext);
TestCluster::Commands::TestSimpleArgumentRequest::Type request;
FakeRequest request;
auto sessionHandle = ctx.GetSessionBobToAlice();

bool onSuccessWasCalled = false;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/tests/data_model/TestRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const Concre

ReturnErrorOnFailure(DataModel::Encode(*(attributeData.GetWriter()),
chip::TLV::ContextTag(chip::to_underlying(AttributeDataIB::Tag::kData)), value));
attributeData.DataVersion(0);
attributeData.DataVersion(0).EndOfAttributeDataIB();
return CHIP_NO_ERROR;
}
else
Expand Down