-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add matter_yamlclusters with a set of default clusters for running so…
…me of the yaml tests
- Loading branch information
1 parent
044297d
commit 0005dfc
Showing
11 changed files
with
297 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
import("//build_overrides/chip.gni") | ||
|
||
import("//build_overrides/pigweed.gni") | ||
import("$dir_pw_build/python.gni") | ||
|
||
pw_python_package("matter_yamlclusters") { | ||
setup = [ | ||
"setup.py", | ||
"setup.cfg", | ||
"pyproject.toml", | ||
] | ||
|
||
sources = [ | ||
"matter_yamlclusters/__init__.py", | ||
"matter_yamlclusters/clusters.py", | ||
"matter_yamlclusters/cluster/delay_commands.py", | ||
"matter_yamlclusters/cluster/log_commands.py", | ||
"matter_yamlclusters/cluster/system_commands.py", | ||
] | ||
|
||
python_deps = [ "${chip_root}/scripts/py_matter_yamltests:matter_yamltests" ] | ||
|
||
# TODO: at a future time consider enabling all (* or missing) here to get | ||
# pylint checking these files | ||
static_analysis = [] | ||
} |
Empty file.
Empty file.
33 changes: 33 additions & 0 deletions
33
scripts/py_matter_yamlclusters/matter_yamlclusters/cluster/delay_commands.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License'); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an 'AS IS' BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import sys | ||
import time | ||
|
||
from matter_yamltests.test_cluster import TestCluster | ||
|
||
|
||
class DelayCommands(TestCluster): | ||
name = 'DelayCommands' | ||
|
||
async def WaitForMs(self, request): | ||
duration_in_ms = 0 | ||
|
||
for argument in request.arguments['values']: | ||
if argument['name'] == 'ms': | ||
duration_in_ms = argument['value'] | ||
|
||
sys.stdout.flush() | ||
time.sleep(duration_in_ms / 1000) |
26 changes: 26 additions & 0 deletions
26
scripts/py_matter_yamlclusters/matter_yamlclusters/cluster/log_commands.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License'); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an 'AS IS' BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from matter_yamltests.test_cluster import TestCluster | ||
|
||
|
||
class LogCommands(TestCluster): | ||
name = 'LogCommands' | ||
|
||
async def UserPrompt(self, request): | ||
pass | ||
|
||
async def Log(self, request): | ||
pass |
106 changes: 106 additions & 0 deletions
106
scripts/py_matter_yamlclusters/matter_yamlclusters/cluster/system_commands.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License'); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an 'AS IS' BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import sys | ||
import xmlrpc.client | ||
|
||
from matter_yamltests.test_cluster import TestCluster | ||
|
||
DEFAULT_KEY = 'default' | ||
IP = '127.0.0.1' | ||
PORT = 9000 | ||
|
||
if sys.platform == 'linux': | ||
IP = '10.10.10.5' | ||
|
||
|
||
def make_url(): | ||
return 'http://' + IP + ':' + str(PORT) + '/' | ||
|
||
|
||
def get_register_key(request): | ||
if request.arguments: | ||
values = request.arguments['values'] | ||
for item in values: | ||
name = item['name'] | ||
value = item['value'] | ||
if name == 'registerKey': | ||
return value | ||
|
||
return DEFAULT_KEY | ||
|
||
|
||
def get_options(request): | ||
options = [] | ||
|
||
if request.arguments: | ||
values = request.arguments['values'] | ||
for item in values: | ||
name = item['name'] | ||
value = item['value'] | ||
|
||
if name == 'discriminator': | ||
options.append('--discriminator') | ||
options.append(str(value)) | ||
elif name == 'port': | ||
options.append('--secured-device-port') | ||
options.append(str(value)) | ||
elif name == 'kvs': | ||
options.append('--KVS') | ||
options.append(str(value)) | ||
elif name == 'minCommissioningTimeout': | ||
options.append('--min_commissioning_timeout') | ||
options.append(str(value)) | ||
elif name == 'filepath': | ||
options.append('--filepath') | ||
options.append(str(value)) | ||
elif name == 'otaDownloadPath': | ||
options.append('--otaDownloadPath') | ||
options.append(str(value)) | ||
elif name == 'registerKey': | ||
pass | ||
else: | ||
raise KeyError(f'Unknown key: {name}') | ||
|
||
return options | ||
|
||
|
||
class SystemCommands(TestCluster): | ||
name = 'SystemCommands' | ||
|
||
async def Start(self, request): | ||
register_key = get_register_key(request) | ||
options = get_options(request) | ||
|
||
with xmlrpc.client.ServerProxy(make_url(), allow_none=True) as proxy: | ||
proxy.start(register_key, options) | ||
|
||
async def Stop(self, request): | ||
register_key = get_register_key(request) | ||
|
||
with xmlrpc.client.ServerProxy(make_url(), allow_none=True) as proxy: | ||
proxy.stop(register_key) | ||
|
||
async def Reboot(self, request): | ||
register_key = get_register_key(request) | ||
|
||
with xmlrpc.client.ServerProxy(make_url(), allow_none=True) as proxy: | ||
proxy.reboot(register_key) | ||
|
||
async def FactoryReset(self, request): | ||
register_key = get_register_key(request) | ||
|
||
with xmlrpc.client.ServerProxy(make_url(), allow_none=True) as proxy: | ||
proxy.factoryReset(register_key) |
26 changes: 26 additions & 0 deletions
26
scripts/py_matter_yamlclusters/matter_yamlclusters/clusters.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License'); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an 'AS IS' BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from matter_yamlclusters.cluster.delay_commands import DelayCommands | ||
from matter_yamlclusters.cluster.log_commands import LogCommands | ||
from matter_yamlclusters.cluster.system_commands import SystemCommands | ||
|
||
|
||
def get_default_clusters(): | ||
return [ | ||
DelayCommands(), | ||
LogCommands(), | ||
SystemCommands() | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
[build-system] | ||
requires = ['setuptools', 'wheel'] | ||
build-backend = 'setuptools.build_meta' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
[metadata] | ||
name = matter_yamlclusters | ||
version = 0.0.1 | ||
author = Project CHIP Authors | ||
description = Implement YAML test clusters | ||
|
||
[options] | ||
packages = find: | ||
|
||
zip_safe = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
"""The matter_yamlclusters package.""" | ||
|
||
import setuptools # type: ignore | ||
|
||
setuptools.setup() # Package definition in setup.cfg |