Skip to content

Commit 19f8db3

Browse files
authored
nodiscard ChipError Batch #1: tests (project-chip#41858)
* Batch #1 nodiscard errors: tests * Fix CI failures & merge head * Fix CI * Fix tizen CI * Clang tidy * Fix CI after clang tidy fix * Clang tidy
1 parent c80ba35 commit 19f8db3

File tree

103 files changed

+1310
-1241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1310
-1241
lines changed

examples/common/server-cluster-shim/tests/TestServerClusterShim.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <data-model-providers/codegen/tests/EmberInvokeOverride.h>
2424
#include <data-model-providers/codegen/tests/EmberReadWriteOverride.h>
2525
#include <lib/support/ReadOnlyBuffer.h>
26+
#include <lib/support/tests/ExtraPwTestMacros.h>
2627
#include <pw_unit_test/framework.h>
2728
#include <server-cluster-shim/ServerClusterShim.h>
2829

@@ -327,7 +328,7 @@ TEST_F(TestServerClusterShim, TestWriteAttributeOnlyProvidedPathsAreValid)
327328
ServerClusterShim invalid_cluster(
328329
{ { kMockEndpoint1,
329330
MockClusterId(1) } }); // Only adds path endpoint 1, cluster 1, even though behind the scenes ember knows more stuff.
330-
invalid_cluster.Startup(testContext.Get());
331+
EXPECT_SUCCESS(invalid_cluster.Startup(testContext.Get()));
331332

332333
WriteOperation test(kMockEndpoint3, MockClusterId(4), MOCK_ATTRIBUTE_ID_FOR_NON_NULLABLE_TYPE(ZCL_CHAR_STRING_ATTRIBUTE_TYPE));
333334
test.SetSubjectDescriptor(kAdminSubjectDescriptor);
@@ -340,7 +341,7 @@ TEST_F(TestServerClusterShim, TestWriteAttributeOnlyProvidedPathsAreValid)
340341

341342
// Create another cluster with the valid paths for the write command
342343
ServerClusterShim valid_cluster({ { kMockEndpoint1, MockClusterId(1) }, { kMockEndpoint3, MockClusterId(4) } });
343-
valid_cluster.Startup(testContext.Get());
344+
EXPECT_SUCCESS(valid_cluster.Startup(testContext.Get()));
344345

345346
chip::Test::SetEmberReadOutput(Protocols::InteractionModel::Status::Success);
346347
// Expect success now
@@ -359,7 +360,7 @@ TEST_F(TestServerClusterShim, TestDataVersion)
359360
chip::Test::SetMockNodeConfig(gTestNodeConfig);
360361

361362
ServerClusterShim cluster({ { kMockEndpoint3, MockClusterId(4) } });
362-
cluster.Startup(testContext.Get());
363+
EXPECT_SUCCESS(cluster.Startup(testContext.Get()));
363364

364365
DataVersion v1 = cluster.GetDataVersion({ kMockEndpoint3, MockClusterId(4) });
365366

@@ -379,7 +380,7 @@ TEST_F(TestServerClusterShim, AttributeWriteShortString)
379380
TestServerClusterContext testContext;
380381
chip::Test::SetMockNodeConfig(gTestNodeConfig);
381382
ServerClusterShim cluster({ { kMockEndpoint3, MockClusterId(4) } });
382-
cluster.Startup(testContext.Get());
383+
EXPECT_SUCCESS(cluster.Startup(testContext.Get()));
383384

384385
WriteOperation test(kMockEndpoint3, MockClusterId(4), MOCK_ATTRIBUTE_ID_FOR_NON_NULLABLE_TYPE(ZCL_CHAR_STRING_ATTRIBUTE_TYPE));
385386
test.SetSubjectDescriptor(kAdminSubjectDescriptor);
@@ -401,8 +402,8 @@ TEST_F(TestServerClusterShim, EmberAttributeReadOctetString)
401402
chip::Test::SetMockNodeConfig(gTestNodeConfig);
402403
ServerClusterShim invalid_cluster({ { 1, 1 } });
403404
ServerClusterShim valid_cluster({ { kMockEndpoint3, MockClusterId(4) } });
404-
invalid_cluster.Startup(testContext.Get());
405-
valid_cluster.Startup(testContext.Get());
405+
EXPECT_SUCCESS(invalid_cluster.Startup(testContext.Get()));
406+
EXPECT_SUCCESS(valid_cluster.Startup(testContext.Get()));
406407

407408
ReadOperation testRequest(kMockEndpoint3, MockClusterId(4),
408409
MOCK_ATTRIBUTE_ID_FOR_NON_NULLABLE_TYPE(ZCL_LONG_OCTET_STRING_ATTRIBUTE_TYPE));
@@ -445,7 +446,7 @@ TEST_F(TestServerClusterShim, IterateOverAttributes)
445446
TestServerClusterContext testContext;
446447
chip::Test::SetMockNodeConfig(gTestNodeConfig);
447448
ServerClusterShim cluster({ { kMockEndpoint3, MockClusterId(4) } });
448-
cluster.Startup(testContext.Get());
449+
EXPECT_SUCCESS(cluster.Startup(testContext.Get()));
449450

450451
// should be able to iterate over valid paths
451452
ReadOnlyBufferBuilder<DataModel::AttributeEntry> builder;
@@ -497,8 +498,8 @@ TEST_F(TestServerClusterShim, EmberInvokeTest)
497498
ServerClusterShim cluster_with_invalid_path({ { kMockEndpoint3, MockClusterId(4) } });
498499
ServerClusterShim cluster_with_valid_path({ { kMockEndpoint1, MockClusterId(1) } });
499500

500-
cluster_with_invalid_path.Startup(testContext.Get());
501-
cluster_with_valid_path.Startup(testContext.Get());
501+
EXPECT_SUCCESS(cluster_with_invalid_path.Startup(testContext.Get()));
502+
EXPECT_SUCCESS(cluster_with_valid_path.Startup(testContext.Get()));
502503

503504
{
504505
const ConcreteCommandPath kCommandPath(kMockEndpoint1, MockClusterId(1), kMockCommandId1);
@@ -539,7 +540,7 @@ TEST_F(TestServerClusterShim, IterateOverAcceptedCommands)
539540
TestServerClusterContext testContext;
540541
chip::Test::SetMockNodeConfig(gTestNodeConfig);
541542
ServerClusterShim cluster({ { kMockEndpoint3, MockClusterId(4) }, { kMockEndpoint2, MockClusterId(2) } });
542-
cluster.Startup(testContext.Get());
543+
EXPECT_SUCCESS(cluster.Startup(testContext.Get()));
543544

544545
ReadOnlyBufferBuilder<DataModel::AcceptedCommandEntry> builder;
545546

@@ -578,10 +579,10 @@ TEST_F(TestServerClusterShim, IterateOverGeneratedCommands)
578579
TestServerClusterContext testContext;
579580
chip::Test::SetMockNodeConfig(gTestNodeConfig);
580581
ServerClusterShim cluster({ { kMockEndpoint2, MockClusterId(2) }, { kMockEndpoint2, MockClusterId(3) } });
581-
cluster.Startup(testContext.Get());
582+
EXPECT_SUCCESS(cluster.Startup(testContext.Get()));
582583

583584
ServerClusterShim cluster_without_id3({ { kMockEndpoint2, MockClusterId(2) } });
584-
cluster_without_id3.Startup(testContext.Get());
585+
EXPECT_SUCCESS(cluster_without_id3.Startup(testContext.Get()));
585586

586587
ReadOnlyBufferBuilder<CommandId> builder;
587588

examples/energy-management-app/energy-management-common/tests/TestEvseTargetsStorage.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <lib/support/DefaultStorageKeyAllocator.h>
2828
#include <lib/support/Span.h>
2929
#include <lib/support/TestPersistentStorageDelegate.h>
30+
#include <lib/support/tests/ExtraPwTestMacros.h>
3031

3132
#include "EnergyEvseTargetsStore.h"
3233

@@ -200,7 +201,7 @@ void TestEvseTargetsStorage::SetTargets()
200201
{
201202
if (!mEtdInitialised)
202203
{
203-
mEtd.Init(&mStorageDelegate);
204+
EXPECT_SUCCESS(mEtd.Init(&mStorageDelegate));
204205

205206
mEtdInitialised = true;
206207
}

0 commit comments

Comments
 (0)