Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio-amjr committed Sep 6, 2024
1 parent 17b1a38 commit a3adbd1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion scripts/py_matter_yamltests/matter_yamltests/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def step_skipped(self, name: str, expression: str):
"""
pass

def step_start(self, request: TestStep):
def step_start(self, request: TestStep, endpoint: int):
"""
This method is called when the runner starts running a step from the test.
Expand Down
22 changes: 11 additions & 11 deletions src/python_testing/TC_OpstateCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,16 +1250,16 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
self.init_test()

# commission
self.step(1)
self.step(1, endpoint)

# Note that this does a subscribe-all instead of subscribing only to the CountdownTime attribute.
# To-Do: Update the TP to subscribe-all.
self.step(2)
self.step(2, endpoint)
sub_handler = ClusterAttributeChangeAccumulator(cluster)
await sub_handler.start(self.default_controller, self.dut_node_id, endpoint)

if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")):
self.step(3)
self.step(3, endpoint)
self.send_manual_or_pipe_command(name="OperationalStateChange",
device=self.device,
operation="Start")
Expand All @@ -1275,10 +1275,10 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
self.skip_step(3)

sub_handler.reset()
self.step(4)
self.step(4, endpoint)
countdownTime = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime)
if countdownTime is not NullValue:
self.step(5)
self.step(5, endpoint)
logging.info('Test will now collect data for 10 seconds')
time.sleep(10)

Expand All @@ -1289,13 +1289,13 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
else:
self.skip_step(5)

self.step(6)
self.step(6, endpoint)
countdownTime = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime)
attr_value = await self.read_expect_success(
endpoint=endpoint,
attribute=attributes.OperationalState)
if attr_value == cluster.Enums.OperationalStateEnum.kRunning and countdownTime is not NullValue:
self.step(7)
self.step(7, endpoint)
wait_count = 0
while (attr_value != cluster.Enums.OperationalStateEnum.kStopped) and (wait_count < 20):
time.sleep(1)
Expand All @@ -1311,7 +1311,7 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):

sub_handler.reset()
if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")):
self.step(8)
self.step(8, endpoint)
self.send_manual_or_pipe_command(name="OperationalStateChange",
device=self.device,
operation="Start")
Expand All @@ -1326,16 +1326,16 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
else:
self.skip_step(8)

self.step(9)
self.step(9, endpoint)
await self.read_and_expect_value(endpoint=endpoint,
attribute=attributes.OperationalState,
expected_value=cluster.Enums.OperationalStateEnum.kRunning)

sub_handler.reset()
self.step(10)
self.step(10, endpoint)
countdownTime = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime)
if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_PAUSED")) and countdownTime is not NullValue:
self.step(11)
self.step(11, endpoint)
self.send_manual_or_pipe_command(name="OperationalStateChange",
device=self.device,
operation="Pause")
Expand Down
15 changes: 10 additions & 5 deletions src/python_testing/matter_testing_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ def step_skipped(self, name: str, expression: str):
# TODO: Do we really need the expression as a string? We can evaluate this in code very easily
logging.info(f'\t\t**** Skipping: {name}')

def step_start(self, name: str):
# The way I'm calling this, the name is already includes the step number, but it seems like it might be good to separate these
logging.info(f'\t\t***** Test Step {name}')
def step_start(self, name: str, endpoint: int):
# TODO: The way I'm calling this, the name is already includes the step number, but it seems like it might be good to separate these
logging.info(f'\t\t***** Test Step {name} started with endpoint {endpoint}')

def step_success(self, logger, logs, duration: int, request):
pass
Expand Down Expand Up @@ -1451,7 +1451,7 @@ def skip_all_remaining_steps(self, starting_step_number):
for step in remaining:
self.skip_step(step.test_plan_number)

def step(self, step: typing.Union[int, str]):
def step(self, step: typing.Union[int, str], endpoint: Optional[int] = None):
test_name = self.current_test_info.name
steps = self.get_test_steps(test_name)

Expand All @@ -1468,7 +1468,12 @@ def step(self, step: typing.Union[int, str]):

# TODO: it seems like the step start should take a number and a name
name = f'{step} : {steps[self.current_step_index].description}'
self.runner_hook.step_start(name=name)
if endpoint is None or not isinstance(endpoint, int):
endpoint = self.matter_test_config.endpoint
logging.info(
f"========= Step {name} started with Endpoint {endpoint} ========="
)
self.runner_hook.step_start(name=name, endpoint=endpoint)
else:
self.print_step(step, steps[self.current_step_index].description)

Expand Down

0 comments on commit a3adbd1

Please sign in to comment.