Skip to content

Commit 6a31e87

Browse files
committed
TC-CCTRL-2.2: Make TH_SERVER app configurable
1 parent b426fde commit 6a31e87

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/python_testing/TC_CCTRL_2_2.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#
2121
# TODO: Skip CI for now, we don't have any way to run this. Needs setup. See test_TC_CCTRL.py
2222

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

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

8181
os.remove(self.kvs)
8282
super().teardown_class()

src/python_testing/test_testing/test_TC_CCNTL_2_2.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#
1818

1919
import base64
20+
import click
2021
import os
2122
import pathlib
2223
import sys
@@ -29,11 +30,11 @@
2930
from MockTestRunner import AsyncMock, MockTestRunner
3031

3132
try:
32-
from matter_testing_support import get_default_paa_trust_store, run_tests_no_exit
33+
from matter_testing_support import MatterTestConfig, get_default_paa_trust_store, run_tests_no_exit
3334
except ImportError:
3435
sys.path.append(os.path.abspath(
3536
os.path.join(os.path.dirname(__file__), '..')))
36-
from matter_testing_support import get_default_paa_trust_store, run_tests_no_exit
37+
from matter_testing_support import MatterTestConfig, get_default_paa_trust_store, run_tests_no_exit
3738

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

149150

150-
def main():
151+
@click.command()
152+
@click.argument('th_server_app', type=click.Path(exists=True))
153+
def main(th_server_app: str):
151154
root = os.path.abspath(os.path.join(pathlib.Path(__file__).resolve().parent, '..', '..', '..'))
152155
print(f'root = {root}')
153156
paa_path = get_default_paa_trust_store(root)
154157
print(f'paa = {paa_path}')
155158

156159
pics = {"PICS_SDK_CI_ONLY": True}
157160
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)
161+
config = MatterTestConfig()
162+
config.user_params = {'th_server_app_path': th_server_app}
163+
test_runner.set_test_config(config)
158164

159165
test_runner.run_test_with_mock(dynamic_invoke_return, dynamic_event_return, wildcard())
160166
test_runner.Shutdown()

0 commit comments

Comments
 (0)