Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Mar 16, 2022
1 parent 2ab3bca commit b0bfa7e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion scripts/tests/run_python_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def main(app: str, factoryreset: bool, app_params: str, script: str, script_args
app_process = subprocess.Popen(
app_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0)
DumpProgramOutputToQueue(
log_cooking_threads, "\33[34mAPP \33[0m", test_script_process, log_queue)
log_cooking_threads, "\33[34mAPP \33[0m", app_process, log_queue)

script_command = ["/usr/bin/env", "python3", script,
'--log-format', '%(message)s'] + [v for v in script_args]
Expand Down
7 changes: 6 additions & 1 deletion src/controller/python/test/test_scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
# limitations under the License.
#

import asyncio
from dataclasses import dataclass
from inspect import Attribute
import inspect
from typing import Any
import typing
from chip import ChipDeviceCtrl
Expand Down Expand Up @@ -97,7 +99,10 @@ def test_case(func):

def CheckEnableBeforeRun(*args, **kwargs):
if TestIsEnabled(test_name=test_name):
func(*args, **kwargs)
return func(*args, **kwargs)
elif inspect.iscoroutinefunction(func):
# noop, so users can use await as usual
return asyncio.sleep(0)
return CheckEnableBeforeRun


Expand Down
53 changes: 26 additions & 27 deletions src/controller/python/test/test_scripts/network_commissioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,33 +298,32 @@ async def test_thread(self, endpointId):

@base.test_case
async def Test(self):
try:
clusters = await self._devCtrl.ReadAttribute(nodeid=self._nodeid, attributes=[(Clusters.Descriptor.Attributes.ServerList)], returnClusterObject=True)
if Clusters.NetworkCommissioning.id not in clusters[0][Clusters.Descriptor].serverList:
clusters = await self._devCtrl.ReadAttribute(nodeid=self._nodeid, attributes=[(Clusters.Descriptor.Attributes.ServerList)], returnClusterObject=True)
if Clusters.NetworkCommissioning.id not in clusters[0][Clusters.Descriptor].serverList:
logger.info(
f"Network commissioning cluster {endpoint} is not enabled on this device.")
return
endpoints = await self._devCtrl.ReadAttribute(nodeid=self._nodeid, attributes=[(Clusters.NetworkCommissioning.Attributes.FeatureMap)], returnClusterObject=True)
logger.info(endpoints)
for endpoint, obj in endpoints.items():
clus = obj[Clusters.NetworkCommissioning]
if clus.featureMap == WIFI_NETWORK_FEATURE_MAP:
logger.info(
f"Network commissioning cluster {endpoint} is not enabled on this device.")
return True
endpoints = await self._devCtrl.ReadAttribute(nodeid=self._nodeid, attributes=[(Clusters.NetworkCommissioning.Attributes.FeatureMap)], returnClusterObject=True)
logger.info(endpoints)
for endpoint, obj in endpoints.items():
clus = obj[Clusters.NetworkCommissioning]
if clus.featureMap == WIFI_NETWORK_FEATURE_MAP:
logger.info(
f"Endpoint {endpoint} is configured as WiFi network, run WiFi commissioning test.")
await self.test_negative(endpoint)
await self.test_wifi(endpoint)
elif clus.featureMap == THREAD_NETWORK_FEATURE_MAP:
logger.info(
f"Endpoint {endpoint} is configured as Thread network, run Thread commissioning test.")
await self.test_negative(endpoint)
await self.test_thread(endpoint)
else:
logger.info(
f"Skip endpoint {endpoint} with featureMap {clus.featureMap}")
except Exception as ex:
logger.exception(ex)
return False
return True
f"Endpoint {endpoint} is configured as WiFi network, run WiFi commissioning test.")
await self.test_negative(endpoint)
await self.test_wifi(endpoint)
elif clus.featureMap == THREAD_NETWORK_FEATURE_MAP:
logger.info(
f"Endpoint {endpoint} is configured as Thread network, run Thread commissioning test.")
await self.test_negative(endpoint)
await self.test_thread(endpoint)
else:
logger.info(
f"Skip endpoint {endpoint} with featureMap {clus.featureMap}")

async def run(self):
return await self.Test()
try:
await self.Test()
return True
except Exception as ex:
return False

0 comments on commit b0bfa7e

Please sign in to comment.