[dts] [PATCH v2] tests/userspace_ethtool: pull and check link status

Tu, Lijuan lijuan.tu at intel.com
Thu Dec 5 02:41:09 CET 2019


Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces at dpdk.org] On Behalf Of
> michael.luo at intel.com
> Sent: Wednesday, December 4, 2019 2:45 PM
> To: dts at dpdk.org
> Subject: [dts] [PATCH v2] tests/userspace_ethtool: pull and check link status
> 
> From: Gaoliang Luo <michael.luo at intel.com>
> 
> in test_port_config, pull and check the link status insteading of using sleep to
> wait after DPDK ethtool app stop/open the port.
> 
> Signed-off-by: Gaoliang Luo <michael.luo at intel.com>
> ---
>  tests/TestSuite_userspace_ethtool.py | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/TestSuite_userspace_ethtool.py
> b/tests/TestSuite_userspace_ethtool.py
> index e9b6ccf..f5583f2 100644
> --- a/tests/TestSuite_userspace_ethtool.py
> +++ b/tests/TestSuite_userspace_ethtool.py
> @@ -221,6 +221,18 @@ class TestUserspaceEthtool(TestCase,
> IxiaPacketGenerator):
> 
>          return status, msg
> 
> +    def ethapp_check_link_status(self, port_id, expected_status = 'Up'):
> +        retries = 0
> +        reg_str = 'Port\s+{}:\s+(Up|Down)'.format(port_id)
> +        while retries < 5:
> +            out = self.dut.send_expect("link", "EthApp> ", 10)
> +            if out is not None:
> +                status = re.search(reg_str, out).group(1)
> +                if status == expected_status:
> +                    return True
> +            time.sleep(1)
> +        return False
> +
>      def test_dump_driver_info(self):
>          """
>          Test ethtool can dump basic information @@ -519,7 +531,8 @@ class
> TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
>              time.sleep(10)
>              # stop port
>              self.dut.send_expect("stop %d" % index, "EthApp>")
> -            time.sleep(10)
> +            self.verify(self.ethapp_check_link_status(index, 'Down') == True,
> +                           'Fail to stop port{}'.format(index))
>              # check packet not forwarded when port is stop
>              pkt = Packet(pkt_type='UDP')
>              tester_port = self.tester.get_local_port(port) @@ -528,11 +541,11
> @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
>              rx_pkts, tx_pkts = self.strip_portstats(index)
>              self.verify(rx_pkts == ori_rx_pkts, "Failed to stop port")
>              # restart port and check packet can normally forwarded
> -            time.sleep(2)
>              self.dut.send_expect("open %d" % index, "EthApp>")
> +            self.verify(self.ethapp_check_link_status(index, 'Up') == True,
> +                         'Fail to Open port{}'.format(index))
>              # wait few time for port ready
>              rx_pkts, tx_pkts = self.strip_portstats(index)
> -            time.sleep(2)
>              pkt.send_pkt(self.tester, tx_port=intf, count=4)
>              rx_pkts_open, tx_pkts_open = self.strip_portstats(index)
>              self.verify(rx_pkts_open == rx_pkts + 4, "Failed to reopen port rx")
> --
> 2.7.4



More information about the dts mailing list