Skip to content

Commit

Permalink
TC-CCTRL-2.2: Make TH_SERVER app configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Jul 30, 2024
1 parent b426fde commit 6a31e87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/python_testing/TC_CCTRL_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#
# TODO: Skip CI for now, we don't have any way to run this. Needs setup. See test_TC_CCTRL.py

# This test requires a TH_SERVER application. Please specify with --string-arg th_server_app_path:<path_to_app>

import ipaddress
import logging
import os
Expand All @@ -43,15 +45,14 @@ class TC_CCTRL_2_2(MatterBaseTest):
@async_test_body
async def setup_class(self):
super().setup_class()
# TODO: This needs to come from an arg and needs to be something available on the TH
# TODO: confirm whether we can open processes like this on the TH
app = os.path.join(pathlib.Path(__file__).resolve().parent, '..', '..', 'out',
'linux-x64-all-clusters-no-ble', 'chip-all-clusters-app')
app = self.matter_test_config.user_params.get("th_server_app_path", None)
if not app:
asserts.fail('This test requires a TH_SERVER app. Specify app path with --string-arg th_server_app_path:<path_to_app>')

self.kvs = f'kvs_{str(uuid.uuid4())}'
self.port = 5543
discriminator = random.randint(0, 4095)
discriminator = 3840
passcode = 20202021
app_args = f'--secured-device-port {self.port} --discriminator {discriminator} --passcode {passcode} --KVS {self.kvs}'
cmd = f'{app} {app_args}'
Expand All @@ -76,7 +77,6 @@ def teardown_class(self):
logging.warning("Stopping app with SIGTERM")
self.app_process.send_signal(signal.SIGTERM.value)
self.app_process.wait()
# TODO: Use timeout, if term doesn't work, try SIGINT

os.remove(self.kvs)
super().teardown_class()
Expand Down
12 changes: 9 additions & 3 deletions src/python_testing/test_testing/test_TC_CCNTL_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#

import base64
import click
import os
import pathlib
import sys
Expand All @@ -29,11 +30,11 @@
from MockTestRunner import AsyncMock, MockTestRunner

try:
from matter_testing_support import get_default_paa_trust_store, run_tests_no_exit
from matter_testing_support import MatterTestConfig, get_default_paa_trust_store, run_tests_no_exit
except ImportError:
sys.path.append(os.path.abspath(
os.path.join(os.path.dirname(__file__), '..')))
from matter_testing_support import get_default_paa_trust_store, run_tests_no_exit
from matter_testing_support import MatterTestConfig, get_default_paa_trust_store, run_tests_no_exit

invoke_call_count = 0
event_call_count = 0
Expand Down Expand Up @@ -147,14 +148,19 @@ def run_test_with_mock(self, dynamic_invoke_return: typing.Callable, dynamic_eve
return run_tests_no_exit(self.test_class, self.config, hooks, self.default_controller, self.stack)


def main():
@click.command()
@click.argument('th_server_app', type=click.Path(exists=True))
def main(th_server_app: str):
root = os.path.abspath(os.path.join(pathlib.Path(__file__).resolve().parent, '..', '..', '..'))
print(f'root = {root}')
paa_path = get_default_paa_trust_store(root)
print(f'paa = {paa_path}')

pics = {"PICS_SDK_CI_ONLY": True}
test_runner = MyMock('TC_CCTRL_2_2', 'TC_CCTRL_2_2', 'test_TC_CCTRL_2_2', 1, paa_trust_store_path=paa_path, pics=pics)
config = MatterTestConfig()
config.user_params = {'th_server_app_path': th_server_app}
test_runner.set_test_config(config)

test_runner.run_test_with_mock(dynamic_invoke_return, dynamic_event_return, wildcard())
test_runner.Shutdown()
Expand Down

0 comments on commit 6a31e87

Please sign in to comment.