From 20c9bcbc4142fd74e490bd50faa7def9e1b3a823 Mon Sep 17 00:00:00 2001 From: Zhanglong Xia Date: Fri, 12 Jul 2024 23:59:28 +0800 Subject: [PATCH] [test] test whether the RCP supports data poll (#10494) This commit adds a test case to the `cp-tests` to test whether the RCP supports data poll transmitter and receiver. --- tools/cp-caps/README.md | 13 ++++++- tools/cp-caps/rcp_caps_test.py | 64 ++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/tools/cp-caps/README.md b/tools/cp-caps/README.md index 2a4909647..1614f3e1f 100644 --- a/tools/cp-caps/README.md +++ b/tools/cp-caps/README.md @@ -54,7 +54,7 @@ Show help info. ```bash $ python3 ./tools/cp-caps/rcp_caps_test.py -h -usage: rcp_caps_test.py [-h] [-c] [-d] [-v] +usage: rcp_caps_test.py [-h] [-c] [-d] [-p] [-v] This script is used for testing RCP capabilities. @@ -62,6 +62,7 @@ options: -h, --help show this help message and exit -c, --csl test whether the RCP supports CSL transmitter -d, --diag-commands test whether the RCP supports all diag commands + -p, --data-poll test whether the RCP supports data poll -v, --verbose output verbose information Device Interfaces: @@ -133,3 +134,13 @@ The parameter `-c` or `--csl` starts to test whether the RCP supports the CSL tr $ DUT_ADB_USB=TW69UCKFZTGM95OR REF_CLI_SERIAL=/dev/ttyACM0 python3 ./tools/cp-caps/rcp_caps_test.py -c CSL Transmitter ------------------------------------------ OK ``` + +### Test Data Poll + +The parameter `-p` or `--data-poll` starts to test whether the RCP supports data poll. + +```bash +$ DUT_ADB_USB=1269UCKFZTAM95OR REF_CLI_SERIAL=/dev/ttyACM0 python3 ./tools/cp-caps/rcp_caps_test.py -p +Data Poll Parent ----------------------------------------- OK +Data Poll Child ------------------------------------------ OK +``` diff --git a/tools/cp-caps/rcp_caps_test.py b/tools/cp-caps/rcp_caps_test.py index adaa86a80..f40e7e2c7 100644 --- a/tools/cp-caps/rcp_caps_test.py +++ b/tools/cp-caps/rcp_caps_test.py @@ -83,6 +83,11 @@ class RcpCaps(object): self.__dataset = self.__get_default_dataset() self.__test_csl_transmitter() + def test_data_poll(self): + self.__dataset = self.__get_default_dataset() + self.__test_data_poll_parent() + self.__test_data_poll_child() + # # Private methods # @@ -117,6 +122,54 @@ class RcpCaps(object): self.__output_format_bool('CSL Transmitter', ret) + def __test_data_poll_parent(self): + packets = 10 + + self.__dut.factory_reset() + self.__ref.factory_reset() + + self.__dut.join(self.__dataset) + self.__dut.wait_for('state', 'leader') + + # Set the reference device as an SED + self.__ref.set_mode('-') + self.__ref.set_poll_period(500) + self.__ref.join(self.__dataset) + self.__ref.wait_for('state', 'child') + + dut_mleid = self.__dut.get_ipaddr_mleid() + result = self.__ref.ping(dut_mleid, count=packets, interval=1) + + self.__dut.leave() + self.__ref.leave() + + ret = result['transmitted_packets'] == result['received_packets'] == packets + self.__output_format_bool('Data Poll Parent', ret) + + def __test_data_poll_child(self): + packets = 10 + + self.__dut.factory_reset() + self.__ref.factory_reset() + + self.__ref.join(self.__dataset) + self.__ref.wait_for('state', 'leader') + + # Set the DUT as an SED + self.__dut.set_mode('-') + self.__dut.set_poll_period(500) + self.__dut.join(self.__dataset) + self.__dut.wait_for('state', 'child') + + dut_mleid = self.__dut.get_ipaddr_mleid() + result = self.__ref.ping(dut_mleid, count=packets, interval=1) + + self.__dut.leave() + self.__ref.leave() + + ret = result['transmitted_packets'] == result['received_packets'] == packets + self.__output_format_bool('Data Poll Child', ret) + def __test_diag_channel(self): channel = 20 commands = ['diag channel', f'diag channel {channel}'] @@ -429,6 +482,14 @@ def parse_arguments(): help='test whether the RCP supports all diag commands', ) + parser.add_argument( + '-p', + '--data-poll', + action='store_true', + default=False, + help='test whether the RCP supports data poll', + ) + parser.add_argument( '-v', '--verbose', @@ -455,6 +516,9 @@ def main(): if arguments.csl is True: rcp_caps.test_csl() + if arguments.data_poll is True: + rcp_caps.test_data_poll() + if __name__ == '__main__': main()