Skip to content

Commit

Permalink
Merge branch 'master' into targeted_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andreilitvin committed Jan 24, 2023
2 parents c1941a1 + 743b9ca commit 0ab80d1
Show file tree
Hide file tree
Showing 19 changed files with 866 additions and 870 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
--bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \
"
- name: Run Tests using chip-repl
timeout-minutes: 5
timeout-minutes: 10
run: |
./scripts/run_in_build_env.sh \
"./scripts/tests/run_test_suite.py \
Expand Down
7 changes: 3 additions & 4 deletions examples/contact-sensor-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <DeviceInfoProviderImpl.h>
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
Expand Down Expand Up @@ -306,8 +305,8 @@ void AppTask::UpdateClusterStateInternal(intptr_t arg)
ChipLogProgress(NotSpecified, "emberAfWriteAttribute : %d", newValue);

// write the new boolean state value
EmberAfStatus status = emberAfWriteAttribute(1, ZCL_BOOLEAN_STATE_CLUSTER_ID, ZCL_STATE_VALUE_ATTRIBUTE_ID,
(uint8_t *) &newValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE);
EmberAfStatus status = emberAfWriteAttribute(1, Clusters::BooleanState::Id, ZCL_STATE_VALUE_ATTRIBUTE_ID, (uint8_t *) &newValue,
ZCL_BOOLEAN_ATTRIBUTE_TYPE);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
ChipLogError(NotSpecified, "ERR: updating boolean status value %x", status);
Expand Down Expand Up @@ -517,7 +516,7 @@ void AppTask::UpdateDeviceStateInternal(intptr_t arg)
bool stateValueAttrValue = 0;

/* get boolean state attribute value */
(void) emberAfReadAttribute(1, ZCL_BOOLEAN_STATE_CLUSTER_ID, ZCL_STATE_VALUE_ATTRIBUTE_ID, (uint8_t *) &stateValueAttrValue, 1);
(void) emberAfReadAttribute(1, Clusters::BooleanState::Id, ZCL_STATE_VALUE_ATTRIBUTE_ID, (uint8_t *) &stateValueAttrValue, 1);

ChipLogProgress(NotSpecified, "emberAfReadAttribute : %d", stateValueAttrValue);
sContactSensorLED.Set(stateValueAttrValue);
Expand Down
5 changes: 3 additions & 2 deletions examples/lock-app/linux/include/LockEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct YearDayScheduleInfo;
struct HolidayScheduleInfo;

static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE = 20;
static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_TYPES = 6;

class LockEndpoint
{
Expand All @@ -48,7 +49,7 @@ class LockEndpoint
uint8_t numberOfHolidaySchedules) :
mEndpointId{ endpointId },
mLockState{ DlLockState::kLocked }, mDoorState{ DoorStateEnum::kDoorClosed }, mLockUsers(numberOfLockUsersSupported),
mLockCredentials(numberOfCredentialsSupported + 1),
mLockCredentials(DOOR_LOCK_CREDENTIAL_INFO_MAX_TYPES, std::vector<LockCredentialInfo>(numberOfCredentialsSupported + 1)),
mWeekDaySchedules(numberOfLockUsersSupported, std::vector<WeekDaysScheduleInfo>(weekDaySchedulesPerUser)),
mYearDaySchedules(numberOfLockUsersSupported, std::vector<YearDayScheduleInfo>(yearDaySchedulesPerUser)),
mHolidaySchedules(numberOfHolidaySchedules)
Expand Down Expand Up @@ -109,7 +110,7 @@ class LockEndpoint
// This is very naive implementation of users/credentials/schedules database and by no means the best practice. Proper storage
// of those items is out of scope of this example.
std::vector<LockUserInfo> mLockUsers;
std::vector<LockCredentialInfo> mLockCredentials;
std::vector<std::vector<LockCredentialInfo>> mLockCredentials;
std::vector<std::vector<WeekDaysScheduleInfo>> mWeekDaySchedules;
std::vector<std::vector<YearDayScheduleInfo>> mYearDaySchedules;
std::vector<HolidayScheduleInfo> mHolidaySchedules;
Expand Down
30 changes: 22 additions & 8 deletions examples/lock-app/linux/src/LockEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,20 @@ bool LockEndpoint::GetCredential(uint16_t credentialIndex, CredentialTypeEnum cr
ChipLogProgress(Zcl, "Lock App: LockEndpoint::GetCredential [endpoint=%d,credentialIndex=%u,credentialType=%u]", mEndpointId,
credentialIndex, to_underlying(credentialType));

if (credentialIndex >= mLockCredentials.size() ||
if (to_underlying(credentialType) >= mLockCredentials.size())
{
ChipLogError(Zcl, "Cannot get the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex);
return false;
}

if (credentialIndex >= mLockCredentials.at(to_underlying(credentialType)).size() ||
(0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType))
{
ChipLogError(Zcl, "Cannot get the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex);
return false;
}

const auto & credentialInStorage = mLockCredentials[credentialIndex];
const auto & credentialInStorage = mLockCredentials[to_underlying(credentialType)][credentialIndex];

credential.status = credentialInStorage.status;
if (DlCredentialStatus::kAvailable == credential.status)
Expand Down Expand Up @@ -206,14 +212,21 @@ bool LockEndpoint::SetCredential(uint16_t credentialIndex, chip::FabricIndex cre
mEndpointId, credentialIndex, to_underlying(credentialStatus), to_underlying(credentialType),
static_cast<unsigned int>(credentialData.size()), creator, modifier);

if (credentialIndex >= mLockCredentials.size() ||
if (to_underlying(credentialType) >= mLockCredentials.capacity())
{
ChipLogError(Zcl, "Cannot set the credential - type out of range [endpoint=%d,type=%d]", mEndpointId,
to_underlying(credentialType));
return false;
}

if (credentialIndex >= mLockCredentials.at(to_underlying(credentialType)).size() ||
(0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType))
{
ChipLogError(Zcl, "Cannot set the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex);
return false;
}

auto & credentialInStorage = mLockCredentials[credentialIndex];
auto & credentialInStorage = mLockCredentials[to_underlying(credentialType)][credentialIndex];
if (credentialData.size() > DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE)
{
ChipLogError(Zcl,
Expand Down Expand Up @@ -391,11 +404,12 @@ bool LockEndpoint::setLockState(DlLockState lockState, const Optional<chip::Byte
}

// Find the credential so we can make sure it is not absent right away
auto credential = std::find_if(mLockCredentials.begin(), mLockCredentials.end(), [&pin](const LockCredentialInfo & c) {
return (c.credentialType == CredentialTypeEnum::kPin && c.status != DlCredentialStatus::kAvailable) &&
auto & pinCredentials = mLockCredentials[to_underlying(CredentialTypeEnum::kPin)];
auto credential = std::find_if(pinCredentials.begin(), pinCredentials.end(), [&pin](const LockCredentialInfo & c) {
return (c.status != DlCredentialStatus::kAvailable) &&
chip::ByteSpan{ c.credentialData, c.credentialDataSize }.data_equal(pin.Value());
});
if (credential == mLockCredentials.end())
if (credential == pinCredentials.end())
{
ChipLogDetail(Zcl,
"Lock App: specified PIN code was not found in the database, ignoring command to set lock state to \"%s\" "
Expand All @@ -407,7 +421,7 @@ bool LockEndpoint::setLockState(DlLockState lockState, const Optional<chip::Byte
}

// Find a user that correspond to this credential
auto credentialIndex = static_cast<unsigned>(credential - mLockCredentials.begin());
auto credentialIndex = static_cast<unsigned>(credential - pinCredentials.begin());
auto user = std::find_if(mLockUsers.begin(), mLockUsers.end(), [credential, credentialIndex](const LockUserInfo & u) {
return std::any_of(u.credentials.begin(), u.credentials.end(), [&credential, credentialIndex](const CredentialStruct & c) {
return c.CredentialIndex == credentialIndex && c.CredentialType == to_underlying(credential->credentialType);
Expand Down
6 changes: 3 additions & 3 deletions integrations/cloudbuild/build-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ steps:
- "--init"
- "--recursive"
id: Submodules
- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
Expand All @@ -21,7 +21,7 @@ steps:
path: /pwenv
timeout: 900s

- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
Expand Down Expand Up @@ -76,7 +76,7 @@ steps:
--target k32w-shell
build
--create-archives /workspace/artifacts/
- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
Expand Down
6 changes: 3 additions & 3 deletions integrations/cloudbuild/chef.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
steps:
- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
Expand All @@ -12,7 +12,7 @@ steps:
path: /pwenv
timeout: 2700s

- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
Expand All @@ -26,7 +26,7 @@ steps:
- name: pwenv
path: /pwenv

- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
Expand Down
14 changes: 7 additions & 7 deletions integrations/cloudbuild/smoke-test.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
steps:
- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
entrypoint: "bash"
args:
- "-c"
- |
git config --global --add safe.directory "*"
git submodule update --init --recursive
id: Submodules
- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
Expand All @@ -22,7 +22,7 @@ steps:
path: /pwenv
timeout: 900s

- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
id: ESP32
env:
- PW_ENVIRONMENT_ROOT=/pwenv
Expand All @@ -40,7 +40,7 @@ steps:
volumes:
- name: pwenv
path: /pwenv
- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
id: NRFConnect
env:
- PW_ENVIRONMENT_ROOT=/pwenv
Expand All @@ -61,7 +61,7 @@ steps:
- name: pwenv
path: /pwenv

- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
id: EFR32
env:
- PW_ENVIRONMENT_ROOT=/pwenv
Expand All @@ -83,7 +83,7 @@ steps:
- name: pwenv
path: /pwenv

- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
id: Linux
env:
- PW_ENVIRONMENT_ROOT=/pwenv
Expand Down Expand Up @@ -141,7 +141,7 @@ steps:
- name: pwenv
path: /pwenv

- name: "connectedhomeip/chip-build-vscode:0.6.32"
- name: "connectedhomeip/chip-build-vscode:0.6.34"
id: Android
env:
- PW_ENVIRONMENT_ROOT=/pwenv
Expand Down
5 changes: 5 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ def is_fabric_scoped(self, target) -> bool:
return bool(target.qualities & StructQuality.FABRIC_SCOPED)
return False

def is_nullable(self, target) -> bool:
if hasattr(target, 'qualities'):
return bool(target.qualities & FieldQuality.NULLABLE)
return False

def __get_by_name(self, cluster_name: str, target_name: str, target_type: _ItemType):
if not cluster_name or not target_name:
return None
Expand Down
2 changes: 2 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ def __init__(self, test: _TestStepWithPlaceholders, runtime_config_variable_stor
self.response = copy.deepcopy(test.response_with_placeholders)
self._update_placeholder_values(self.arguments)
self._update_placeholder_values(self.response)
self._test.node_id = self._config_variable_substitution(
self._test.node_id)
test.update_arguments(self.arguments)
test.update_response(self.response)

Expand Down
33 changes: 33 additions & 0 deletions scripts/py_matter_yamltests/test_spec_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@
</configurator>
'''

source_response_with_nullable = '''<?xml version="1.0"?>
<configurator>
<cluster>
<name>Test</name>
<code>0x1234</code>
<command source="server" code="0x0" name="TestCommandResponse">
<arg name="arg1" type="int8u"/>
<arg name="arg2" type="int8u" isNullable="true"/>
</command>
</cluster>
</configurator>
'''

source_attribute = '''<?xml version="1.0"?>
<configurator>
<global>
Expand Down Expand Up @@ -184,6 +199,24 @@ def test_response_name(self):
self.assertEqual(definitions.get_response_name(
0x1234, 0x0), 'TestCommandResponse')

def test_response_name_with_nullable(self):
definitions = SpecDefinitions(
[ParseSource(source=io.StringIO(source_response_with_nullable), name='source_response_with_nullable')])
cluster_name = 'Test'
response_name = 'TestCommandResponse'

self.assertEqual(definitions.get_cluster_name(0x1234), cluster_name)
self.assertEqual(definitions.get_response_name(
0x1234, 0x0), response_name)

response = definitions.get_response_by_name(
cluster_name, response_name)
for field in response.fields:
if field.name == 'arg1':
self.assertFalse(definitions.is_nullable(field))
else:
self.assertTrue(definitions.is_nullable(field))

def test_attribute_name(self):
definitions = SpecDefinitions(
[ParseSource(source=io.StringIO(source_attribute), name='source_attribute')])
Expand Down
Loading

0 comments on commit 0ab80d1

Please sign in to comment.