Skip to content

Conversation

@j-ororke
Copy link
Contributor

Summary

Created idm_support.py following the cadmin_support pattern to share common functionality across IDM test modules. Moved 30+ shared methods from TC_IDM_1_2, TC_IDM_1_4, TC_IDM_2_2, and TC_IDM_4_2 into IDMBaseTest class created in idm_support module.

This reduces duplication and makes test files cleaner and easier to maintain.

Related issues

Resolves follow-up task: project-chip/matter-test-scripts#690

Testing

This is validated by the following test modules: TC_IDM_1_2.py, TC_IDM_1_4.py, TC_IDM_2_2.py, TC_IDM_4_2.py

Used following example command in WSL Linux for validation of TC_IDM_1_2, TC_IDM_2_2.py, and TC_IDM_4_2.py:

./scripts/tests/run_python_test.py --factory-reset --app out/linux-x64-all-clusters/chip-all-clusters-app --app-args "--discriminator 1234 --KVS kvs1" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --endpoint 0" --script src/python_testing/TC_IDM_2_2.py 

Following command was used for validation of TC_IDM_1_4.py:

./scripts/tests/run_python_test.py --factory-reset --app out/linux-x64-all-clusters/chip-all-clusters-app --app-args "--discriminator 1234 --KVS kvs1 --enable-key 000102030405060708090a0b0c0d0e0f" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --endpoint 0 --hex-arg PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f" --script src/python_testing/TC_IDM_1_4.py 

Note

Need to add TC_IDM_3_2 test module functions in PR #41066 that can be shared amongst other test modules once that PR gets merged.

Readability checklist

The checklist below will help the reviewer finish PR review in time and keep the
code readable:

  • PR title is
    descriptive
  • Apply the
    “When in Rome…”
    rule (coding style)
  • PR size is short
  • Try to avoid "squashing" and "force-update" in commit history
  • CI time didn't increase

See: Pull Request Guidelines

… IDM test modules

Created idm_support.py following the cadmin_support pattern to share common
functionality across IDM test modules. Moved 30+ shared methods from
TC_IDM_1_2, TC_IDM_1_4, TC_IDM_2_2, and TC_IDM_4_2 into IDMBaseTest class created in idm_support module.

This reduces duplication and makes test files cleaner and easier to maintain.
@j-ororke j-ororke self-assigned this Oct 27, 2025
@github-actions github-actions bot added the tests label Oct 27, 2025
@j-ororke j-ororke requested review from cecille and removed request for cecille October 27, 2025 06:26
@github-actions
Copy link

github-actions bot commented Oct 27, 2025

PR #41641: Size comparison from e156205 to 90f168f

Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section e156205 90f168f change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1106046 1106046 0 0.0
RAM 178874 178874 0 0.0
bl702 lighting-app bl702+eth FLASH 661198 661198 0 0.0
RAM 134969 134969 0 0.0
bl702+wifi FLASH 836734 836734 0 0.0
RAM 124405 124405 0 0.0
bl706+mfd+rpc+littlefs FLASH 1070278 1070278 0 0.0
RAM 117261 117261 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 899730 899730 0 0.0
RAM 105524 105524 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 983040 983040 0 0.0
RAM 109740 109740 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770404 770404 0 0.0
RAM 103304 103304 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 782152 782152 0 0.0
RAM 108472 108472 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 728212 728212 0 0.0
RAM 97364 97364 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 712672 712672 0 0.0
RAM 97580 97580 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554226 554226 0 0.0
RAM 205736 205736 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587202 587202 0 0.0
RAM 205832 205832 0 0.0
efr32 lock-app BRD4187C FLASH 962944 962944 0 0.0
RAM 123512 123512 0 0.0
BRD4338a FLASH 756392 756392 0 0.0
RAM 254136 254136 0 0.0
window-app BRD4187C FLASH 1058140 1058140 0 0.0
RAM 119740 119740 0 0.0
esp32 all-clusters-app c3devkit DRAM 102516 102516 0 0.0
FLASH 1836138 1836138 0 0.0
IRAM 93540 93540 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 932908 932908 0 0.0
RAM 161313 161313 0 0.0
nxp contact mcxw71+release FLASH 691904 691904 0 0.0
RAM 61496 61496 0 0.0
lighting mcxw71+release FLASH 723408 723408 0 0.0
RAM 68140 68140 0 0.0
lock mcxw71+release FLASH 773672 773672 0 0.0
RAM 61932 61932 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1676372 1676372 0 0.0
RAM 213900 213900 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1592812 1592812 0 0.0
RAM 211108 211108 0 0.0
light cy8ckit_062s2_43012 FLASH 1459356 1459356 0 0.0
RAM 197728 197728 0 0.0
lock cy8ckit_062s2_43012 FLASH 1491908 1491908 0 0.0
RAM 225440 225440 0 0.0
qpg lighting-app qpg6200+debug FLASH 837104 837104 0 0.0
RAM 127708 127708 0 0.0
lock-app qpg6200+debug FLASH 773884 773884 0 0.0
RAM 118684 118684 0 0.0
realtek light-switch-app rtl8777g FLASH 706384 706384 0 0.0
RAM 106904 106904 0 0.0
lighting-app rtl8777g FLASH 757480 757480 0 0.0
RAM 127236 127236 0 0.0
stm32 light STM32WB5MM-DK FLASH 469852 469852 0 0.0
RAM 141304 141304 0 0.0
telink bridge-app tl7218x FLASH 710504 710504 0 0.0
RAM 90544 90544 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 796858 796858 0 0.0
RAM 41000 41000 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 788058 788058 0 0.0
RAM 93644 93644 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 714936 714936 0 0.0
RAM 51844 51844 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 748232 748232 0 0.0
RAM 70892 70892 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 725088 725088 0 0.0
RAM 34592 34592 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602332 602332 0 0.0
RAM 108904 108904 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 820662 820666 4 0.0
RAM 92040 92040 0 0.0

@j-ororke j-ororke marked this pull request as ready for review October 27, 2025 13:42
@j-ororke j-ororke requested a review from cecille October 27, 2025 13:43
try:
return inspect.getmembers(cluster.Commands, inspect.isclass)
except AttributeError:
return []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a comment about why this ignore is needed (here and in other places)? Why do we treat this error as a empty list instead of allowing it to propagate up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I've added a comment to explain this here now.
Quick context: This function came from TC_IDM_1_2.py - I just moved it to the support module without changing the logic.
Why return empty list: Looking at the code and its usage in IDM_1_2 not all clusters have a Commands attribute. When the test iterates through all clusters looking for ones with commands, some clusters throw AttributeError because they simply don't define any commands.
Returning an empty list lets the test safely check if not members: continue and move on to the next cluster, rather than crashing or needing special handling for every cluster that doesn't support commands.
Added a docstring note and inline comment to make this clearer. Let me know if you think there's a better approach to use here!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see below response from your next comment below, since I hadn't read that earlier I have now updated to using the hasattr that you have suggested below here as well.
This makes the intent clearer and easier to understand. Thank you!

# Inspect returns all the classes, not just the ones we want, so use a try
# here incase we're inspecting a builtin class
try:
return cmd_class if cmd_class.is_client else None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we use hasattr and not have try/catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, great suggestion! Using hasattr is much clearer.
I've now updated both get_all_cmds_for_cluster_id and client_cmd from IDM_1_2 to use hasattr instead of try/catch. This makes the intent more explicit and easier to read.
Thanks for the improvement! 👍

# ========================================================================

@staticmethod
def is_valid_uint32_value(var):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these not in src/python_testing/matter_testing_infrastructure/matter/testing/matter_asserts.py ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the matter_asserts module it appears to now have this covered, so there is no longer any need to have this in the IDM support module. I've removed them from idm_support.py and updated TC_IDM_4_2.py to import and use is_valid_uint_value() directly from matter_asserts. Much cleaner this way.
Thank you for bringing this to light!

# Descriptor and Cluster Reading Utilities
# ========================================================================

async def get_descriptor_server_list(self, ctrl: ChipDeviceCtrl, ep: int = None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async def get_descriptor_server_list(self, ctrl: ChipDeviceCtrl, ep: int = None):
async def get_descriptor_server_list(self, ctrl: ChipDeviceCtrl, ep: Optional[int] = None):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to allow None or can we use int and default to ROOT_NODE_ENDPOINT_ID instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment for all instances below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion!
You're right - there's no reason to use None here. I've updated all the functions to default directly to ROOT_NODE_ENDPOINT_ID instead. This simplifies the code by removing the None checks and makes the default behavior more explicit.
Changed from ep: int = None to ep: int = ROOT_NODE_ENDPOINT_ID in all 7 affected functions. Much cleaner now!

j-ororke and others added 5 commits October 27, 2025 14:50
- Added docstring and inline comment explaining why empty list is returned when clusters lack a Commands attribute.
Makes the code intent clearer and more Pythonic per Andrei's feedback.
…ameters

- Simplifies code by removing None checks and makes default behavior more explicit.
@github-actions
Copy link

github-actions bot commented Oct 27, 2025

PR #41641: Size comparison from e156205 to 9a393d4

Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section e156205 9a393d4 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1106046 1106076 30 0.0
RAM 178874 178882 8 0.0
bl702 lighting-app bl702+eth FLASH 661198 661228 30 0.0
RAM 134969 134969 0 0.0
bl702+wifi FLASH 836734 836764 30 0.0
RAM 124405 124405 0 0.0
bl706+mfd+rpc+littlefs FLASH 1070278 1070308 30 0.0
RAM 117261 117277 16 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 899730 899760 30 0.0
RAM 105524 105540 16 0.0
lighting-app bl702l+mfd+littlefs FLASH 983040 983070 30 0.0
RAM 109740 109756 16 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770404 770436 32 0.0
RAM 103304 103304 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 782152 782184 32 0.0
RAM 108472 108472 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 728212 728244 32 0.0
RAM 97364 97364 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 712672 712704 32 0.0
RAM 97580 97580 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554226 554578 352 0.1
RAM 205736 205744 8 0.0
lock CC3235SF_LAUNCHXL FLASH 587202 587234 32 0.0
RAM 205832 205840 8 0.0
efr32 lock-app BRD4187C FLASH 962944 962976 32 0.0
RAM 123512 123512 0 0.0
BRD4338a FLASH 756392 756424 32 0.0
RAM 254136 254144 8 0.0
window-app BRD4187C FLASH 1058140 1058172 32 0.0
RAM 119740 119740 0 0.0
esp32 all-clusters-app c3devkit DRAM 102516 102524 8 0.0
FLASH 1836138 1836410 272 0.0
IRAM 93540 93540 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 932908 933180 272 0.0
RAM 161313 161317 4 0.0
nxp contact mcxw71+release FLASH 691904 691936 32 0.0
RAM 61496 61496 0 0.0
lighting mcxw71+release FLASH 723408 723440 32 0.0
RAM 68140 68148 8 0.0
lock mcxw71+release FLASH 773672 773704 32 0.0
RAM 61932 61932 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1676372 1676836 464 0.0
RAM 213900 213908 8 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1592812 1593276 464 0.0
RAM 211108 211116 8 0.0
light cy8ckit_062s2_43012 FLASH 1459356 1459388 32 0.0
RAM 197728 197736 8 0.0
lock cy8ckit_062s2_43012 FLASH 1491908 1491940 32 0.0
RAM 225440 225448 8 0.0
qpg lighting-app qpg6200+debug FLASH 837104 837216 112 0.0
RAM 127708 127716 8 0.0
lock-app qpg6200+debug FLASH 773884 773996 112 0.0
RAM 118684 118692 8 0.0
realtek light-switch-app rtl8777g FLASH 706384 706416 32 0.0
RAM 106904 106904 0 0.0
lighting-app rtl8777g FLASH 757480 757512 32 0.0
RAM 127236 127236 0 0.0
stm32 light STM32WB5MM-DK FLASH 469852 469892 40 0.0
RAM 141304 141312 8 0.0
telink bridge-app tl7218x FLASH 710504 710534 30 0.0
RAM 90544 90544 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 796858 796888 30 0.0
RAM 41000 41008 8 0.0
light-app-ota-shell-factory-data tl7218x FLASH 788058 788088 30 0.0
RAM 93644 93644 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 714936 714966 30 0.0
RAM 51844 51852 8 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 748232 748262 30 0.0
RAM 70892 70892 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 725088 725118 30 0.0
RAM 34592 34600 8 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602332 602362 30 0.0
RAM 108904 108912 8 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 820662 820696 34 0.0
RAM 92040 92040 0 0.0

return None


# ============================================================================
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this class get used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
Yeah, when I was creating this module I was using the cadmin_support module we created for the CADMIN tests as a reference - it has both a CADMINSupport helper class and a CADMINBaseTest base class.
So I copied that structure over to use with the IDM tests thinking I might need both, but appears I only needed the IDMBaseTest class for all the IDM functionality and never ended up using the helper class.
Sorry, Completely forgot to clean it up. I'll remove it now. Thanks!

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

PR #41641: Size comparison from 3548c02 to de3b275

Full report (4 builds for nrfconnect, realtek, stm32)
platform target config section 3548c02 de3b275e change % change
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 933460 933460 0 0.0
RAM 161377 161377 0 0.0
realtek light-switch-app rtl8777g FLASH 706960 706960 0 0.0
RAM 106964 106964 0 0.0
lighting-app rtl8777g FLASH 757904 757904 0 0.0
RAM 127296 127296 0 0.0
stm32 light STM32WB5MM-DK FLASH 470232 470232 0 0.0
RAM 141352 141352 0 0.0

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

PR #41641: Size comparison from 3548c02 to 07607a3

Full report (35 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section 3548c02 07607a3 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1106354 1106354 0 0.0
RAM 178930 178930 0 0.0
bl702 lighting-app bl702+eth FLASH 661428 661428 0 0.0
RAM 135025 135025 0 0.0
bl702+wifi FLASH 837022 837022 0 0.0
RAM 124445 124445 0 0.0
bl706+mfd+rpc+littlefs FLASH 1070624 1070624 0 0.0
RAM 117317 117317 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 900056 900056 0 0.0
RAM 105612 105612 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 983370 983370 0 0.0
RAM 109796 109796 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770820 770820 0 0.0
RAM 103360 103360 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 782672 782672 0 0.0
RAM 108528 108528 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 728612 728612 0 0.0
RAM 97420 97420 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 713080 713080 0 0.0
RAM 97636 97636 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554914 554914 0 0.0
RAM 205776 205776 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587794 587794 0 0.0
RAM 205872 205872 0 0.0
efr32 lock-app BRD4187C FLASH 963504 963504 0 0.0
RAM 123572 123572 0 0.0
BRD4338a FLASH 757752 757752 0 0.0
RAM 254196 254196 0 0.0
window-app BRD4187C FLASH 1058820 1058820 0 0.0
RAM 119800 119800 0 0.0
esp32 all-clusters-app c3devkit DRAM 102572 102572 0 0.0
FLASH 1836850 1836850 0 0.0
IRAM 93540 93540 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 933460 933460 0 0.0
RAM 161377 161377 0 0.0
nxp contact mcxw71+release FLASH 692512 692512 0 0.0
RAM 61552 61552 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1678108 1678108 0 0.0
RAM 213956 213956 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1594508 1594508 0 0.0
RAM 211156 211156 0 0.0
light cy8ckit_062s2_43012 FLASH 1460732 1460732 0 0.0
RAM 197776 197776 0 0.0
lock cy8ckit_062s2_43012 FLASH 1493420 1493420 0 0.0
RAM 225496 225496 0 0.0
qpg lighting-app qpg6200+debug FLASH 837768 837768 0 0.0
RAM 127768 127768 0 0.0
lock-app qpg6200+debug FLASH 774596 774596 0 0.0
RAM 118736 118736 0 0.0
realtek light-switch-app rtl8777g FLASH 706960 706960 0 0.0
RAM 106964 106964 0 0.0
lighting-app rtl8777g FLASH 757904 757904 0 0.0
RAM 127296 127296 0 0.0
stm32 light STM32WB5MM-DK FLASH 470232 470232 0 0.0
RAM 141352 141352 0 0.0
telink bridge-app tl7218x FLASH 710622 710622 0 0.0
RAM 90600 90600 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 797098 797098 0 0.0
RAM 41024 41024 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 788300 788300 0 0.0
RAM 93700 93700 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 715300 715300 0 0.0
RAM 51892 51892 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 748596 748596 0 0.0
RAM 70932 70932 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 725450 725450 0 0.0
RAM 34624 34624 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602686 602686 0 0.0
RAM 108928 108928 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 820932 820936 4 0.0
RAM 92096 92096 0 0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants