Skip to content

Commit

Permalink
Merge branch 'master' into TC-SC-4.3-python-test
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-marquez-csa authored Jul 10, 2024
2 parents fe29dde + 8ebe19d commit 7800000
Show file tree
Hide file tree
Showing 14 changed files with 405 additions and 194 deletions.
15 changes: 11 additions & 4 deletions config/python/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@
#define CHIP_CONFIG_EVENT_LOGGING_NUM_EXTERNAL_CALLBACKS 2

// Uncomment this for a large Tunnel MTU.
//#define CHIP_CONFIG_TUNNEL_INTERFACE_MTU (9000)
// #define CHIP_CONFIG_TUNNEL_INTERFACE_MTU (9000)

// Enable support functions for parsing command-line arguments
#define CHIP_CONFIG_ENABLE_ARG_PARSER 1

// Use a default pairing code if one hasn't been provisioned in flash.
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00
// Enable use of test setup parameters for testing purposes only.
//
// WARNING: This option makes it possible to circumvent basic chip security functionality.
// Because of this it SHOULD NEVER BE ENABLED IN PRODUCTION BUILDS.
//
#ifndef CHIP_DEVICE_CONFIG_ENABLE_TEST_SETUP_PARAMS
#define CHIP_DEVICE_CONFIG_ENABLE_TEST_SETUP_PARAMS 1
#endif

// Enable reading DRBG seed data from /dev/(u)random.
// This is needed for test applications and the CHIP device manager to function
Expand All @@ -46,6 +51,8 @@
// WARNING: These options make it possible to circumvent basic Chip security functionality,
// including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS.
//
// To build with this flag, pass 'treat_warnings_as_errors=false' to gn/ninja.
//
#define CHIP_CONFIG_SECURITY_TEST_MODE 0

#define CHIP_CONFIG_ENABLE_UPDATE 1
Expand Down
7 changes: 6 additions & 1 deletion examples/contact-sensor-app/nxp/k32w/k32w0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,14 @@ Please see more in the
Here is an example that generates an OTA image with application update TLV:

```
./scripts/tools/nxp/ota/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 42021 -vs "1.0" -da sha256 --app-input-file chip-k32w0x-contact-example.bin chip-k32w0x-contact-example.ota
./scripts/tools/nxp/ota/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 2 -vs "2.0" -da sha256 --enc_enable --input_ota_key "1234567890ABCDEFA1B2C3D4E5F6F1B4" --app-input-file chip-k32w0x-contact-example.bin chip-k32w0x-contact-example.ota
```

Please note the two options `--enc_enable` and `--input_ota_key`, which are
mandatory when `chip_with_ota_encryption=1`. The value of `--input_ota_key` must
match the value of `chip_with_ota_key`. See `args.gni` for the default gn
configuration.

A note regarding OTA image header version (`-vn` option). An application binary
has its own software version, given by
`CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION` (`42020` by default), which can be
Expand Down
19 changes: 16 additions & 3 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1844,13 +1844,25 @@ void DeviceCommissioner::CleanupCommissioning(DeviceProxy * proxy, NodeId nodeId

if (completionStatus.err == CHIP_NO_ERROR)
{
// CommissioningStageComplete uses mDeviceBeingCommissioned, which can
// be commissionee if we are cleaning up before we've gone operational. Normally
// that would not happen in this non-error case, _except_ if we were told to skip sending
// CommissioningComplete: in that case we do not have an operational DeviceProxy, so
// we're using our CommissioneeDeviceProxy to do a successful cleanup.
//
// This means we have to call CommissioningStageComplete() before we destroy commissionee.
//
// This should be safe, because CommissioningStageComplete() does not call CleanupCommissioning
// when called in the cleanup stage (which is where we are), and StopPairing does not directly release
// mDeviceBeingCommissioned.
CommissioningStageComplete(CHIP_NO_ERROR);

CommissioneeDeviceProxy * commissionee = FindCommissioneeDevice(nodeId);
if (commissionee != nullptr)
{
ReleaseCommissioneeDevice(commissionee);
}
// Send the callbacks, we're done.
CommissioningStageComplete(CHIP_NO_ERROR);
SendCommissioningCompleteCallbacks(nodeId, mCommissioningCompletionStatus);
}
else if (completionStatus.err == CHIP_ERROR_CANCELLED)
Expand Down Expand Up @@ -1929,12 +1941,13 @@ void DeviceCommissioner::CleanupDoneAfterError()
VerifyOrReturn(mDeviceBeingCommissioned != nullptr);

NodeId nodeId = mDeviceBeingCommissioned->GetDeviceId();
// At this point, we also want to close off the pase session so we need to re-establish
CommissioneeDeviceProxy * commissionee = FindCommissioneeDevice(nodeId);

// Signal completion - this will reset mDeviceBeingCommissioned.
CommissioningStageComplete(CHIP_NO_ERROR);

// At this point, we also want to close off the pase session so we need to re-establish
CommissioneeDeviceProxy * commissionee = FindCommissioneeDevice(nodeId);

// If we've disarmed the failsafe, it's because we're starting again, so kill the pase connection.
if (commissionee != nullptr)
{
Expand Down
4 changes: 2 additions & 2 deletions src/protocols/secure_channel/CASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ void CASESession::OnResponseTimeout(ExchangeContext * ec)
ChipLogError(SecureChannel, "CASESession::OnResponseTimeout exchange doesn't match"));
ChipLogError(SecureChannel,
"CASESession timed out while waiting for a response from peer " ChipLogFormatScopedNodeId ". Current state was %u",
ChipLogValueScopedNodeId(ScopedNodeId(mPeerNodeId, mFabricIndex)), to_underlying(mState));
ChipLogValueScopedNodeId(GetPeer()), to_underlying(mState));
MATTER_TRACE_COUNTER("CASETimeout");
// Discard the exchange so that Clear() doesn't try aborting it. The
// exchange will handle that.
Expand Down Expand Up @@ -872,7 +872,7 @@ CHIP_ERROR CASESession::SendSigma1()
mState = State::kSentSigma1;
}

ChipLogProgress(SecureChannel, "Sent Sigma1 msg");
ChipLogProgress(SecureChannel, "Sent Sigma1 msg to " ChipLogFormatScopedNodeId, ChipLogValueScopedNodeId(GetPeer()));

mDelegate->OnSessionEstablishmentStarted();

Expand Down
36 changes: 24 additions & 12 deletions src/python_testing/TC_EEM_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,20 @@ def pics_TC_EEM_2_1(self):

def steps_TC_EEM_2_1(self) -> list[TestStep]:
steps = [
TestStep("1", "Commissioning, already done", is_commissioning=True),
TestStep("2", "TH reads Accuracy attribute. Verify that the DUT response contains a MeasurementAccuracyStruct value."),
TestStep("3", "TH reads CumulativeEnergyImported attribute. Verify that the DUT response contains either null or an EnergyMeasurementStruct value."),
TestStep("4", "TH reads CumulativeEnergyExported attribute. Verify that the DUT response contains either null or an EnergyMeasurementStruct value."),
TestStep("5", "TH reads PeriodicEnergyImported attribute. Verify that the DUT response contains either null or an EnergyMeasurementStruct value."),
TestStep("6", "TH reads PeriodicEnergyExported attribute. Verify that the DUT response contains either null or an EnergyMeasurementStruct value."),
TestStep("7", "TH reads CumulativeEnergyReset attribute. Verify that the DUT response contains either null or an CumulativeEnergyResetStruct value."),
TestStep("1", "Commissioning, already done",
is_commissioning=True),
TestStep("2", "TH reads Accuracy attribute",
"Verify that the DUT response contains a MeasurementAccuracyStruct value."),
TestStep("3", "TH reads CumulativeEnergyImported attribute",
"Verify that the DUT response contains either null or an EnergyMeasurementStruct value."),
TestStep("4", "TH reads CumulativeEnergyExported attribute",
"Verify that the DUT response contains either null or an EnergyMeasurementStruct value."),
TestStep("5", "TH reads PeriodicEnergyImported attribute",
"Verify that the DUT response contains either null or an EnergyMeasurementStruct value."),
TestStep("6", "TH reads PeriodicEnergyExported attribute",
"Verify that the DUT response contains either null or an EnergyMeasurementStruct value."),
TestStep("7", "TH reads CumulativeEnergyReset attribute",
"Verify that the DUT response contains either null or an CumulativeEnergyResetStruct value."),
]

return steps
Expand All @@ -64,29 +71,34 @@ async def test_TC_EEM_2_1(self):
self.step("2")
accuracy = await self.read_eem_attribute_expect_success("Accuracy")
logger.info(f"Rx'd Accuracy: {accuracy}")
asserts.assert_not_equal(accuracy, NullValue, "Accuracy is not allowed to be null")
asserts.assert_not_equal(
accuracy, NullValue, "Accuracy is not allowed to be null")
asserts.assert_equal(accuracy.measurementType, Clusters.ElectricalEnergyMeasurement.Enums.MeasurementTypeEnum.kElectricalEnergy,
"Accuracy measurementType must be ElectricalEnergy")

self.step("3")
if self.pics_guard(self.check_pics("EEM.S.A0001")):
cumulativeEnergyImported = await self.read_eem_attribute_expect_success("CumulativeEnergyImported")
logger.info(f"Rx'd CumulativeEnergyImported: {cumulativeEnergyImported}")
logger.info(
f"Rx'd CumulativeEnergyImported: {cumulativeEnergyImported}")

self.step("4")
if self.pics_guard(self.check_pics("EEM.S.A0002")):
cumulativeEnergyExported = await self.read_eem_attribute_expect_success("CumulativeEnergyExported")
logger.info(f"Rx'd CumulativeEnergyExported: {cumulativeEnergyExported}")
logger.info(
f"Rx'd CumulativeEnergyExported: {cumulativeEnergyExported}")

self.step("5")
if self.pics_guard(self.check_pics("EEM.S.A0003")):
periodicEnergyImported = await self.read_eem_attribute_expect_success("PeriodicEnergyImported")
logger.info(f"Rx'd PeriodicEnergyImported: {periodicEnergyImported}")
logger.info(
f"Rx'd PeriodicEnergyImported: {periodicEnergyImported}")

self.step("6")
if self.pics_guard(self.check_pics("EEM.S.A0004")):
periodicEnergyExported = await self.read_eem_attribute_expect_success("PeriodicEnergyExported")
logger.info(f"Rx'd PeriodicEnergyExported: {periodicEnergyExported}")
logger.info(
f"Rx'd PeriodicEnergyExported: {periodicEnergyExported}")

self.step("7")
if self.pics_guard(self.check_pics("EEM.S.A0005")):
Expand Down
12 changes: 8 additions & 4 deletions src/python_testing/TC_EEM_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ def pics_TC_EEM_2_2(self):

def steps_TC_EEM_2_2(self) -> list[TestStep]:
steps = [
TestStep("1", "Commissioning, already done", is_commissioning=True),
TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster. Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"),
TestStep("1", "Commissioning, already done",
is_commissioning=True),
TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster",
"Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"),
TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Start Fake Load Test 1kW Event"),
TestStep("4", "Wait 3 seconds"),
TestStep("4a", "TH reads from the DUT the CumulativeEnergyImported attribute. Verify the read is successful and note the value read."),
TestStep("4a", "TH reads from the DUT the CumulativeEnergyImported attribute",
"Verify the read is successful and note the value read."),
TestStep("5", "Wait 3 seconds"),
TestStep("5a", "TH reads from the DUT the CumulativeEnergyImported attribute. Verify the read is successful and that the value is greater than the value measured in step 4a."),
TestStep("5a", "TH reads from the DUT the CumulativeEnergyImported attribute",
"Verify the read is successful and that the value is greater than the value measured in step 4a."),
TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Stop Fake Readings Test Event."),
]

Expand Down
12 changes: 8 additions & 4 deletions src/python_testing/TC_EEM_2_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ def pics_TC_EEM_2_3(self):

def steps_TC_EEM_2_3(self) -> list[TestStep]:
steps = [
TestStep("1", "Commissioning, already done", is_commissioning=True),
TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster. Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"),
TestStep("1", "Commissioning, already done",
is_commissioning=True),
TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster",
"Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"),
TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Start Fake Generator Test 3kW Event"),
TestStep("4", "Wait 6 seconds"),
TestStep("4a", "TH reads from the DUT the CumulativeEnergyExported attribute. Verify the read is successful and note the value read."),
TestStep("4a", "TH reads from the DUT the CumulativeEnergyExported attribute",
"Verify the read is successful and note the value read."),
TestStep("5", "Wait 6 seconds"),
TestStep("5a", "TH reads from the DUT the CumulativeEnergyExported attribute. Verify the read is successful and that the value is greater than the value measured in step 4a."),
TestStep("5a", "TH reads from the DUT the CumulativeEnergyExported attribute",
"Verify the read is successful and that the value is greater than the value measured in step 4a."),
TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Stop Fake Readings Test Event."),
]

Expand Down
12 changes: 8 additions & 4 deletions src/python_testing/TC_EEM_2_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ def pics_TC_EEM_2_4(self):

def steps_TC_EEM_2_4(self) -> list[TestStep]:
steps = [
TestStep("1", "Commissioning, already done", is_commissioning=True),
TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster. Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"),
TestStep("1", "Commissioning, already done",
is_commissioning=True),
TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster",
"Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"),
TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Start Fake Load Test 1kW Event"),
TestStep("4", "Wait 3 seconds"),
TestStep("4a", "TH reads from the DUT the PeriodicEnergyImported attribute. Verify the read is successful and note the value read."),
TestStep("4a", "TH reads from the DUT the PeriodicEnergyImported attribute",
"Verify the read is successful and note the value read."),
TestStep("5", "Wait 3 seconds"),
TestStep("5a", "TH reads from the DUT the PeriodicEnergyImported attribute. Verify the read is successful and that the value read has to be different from value measure in step 4a."),
TestStep("5a", "TH reads from the DUT the PeriodicEnergyImported attribute",
"Verify the read is successful and that the value read has to be different from value measure in step 4a."),
TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Stop Fake Readings Test Event."),
]

Expand Down
12 changes: 8 additions & 4 deletions src/python_testing/TC_EEM_2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ def pics_TC_EEM_2_5(self):

def steps_TC_EEM_2_5(self) -> list[TestStep]:
steps = [
TestStep("1", "Commissioning, already done", is_commissioning=True),
TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster. Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"),
TestStep("1", "Commissioning, already done",
is_commissioning=True),
TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster",
"Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"),
TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Start Fake Generator Test 3kW Event"),
TestStep("4", "Wait 6 seconds"),
TestStep("4a", "TH reads from the DUT the PeriodicEnergyExported attribute. Verify the read is successful and note the value read."),
TestStep("4a", "TH reads from the DUT the PeriodicEnergyExported attribute",
"Verify the read is successful and note the value read."),
TestStep("5", "Wait 6 seconds"),
TestStep("5a", "TH reads from the DUT the PeriodicEnergyExported attribute. Verify the read is successful and that the value read has to be different from value measure in step 4a."),
TestStep("5a", "TH reads from the DUT the PeriodicEnergyExported attribute",
"Verify the read is successful and that the value read has to be different from value measure in step 4a."),
TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Stop Fake Readings Test Event."),
]

Expand Down
Loading

0 comments on commit 7800000

Please sign in to comment.