Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python framework - write_to_app_pipe updates. #37637

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions src/python_testing/TC_OCC_3_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# --endpoint 1
# --app-pipe /tmp/chip_all_clusters_fifo_
# --bool-arg simulate_occupancy:true
# factory-reset: true
# quiet: true
Expand Down Expand Up @@ -91,25 +92,9 @@ def pics_TC_OCC_3_1(self) -> list[str]:
]
return pics

# Sends and out-of-band command to the all-clusters-app
def write_to_app_pipe(self, command):
# CI app pipe id creation
self.app_pipe = "/tmp/chip_all_clusters_fifo_"
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when using named pipe")
self.app_pipe = self.app_pipe + str(app_pid)

with open(self.app_pipe, "w") as app_pipe:
app_pipe.write(command + "\n")
# Delay for pipe command to be processed (otherwise tests are flaky)
time.sleep(0.001)

@async_test_body
async def test_TC_OCC_3_1(self):
hold_time = 10 if not self.is_ci else 1.0 # 10 seconds for occupancy state hold time

self.step(1) # Commissioning already done

self.step(2)
Expand All @@ -133,7 +118,7 @@ async def test_TC_OCC_3_1(self):

if self.is_ci:
# CI call to trigger unoccupied.
self.write_to_app_pipe('{"Name":"SetOccupancy", "EndpointId": 1, "Occupancy": 0}')
self.write_to_app_pipe({"Name": "SetOccupancy", "EndpointId": 1, "Occupancy": 0})
else:
self.wait_for_user_input(
prompt_msg="Type any letter and press ENTER after the sensor occupancy is unoccupied state (occupancy attribute = 0)")
Expand All @@ -157,7 +142,7 @@ async def test_TC_OCC_3_1(self):
self.step("5a")
# CI call to trigger on
if self.is_ci:
self.write_to_app_pipe('{"Name":"SetOccupancy", "EndpointId": 1, "Occupancy": 1}')
self.write_to_app_pipe({"Name": "SetOccupancy", "EndpointId": 1, "Occupancy": 1})
else:
# Trigger occupancy sensor to change Occupancy attribute value to 1 => TESTER ACTION on DUT
self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after a sensor occupancy is triggered.")
Expand All @@ -183,7 +168,7 @@ async def test_TC_OCC_3_1(self):
self.step(6)
if self.is_ci:
# CI call to trigger unoccupied.
self.write_to_app_pipe('{"Name":"SetOccupancy", "EndpointId": 1, "Occupancy": 0}')
self.write_to_app_pipe({"Name": "SetOccupancy", "EndpointId": 1, "Occupancy": 0})

if has_hold_time:
time.sleep(hold_time + 2.0) # add some extra 2 seconds to ensure hold time has passed.
Expand Down
21 changes: 3 additions & 18 deletions src/python_testing/TC_OCC_3_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# --passcode 20202021
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# --app-pipe /tmp/chip_all_clusters_fifo_
# --endpoint 1
# --bool-arg simulate_occupancy:true
# factory-reset: true
Expand All @@ -41,7 +42,6 @@
# [TC-OCC-3.2] test precedure step 3a, 3c

import logging
import time

import chip.clusters as Clusters
from chip.testing.matter_testing import (ClusterAttributeChangeAccumulator, MatterBaseTest, TestStep, async_test_body,
Expand Down Expand Up @@ -83,21 +83,6 @@ def pics_TC_OCC_3_2(self) -> list[str]:
]
return pics

# Sends and out-of-band command to the all-clusters-app
def write_to_app_pipe(self, command):
# CI app pipe id creation
self.app_pipe = "/tmp/chip_all_clusters_fifo_"
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when using named pipe")
self.app_pipe = self.app_pipe + str(app_pid)

with open(self.app_pipe, "w") as app_pipe:
app_pipe.write(command + "\n")
# Delay for pipe command to be processed (otherwise tests are flaky)
time.sleep(0.001)

@async_test_body
async def test_TC_OCC_3_2(self):
endpoint_id = self.get_endpoint()
Expand Down Expand Up @@ -136,7 +121,7 @@ async def test_TC_OCC_3_2(self):
self.step("3a")
# CI call to trigger off
if self.is_ci:
self.write_to_app_pipe('{"Name":"SetOccupancy", "EndpointId": 1, "Occupancy": 0}')
self.write_to_app_pipe({"Name": "SetOccupancy", "EndpointId": 1, "Occupancy": 0})
else:
self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after DUT goes back to unoccupied state.")

Expand All @@ -150,7 +135,7 @@ async def test_TC_OCC_3_2(self):

# CI call to trigger on
if self.is_ci:
self.write_to_app_pipe('{"Name":"SetOccupancy", "EndpointId": 1, "Occupancy": 1}')
self.write_to_app_pipe({"Name": "SetOccupancy", "EndpointId": 1, "Occupancy": 1})
else:
self.wait_for_user_input(
prompt_msg="Type any letter and press ENTER after the sensor occupancy is triggered and its occupancy state changed.")
Expand Down
4 changes: 2 additions & 2 deletions src/python_testing/TC_OpstateCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ def init_test(self):
app_pid = get_pid("chip-all-clusters-app")
if app_pid is None:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set")
self.app_pipe = self.app_pipe + str(app_pid)
self.app_pid = app_pid

def send_raw_manual_or_pipe_command(self, command: dict, msg: str):
if self.is_ci:
self.write_to_app_pipe(command)
self.write_to_app_pipe(command, app_pipe_name=self.app_pipe, app_pid=self.app_pid)
time.sleep(0.1)
else:
prompt = msg if msg is not None else "Press Enter when ready."
Expand Down
7 changes: 1 addition & 6 deletions src/python_testing/TC_RVCCLEANM_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# --int-arg PIXIT.RVCCLEANM.MODE_CHANGE_FAIL:1
# --int-arg PIXIT.RVCCLEANM.MODE_CHANGE_OK:2
# --endpoint 1
# --app-pipe /tmp/chip_rvc_fifo_
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
Expand All @@ -57,7 +58,6 @@ def __init__(self, *args):
self.mode_ok = 0
self.mode_fail = 0
self.is_ci = False
self.app_pipe = "/tmp/chip_rvc_fifo_"

async def read_mod_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.RvcCleanMode
Expand Down Expand Up @@ -92,11 +92,6 @@ async def test_TC_RVCCLEANM_2_1(self):
self.mode_ok = self.matter_test_config.global_test_params['PIXIT.RVCCLEANM.MODE_CHANGE_OK']
self.mode_fail = self.matter_test_config.global_test_params['PIXIT.RVCCLEANM.MODE_CHANGE_FAIL']
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set")
self.app_pipe = self.app_pipe + str(app_pid)

asserts.assert_true(self.check_pics("RVCCLEANM.S.A0000"), "RVCCLEANM.S.A0000 must be supported")
asserts.assert_true(self.check_pics("RVCCLEANM.S.A0001"), "RVCCLEANM.S.A0001 must be supported")
Expand Down
7 changes: 1 addition & 6 deletions src/python_testing/TC_RVCCLEANM_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# --discriminator 1234
# --passcode 20202021
# --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values
# --app-pipe /tmp/chip_rvc_fifo_
# --endpoint 1
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
Expand Down Expand Up @@ -63,7 +64,6 @@ def __init__(self, *args):
self.old_clean_mode_dut = 0
self.new_clean_mode_th = 0
self.is_ci = False
self.app_pipe = "/tmp/chip_rvc_fifo_"

async def read_mod_attribute_expect_success(self, cluster, attribute):
return await self.read_single_attribute_check_success(
Expand Down Expand Up @@ -107,11 +107,6 @@ async def test_TC_RVCCLEANM_2_2(self):
self.directmodech_bit_mask = Clusters.RvcCleanMode.Bitmaps.Feature.kDirectModeChange
self.endpoint = self.get_endpoint()
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set.c")
self.app_pipe = self.app_pipe + str(app_pid)

asserts.assert_true(self.check_pics("RVCCLEANM.S"), "RVCCLEANM.S must be supported")
asserts.assert_true(self.check_pics("RVCRUNM.S.A0000"), "RVCRUNM.S.A0000 must be supported")
Expand Down
7 changes: 1 addition & 6 deletions src/python_testing/TC_RVCOPSTATE_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# --passcode 20202021
# --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values
# --endpoint 1
# --app-pipe /tmp/chip_rvc_fifo_
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
Expand All @@ -49,7 +50,6 @@ def __init__(self, *args):
super().__init__(*args)
self.endpoint = None
self.is_ci = False
self.app_pipe = "/tmp/chip_rvc_fifo_"

async def read_mod_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.RvcOperationalState
Expand Down Expand Up @@ -90,11 +90,6 @@ async def test_TC_RVCOPSTATE_2_1(self):
self.endpoint = self.get_endpoint()
asserts.assert_false(self.endpoint is None, "--endpoint <endpoint> must be included on the command line in.")
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set")
self.app_pipe = self.app_pipe + str(app_pid)

cluster = Clusters.RvcOperationalState
attributes = cluster.Attributes
Expand Down
7 changes: 1 addition & 6 deletions src/python_testing/TC_RVCOPSTATE_2_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# --passcode 20202021
# --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values
# --endpoint 1
# --app-pipe /tmp/chip_rvc_fifo_
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
Expand Down Expand Up @@ -99,7 +100,6 @@ def __init__(self, *args):
super().__init__(*args)
self.endpoint = None
self.is_ci = False
self.app_pipe = "/tmp/chip_rvc_fifo_"

async def read_mod_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.RvcOperationalState
Expand Down Expand Up @@ -161,11 +161,6 @@ async def test_TC_RVCOPSTATE_2_3(self):
self.endpoint = self.get_endpoint()
asserts.assert_false(self.endpoint is None, "--endpoint <endpoint> must be included on the command line in.")
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set.c")
self.app_pipe = self.app_pipe + str(app_pid)

asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0003"), "RVCOPSTATE.S.A0003 must be supported")
asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0004"), "RVCOPSTATE.S.A0004 must be supported")
Expand Down
7 changes: 1 addition & 6 deletions src/python_testing/TC_RVCOPSTATE_2_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# --passcode 20202021
# --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values
# --endpoint 1
# --app-pipe /tmp/chip_rvc_fifo_
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
Expand Down Expand Up @@ -64,7 +65,6 @@ def __init__(self, *args):
super().__init__(*args)
self.endpoint = None
self.is_ci = False
self.app_pipe = "/tmp/chip_rvc_fifo_"

async def read_mod_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.RvcOperationalState
Expand Down Expand Up @@ -106,11 +106,6 @@ async def test_TC_RVCOPSTATE_2_4(self):
self.endpoint = self.get_endpoint()
asserts.assert_false(self.endpoint is None, "--endpoint <endpoint> must be included on the command line in.")
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set.c")
self.app_pipe = self.app_pipe + str(app_pid)

asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0004"), "RVCOPSTATE.S.A0004 must be supported")
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Tx"), "RVCOPSTATE.S.C04.Tx must be supported")
Expand Down
7 changes: 1 addition & 6 deletions src/python_testing/TC_RVCRUNM_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# --endpoint 1
# --int-arg PIXIT.RVCRUNM.MODE_CHANGE_OK:0
# --int-arg PIXIT.RVCRUNM.MODE_CHANGE_FAIL:2
# --app-pipe /tmp/chip_rvc_fifo_
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
Expand All @@ -58,7 +59,6 @@ def __init__(self, *args):
self.mode_ok = 0
self.mode_fail = 0
self.is_ci = False
self.app_pipe = "/tmp/chip_rvc_fifo_"

async def read_mod_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.RvcRunMode
Expand Down Expand Up @@ -87,11 +87,6 @@ async def test_TC_RVCRUNM_2_1(self):
self.mode_ok = self.matter_test_config.global_test_params['PIXIT.RVCRUNM.MODE_CHANGE_OK']
self.mode_fail = self.matter_test_config.global_test_params['PIXIT.RVCRUNM.MODE_CHANGE_FAIL']
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set.c")
self.app_pipe = self.app_pipe + str(app_pid)

asserts.assert_true(self.check_pics("RVCRUNM.S.A0000"), "RVCRUNM.S.A0000 must be supported")
asserts.assert_true(self.check_pics("RVCRUNM.S.A0001"), "RVCRUNM.S.A0001 must be supported")
Expand Down
7 changes: 1 addition & 6 deletions src/python_testing/TC_RVCRUNM_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# --discriminator 1234
# --passcode 20202021
# --endpoint 1
# --app-pipe /tmp/chip_rvc_fifo_
# --int-arg PIXIT.RVCRUNM.MODE_A:1
# --int-arg PIXIT.RVCRUNM.MODE_B:2
# --trace-to json:${TRACE_TEST_JSON}.json
Expand Down Expand Up @@ -84,7 +85,6 @@ def __init__(self, *args):
self.supported_run_modes_dut = []
self.idle_mode_dut = 0
self.is_ci = False
self.app_pipe = "/tmp/chip_rvc_fifo_"

async def read_mod_attribute_expect_success(self, cluster, attribute):
return await self.read_single_attribute_check_success(
Expand Down Expand Up @@ -138,11 +138,6 @@ async def test_TC_RVCRUNM_2_2(self):
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
self.mode_a = self.matter_test_config.global_test_params['PIXIT.RVCRUNM.MODE_A']
self.mode_b = self.matter_test_config.global_test_params['PIXIT.RVCRUNM.MODE_B']
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set.c")
self.app_pipe = self.app_pipe + str(app_pid)

asserts.assert_true(self.check_pics("RVCRUNM.S"), "RVCRUNM.S must be supported")
# I think that the following PICS should be listed in the preconditions section in the test plan as if either
Expand Down
8 changes: 1 addition & 7 deletions src/python_testing/TC_SEAR_1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# --passcode 20202021
# --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values
# --endpoint 1
# --app-pipe /tmp/chip_rvc_fifo_
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# factory-reset: true
Expand All @@ -50,7 +51,6 @@ def __init__(self, *args):
super().__init__(*args)
self.endpoint = None
self.is_ci = False
self.app_pipe = "/tmp/chip_rvc_fifo_"
self.mapid_list = []

# this must be kept in sync with the definitions from the Common Landmark Semantic Tag Namespace
Expand Down Expand Up @@ -207,12 +207,6 @@ async def test_TC_SEAR_1_2(self):
self.endpoint = self.get_endpoint(default=1)
asserts.assert_false(self.endpoint is None, "--endpoint <endpoint> must be included on the command line in.")
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set")
self.app_pipe = self.app_pipe + str(app_pid)

self.print_step(1, "Commissioning, already done")

# Ensure that the device is in the correct state
Expand Down
8 changes: 1 addition & 7 deletions src/python_testing/TC_SEAR_1_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# --passcode 20202021
# --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values
# --endpoint 1
# --app-pipe /tmp/chip_rvc_fifo_
# --json-arg PIXIT.SEAR.VALID_AREAS:'[7, 1234567]'
# --trace-to json:${TRACE_TEST_JSON}.json
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
Expand All @@ -50,7 +51,6 @@ def __init__(self, *args):
super().__init__(*args)
self.endpoint = None
self.is_ci = False
self.app_pipe = "/tmp/chip_rvc_fifo_"

async def read_sear_attribute_expect_success(self, endpoint, attribute):
cluster = Clusters.Objects.ServiceArea
Expand Down Expand Up @@ -91,12 +91,6 @@ async def test_TC_SEAR_1_3(self):
self.endpoint = self.get_endpoint()
asserts.assert_false(self.endpoint is None, "--endpoint <endpoint> must be included on the command line in.")
self.is_ci = self.check_pics("PICS_SDK_CI_ONLY")
if self.is_ci:
app_pid = self.matter_test_config.app_pid
if app_pid == 0:
asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set")
self.app_pipe = self.app_pipe + str(app_pid)

self.print_step(1, "Commissioning, already done")

# Ensure that the device is in the correct state
Expand Down
Loading
Loading