Skip to content

Commit

Permalink
Fix tests for NO DUT (unit and mock)
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Aug 22, 2024
1 parent bc7c5d8 commit 5762564
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,6 @@ jobs:
mkdir -p out/trace_data
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/controller/python/test/test_scripts/mobile-device-test.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/execute_python_tests.py --env-file /tmp/test_env.yaml --search-directory src/python_testing'
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestMatterTestingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestSpecParsingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
scripts/run_in_python_env.sh out/venv './scripts/tests/TestTimeSyncTrustedTimeSourceRunner.py'
scripts/run_in_python_env.sh out/venv './src/python_testing/test_testing/test_TC_ICDM_2_1.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestIdChecks.py'
Expand All @@ -518,6 +516,8 @@ jobs:
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_IDM_10_4.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_TC_SC_7_1.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/TestDecorators.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestMatterTestingSupport.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestSpecParsingSupport.py'
- name: Uploading core files
Expand Down
32 changes: 17 additions & 15 deletions src/python_testing/matter_testing_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ class MatterTestConfig:
app_pid: int = 0

commissioning_method: Optional[str] = None
discriminators: Optional[List[int]] = None
setup_passcodes: Optional[List[int]] = None
discriminators: List[int] = field(default_factory=list)
setup_passcodes: List[int] = field(default_factory=list)
commissionee_ip_address_just_for_testing: Optional[str] = None
# By default, we start with maximized cert chains, as required for RR-1.1.
# This allows cert tests to be run without re-commissioning for RR-1.1.
Expand All @@ -527,7 +527,7 @@ class MatterTestConfig:
pics: dict[bool, str] = field(default_factory=dict)

# Node ID for basic DUT
dut_node_ids: Optional[List[int]] = None
dut_node_ids: List[int] = field(default_factory=list)
# Node ID to use for controller/commissioner
controller_node_id: int = _DEFAULT_CONTROLLER_NODE_ID
# CAT Tags for default controller/commissioner
Expand Down Expand Up @@ -1545,16 +1545,8 @@ def populate_commissioning_args(args: argparse.Namespace, config: MatterTestConf

config.qr_code_content.extend(args.qr_code)
config.manual_code.extend(args.manual_code)

if args.discriminators == [] and (args.qr_code == [] and args.manual_code == []):
print("error: Missing --discriminator when no --qr-code/--manual-code present!")
return False
config.discriminators = args.discriminators

if args.passcodes == [] and (args.qr_code == [] and args.manual_code == []):
print("error: Missing --passcode when no --qr-code/--manual-code present!")
return False
config.setup_passcodes = args.passcodes
config.discriminators.extend(args.discriminators)
config.setup_passcodes.extend(args.passcodes)

if args.qr_code != [] and args.manual_code != []:
print("error: Cannot have both --qr-code and --manual-code present!")
Expand All @@ -1571,9 +1563,11 @@ def populate_commissioning_args(args: argparse.Namespace, config: MatterTestConf
return False

if len(config.dut_node_ids) < len(device_descriptors):
missing = len(device_descriptors) - len(config.dut_node_ids)
# We generate new node IDs sequentially from the last one seen for all
# missing NodeIDs when commissioning many nodes at once.
if not config.dut_node_ids:
config.dut_node_ids = [_DEFAULT_DUT_NODE_ID]
missing = len(device_descriptors) - len(config.dut_node_ids)
for i in range(missing):
config.dut_node_ids.append(config.dut_node_ids[-1] + 1)

Expand All @@ -1588,6 +1582,14 @@ def populate_commissioning_args(args: argparse.Namespace, config: MatterTestConf
if args.commissioning_method is None:
return True

if args.discriminators == [] and (args.qr_code == [] and args.manual_code == []):
print("error: Missing --discriminator when no --qr-code/--manual-code present!")
return False

if args.passcodes == [] and (args.qr_code == [] and args.manual_code == []):
print("error: Missing --passcode when no --qr-code/--manual-code present!")
return False

if config.commissioning_method == "ble-wifi":
if args.wifi_ssid is None:
print("error: missing --wifi-ssid <SSID> for --commissioning-method ble-wifi!")
Expand Down Expand Up @@ -1684,7 +1686,7 @@ def parse_matter_test_args(argv: Optional[List[str]] = None) -> MatterTestConfig
default=_DEFAULT_CONTROLLER_NODE_ID,
help='NodeID to use for initial/default controller (default: %d)' % _DEFAULT_CONTROLLER_NODE_ID)
basic_group.add_argument('-n', '--dut-node-id', '--nodeId', type=int_decimal_or_hex,
metavar='NODE_ID', dest='dut_node_ids', default=[_DEFAULT_DUT_NODE_ID],
metavar='NODE_ID', dest='dut_node_ids', default=[],
help='Node ID for primary DUT communication, '
'and NodeID to assign if commissioning (default: %d)' % _DEFAULT_DUT_NODE_ID, nargs="+")
basic_group.add_argument('--endpoint', type=int, default=0, help="Endpoint under test")
Expand Down

0 comments on commit 5762564

Please sign in to comment.