From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6CB7043348; Thu, 16 Nov 2023 20:05:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 00BD6402B7; Thu, 16 Nov 2023 20:05:24 +0100 (CET) Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by mails.dpdk.org (Postfix) with ESMTP id 3874440150 for ; Thu, 16 Nov 2023 20:05:22 +0100 (CET) Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-9f27af23443so166688566b.0 for ; Thu, 16 Nov 2023 11:05:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1700161522; x=1700766322; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bh73PVeDX4r80LdCXcw6hbMQE/Jo120uv22AH7H0Mx4=; b=FF6MhYxHISYW8kPxGnERyanzzXxKFWJYgIwjzm0mD9sWj9C1+KW+YeZxTmnv8u4fJW ls4W+We5gHQqwZV4nss5ZW2IoLEZt1D1S87dk+ezxmAMHhm+cHvPTEIf/cBSkctDGTi1 39WXyD0oyR27QPUyx+P9mQZrKhg617jyNeT0uoCSTsR8/63tdX6D6OW/DHuzR0IZXwAN h1SUmcuJSauCWYF6H4fnLXhS9TxiCKHc96V3YcVh8Ac1oSLEElxIJ2NavItJLuXvsi4e TH0cJtFE/wmFw0eG5Zp8V3kPQ6V/axD4+JTXBujBL7xxU2HbsSKGtIcHFbmeNl50WCQG CfCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700161522; x=1700766322; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bh73PVeDX4r80LdCXcw6hbMQE/Jo120uv22AH7H0Mx4=; b=r+LTOCORox2Srz67FzHmTcNzvT+BxPooAV/BMWKQUa6K+RJGTipIOhfb051O+kXA+q 95pGeWSzFdg4HeNIUl5VDLzwJUTX/iUA/d82mxTKJNARvAguzhKISeOFIdFy/hXeogAf OEykWy9Ct6ksMQQU1GKcC/sHGbN00T27WrFVUts9YjcNtFZGYn1mfStxU2aMd2dSCQUh ZRbNYDXbul7DGDIs2LTQcQ24Pk3BwDNJdYcSw9LFvLU+JlARkPxZjrMHow5YLGdne1PA hBzLOlhAhKChn5dkf4/zQautPE/vH2Qv/ED6neAdBiAZFn2Yi/zrRkDRUdAjb5HfHEiu gREQ== X-Gm-Message-State: AOJu0Yz2aYYjoUcR6CMqvBD6ETPm+Wv5He0b8cZZ+TIYb91NSHIa9I5V roaGbeMXzz7xNBTu3ZhxgZOHGHB5astwH7EC6tm1Mw== X-Google-Smtp-Source: AGHT+IHx3lVhF66oFrdP6xNd1fihjkVkhbpxEtJNNYeKj8mXA13pFVKJKC4BmD/aM0ZgdLA4PvwOjpALxZ9835QGmmg= X-Received: by 2002:a17:907:36c7:b0:9d5:b7db:f571 with SMTP id bj7-20020a17090736c700b009d5b7dbf571mr14325164ejc.17.1700161521861; Thu, 16 Nov 2023 11:05:21 -0800 (PST) MIME-Version: 1.0 References: <20231113202833.12900-1-jspewock@iol.unh.edu> <20231113202833.12900-3-jspewock@iol.unh.edu> In-Reply-To: <20231113202833.12900-3-jspewock@iol.unh.edu> From: =?UTF-8?Q?Juraj_Linke=C5=A1?= Date: Thu, 16 Nov 2023 20:05:11 +0100 Message-ID: Subject: Re: [PATCH v3 2/7] dts: add waiting for port up in testpmd To: jspewock@iol.unh.edu Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, wathsala.vithanage@arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru, dev@dpdk.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Mon, Nov 13, 2023 at 9:28=E2=80=AFPM wrote: > > From: Jeremy Spewock > > Added a method within the testpmd interactive shell that polls the > status of ports and verifies that the link status on a given port is > "up." Polling will continue until either the link comes up, or the > timeout is reached. > > Signed-off-by: Jeremy Spewock > --- > .../remote_session/remote/testpmd_shell.py | 29 +++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/f= ramework/remote_session/remote/testpmd_shell.py > index 1455b5a199..3ea16c7ab3 100644 > --- a/dts/framework/remote_session/remote/testpmd_shell.py > +++ b/dts/framework/remote_session/remote/testpmd_shell.py > @@ -1,9 +1,12 @@ > # SPDX-License-Identifier: BSD-3-Clause > # Copyright(c) 2023 University of New Hampshire > > +import time > from pathlib import PurePath > from typing import Callable > > +from framework.settings import SETTINGS > + > from .interactive_shell import InteractiveShell > > > @@ -47,3 +50,29 @@ def get_devices(self) -> list[TestPmdDevice]: > if "device name:" in line.lower(): > dev_list.append(TestPmdDevice(line)) > return dev_list > + > + def wait_link_status_up(self, port_id: int, timeout=3DSETTINGS.timeo= ut) -> bool: > + """Wait until the link status on the given port is "up". > + > + Arguments: > + port_id: Port to check the link status on. > + timeout: time to wait for the link to come up. > + > + Returns: > + If the link came up in time or not. > + """ Again with the docstrings - the new thing here is the usage of SETTINGS. Here's an example: The YAML test run configuration file is specified in the :option:`--config-file` command line argument or the :envvar:`DTS_CFG_FILE` environment variable. The rule is to first mention the cmdline arg, then the env var. > + time_to_stop =3D time.time() + timeout > + while time.time() < time_to_stop: > + port_info =3D self.send_command(f"show port info {port_id}") > + if "Link status: up" in port_info: > + break > + time.sleep(0.5) > + else: > + self._logger.error( > + f"The link for port {port_id} did not come up in the giv= en timeout." > + ) > + return "Link status: up" in port_info > + > + def close(self) -> None: > + self.send_command("exit", "") > + return super().close() > -- > 2.42.0 >