Skip to content

Commit 7ef53d2

Browse files
authored
Enable backwards compatibility test run/compilation on linux/darwin (project-chip#43705)
* Enable backwards compatibility test run/compilation on linux/darwin for master unit tests. Also fix these tests, they already bitrotted. * Restyle * make clang-tidy happy
1 parent 926ef5a commit 7ef53d2

5 files changed

Lines changed: 27 additions & 6 deletions

File tree

src/BUILD.gn

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,23 @@ if (chip_build_tests) {
148148
# "${chip_root}/src/app/clusters/commodity-tariff-server/tests",
149149
]
150150

151+
# Backwards compatibility uses ember mocks, so they cannot run in a "unified"
152+
# test build. Restrict them to specific platforms only
153+
if (chip_device_platform == "darwin" || chip_device_platform == "linux") {
154+
tests += [
155+
# keep-sorted: start
156+
"${chip_root}/src/app/clusters/chime-server/tests:tests-backwards-compatibility",
157+
"${chip_root}/src/app/clusters/device-energy-management-server/tests:tests-backwards-compatibility",
158+
"${chip_root}/src/app/clusters/electrical-energy-measurement-server/tests:tests-backwards-compatibility",
159+
"${chip_root}/src/app/clusters/electrical-power-measurement-server/tests:tests-backwards-compatibility",
160+
"${chip_root}/src/app/clusters/energy-evse-server/tests:tests-backwards-compatibility",
161+
"${chip_root}/src/app/clusters/identify-server/tests:tests-backwards-compatibility",
162+
"${chip_root}/src/app/clusters/power-topology-server/tests:tests-backwards-compatibility",
163+
164+
# keep-sorted: end
165+
]
166+
}
167+
151168
if (current_os != "zephyr") {
152169
tests += [ "${chip_root}/src/lib/dnssd/minimal_mdns/records/tests" ]
153170
}

src/app/clusters/chime-server/tests/TestChimeClusterBackwardsCompatibility.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <app/DefaultSafeAttributePersistenceProvider.h>
2020
#include <app/SafeAttributePersistenceProvider.h>
2121
#include <app/clusters/chime-server/chime-server.h>
22-
#include <app/server-cluster/testingClusterTester.h>
22+
#include <app/server-cluster/testing/ClusterTester.h>
2323
#include <data-model-providers/codegen/CodegenDataModelProvider.h>
2424
#include <gtest/gtest.h>
2525

@@ -59,7 +59,7 @@ class MockChimeDelegate : public ChimeDelegate
5959
}
6060
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
6161
}
62-
Protocols::InteractionModel::Status PlayChimeSound() override
62+
Protocols::InteractionModel::Status PlayChimeSound(uint8_t) override
6363
{
6464
playChimeSoundCalled = true;
6565
return Protocols::InteractionModel::Status::Success;

src/app/clusters/device-energy-management-server/tests/TestDeviceEnergyManagementClusterBackwardsCompatibility.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ TEST_F(TestDeviceEnergyManagementClusterBackwardsCompatibility, TestInstanceLife
7474
EXPECT_TRUE(instance.HasFeature(Feature::kConstraintBasedAdjustment));
7575

7676
// Test shutdown (unregistration)
77-
instance.Shutdown(ClusterShutdownType::kClusterShutdown);
77+
instance.Shutdown();
7878

7979
// Verify cluster is unregistered from the registry
8080
auto * unregisteredCluster =
@@ -97,7 +97,7 @@ TEST_F(TestDeviceEnergyManagementClusterBackwardsCompatibility, TestInstanceLife
9797
EXPECT_FALSE(instance.HasFeature(Feature::kPausable));
9898

9999
// Test shutdown
100-
instance.Shutdown(ClusterShutdownType::kClusterShutdown);
100+
instance.Shutdown();
101101
}
102102
}
103103

src/app/clusters/electrical-energy-measurement-server/tests/TestElectricalEnergyMeasurementClusterBackwardsCompatibility.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ TEST_F(TestElectricalEnergyMeasurementClusterBackwardsCompatibility, TestCodegen
195195
EXPECT_EQ(SetMeasurementAccuracy(kTestEndpointId, accuracy), CHIP_NO_ERROR);
196196

197197
// Verify the value was set
198-
Structs::MeasurementAccuracyStruct::Type readAccuracy;
199198
cluster->GetMeasurementAccuracy(readAccuracy);
200199
// Verify that the MeasurementAccuracyStruct is not erased by the empty accuracyRanges
201200
EXPECT_EQ(readAccuracy.measurementType, MeasurementTypeEnum::kApparentEnergy);
@@ -250,10 +249,13 @@ TEST_F(TestElectricalEnergyMeasurementClusterBackwardsCompatibility, TestCodegen
250249
ASSERT_TRUE(event.has_value());
251250

252251
using CumulativeEventType = chip::app::Clusters::ElectricalEnergyMeasurement::Events::CumulativeEnergyMeasured::Type;
252+
253+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access): we asserted above for has_value
253254
EXPECT_EQ(event->eventOptions.mPath,
254255
ConcreteEventPath(kTestEndpointId, CumulativeEventType::GetClusterId(), CumulativeEventType::GetEventId()));
255256

256257
chip::app::Clusters::ElectricalEnergyMeasurement::Events::CumulativeEnergyMeasured::DecodableType decodedEvent;
258+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access): we asserted above for has_value
257259
ASSERT_EQ(event->GetEventData(decodedEvent), CHIP_NO_ERROR);
258260

259261
ASSERT_TRUE(decodedEvent.energyImported.HasValue());
@@ -291,10 +293,12 @@ TEST_F(TestElectricalEnergyMeasurementClusterBackwardsCompatibility, TestCodegen
291293
ASSERT_TRUE(event.has_value());
292294

293295
using PeriodicEventType = chip::app::Clusters::ElectricalEnergyMeasurement::Events::PeriodicEnergyMeasured::Type;
296+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access): we asserted above for has_value
294297
EXPECT_EQ(event->eventOptions.mPath,
295298
ConcreteEventPath(kTestEndpointId, PeriodicEventType::GetClusterId(), PeriodicEventType::GetEventId()));
296299

297300
chip::app::Clusters::ElectricalEnergyMeasurement::Events::PeriodicEnergyMeasured::DecodableType decodedEvent;
301+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access): we asserted above for has_value
298302
ASSERT_EQ(event->GetEventData(decodedEvent), CHIP_NO_ERROR);
299303

300304
ASSERT_TRUE(decodedEvent.energyImported.HasValue());

src/app/clusters/power-topology-server/tests/TestPowerTopologyClusterBackwardsCompatibility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ TEST_F(TestPowerTopologyClusterBackwardsCompatibility, TestInstanceLifecycle)
5858
EXPECT_EQ(instance.Init(), CHIP_NO_ERROR);
5959

6060
// Test shutdown
61-
instance.Shutdown(ClusterShutdownType::kClusterShutdown);
61+
instance.Shutdown();
6262
}
6363

6464
} // namespace

0 commit comments

Comments
 (0)