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 19C3143E92; Wed, 17 Apr 2024 15:22:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A74DB40E32; Wed, 17 Apr 2024 15:22:28 +0200 (CEST) Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by mails.dpdk.org (Postfix) with ESMTP id 3160D402AE for ; Wed, 17 Apr 2024 15:22:27 +0200 (CEST) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a44ad785a44so682373866b.3 for ; Wed, 17 Apr 2024 06:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1713360147; x=1713964947; 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=2CCDDZVT0SYpGyxKG0+m/QkQAp5VpU7cvIOOsnAqBS0=; b=pu/xwvhtrJ6puTLjlOcE6/gG2Sau6FLmBe2kAQLfF58axn4aRRW+NGWQd6SparMcNx ijf4UsdsBMYtuU33XbpT62+nnhVmDlwhCBrnSsjiSM91Nlg3SHJxz4oHz/S516wW987M iZPa/I8ajucSM0e0JmyKcw2HaM+Gf6T/2ag57ZzkQc+v5JMZXD5AZylRRvfxuClmqKdC CIPWrtD+OAwhsvgj45K2GSLLvrwQP8x7OgPG7A62snHVa2Ljoizd91QsCTMBNg66hlsM 5sMvPEJXcoMmb8iKq1O5AwIdShrEVYQUHd2hv/1wL7hdDyL++1BU4Ks1udm8E29oArMO UTsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713360147; x=1713964947; 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=2CCDDZVT0SYpGyxKG0+m/QkQAp5VpU7cvIOOsnAqBS0=; b=KtCbjgNWkjItiEF+VyES/TjBs7QgabiLc4WUw510lc2tgqrBiBcrycVXt6d0JXinOB x/cZuTQeY7/RCDyvMeYYZCpzsEwdHE6q2IsDkis0u12651Qrn22IoKgGHpwK2o5BZtv0 KVrifJ+Gw7QC+4aNVcEZXP4VTEJQ+FVTfc3tKbHTp8zcYFamOOBPTSuhsHuvZ3/snUVa RQ64K3FO4yTjSxibRRq//Xmr9L0Bzz7xRvX9dI8wY0dmtejY7Y1zHNG57n5d0o4btXkw WcoCVJBp/20IDdQI636PX5Nh4qQKBatJXYFi5IYQJ7uQFHuWA3h9z/bhx0JxYA5W44+h Sp8g== X-Gm-Message-State: AOJu0YzuzquM7It2iuQsxvtUbPHphN474eU/W+qdZz+BvaYQQepsLLci MZ5gP2Zip0vTnTK+W/KaC1yZUg35yIRkBYSA+bJPVGK5DX36Brx0MZE4Y9Yc+qpqiSHg1E+unKh zRAEEygYkpVPssOv+VExOSkDJxTTe8Cy/Q9W2Tw== X-Google-Smtp-Source: AGHT+IFdyXqGVhS77fyPPM+j9DQTNojEmEwvSvXw0Wp4u8Y/gLiLBdNJXQmoIRiZnQG7LhaPHAWiZt9xPO35IMoN+k4= X-Received: by 2002:a17:906:3a85:b0:a51:fa56:4fc7 with SMTP id y5-20020a1709063a8500b00a51fa564fc7mr9914950ejd.21.1713360146749; Wed, 17 Apr 2024 06:22:26 -0700 (PDT) MIME-Version: 1.0 References: <20240412111136.3470304-1-luca.vizzarro@arm.com> <20240412111136.3470304-5-luca.vizzarro@arm.com> <4f17ef06-c508-495a-a0f8-a28e9e77a1f9@arm.com> In-Reply-To: <4f17ef06-c508-495a-a0f8-a28e9e77a1f9@arm.com> From: =?UTF-8?Q?Juraj_Linke=C5=A1?= Date: Wed, 17 Apr 2024 15:22:16 +0200 Message-ID: Subject: Re: [PATCH 4/5] dts: add `show port info` command to TestPmdShell To: Luca Vizzarro Cc: dev@dpdk.org, Jeremy Spewock , Paul Szczepanek 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 Tue, Apr 16, 2024 at 2:24=E2=80=AFPM Luca Vizzarro wrote: > > On 16/04/2024 10:03, Juraj Linke=C5=A1 wrote: > >> +@dataclass > >> +class TestPmdPort(TextParser): > > > > This and the classes above are missing docstrings. > > Ack. > > >> @@ -225,6 +664,38 @@ def set_forward_mode(self, mode: TestPmdForwardin= gModes, verify: bool =3D True): > >> f"Test pmd failed to set fwd mode to {mode.value}" > >> ) > >> > >> + def show_port_info_all(self) -> list[TestPmdPort]: > >> + """Returns the information of all the ports.""" > > > > Can we add sample output so that the format of what we're trying to > > parse is clear? > > Ack. > > >> + output =3D self.send_command("show port info all") > >> + > >> + ports =3D [] > >> + iter =3D re.finditer(r"\*+.+\*+", output) > >> + if next(iter, False): # we are slicing retrospectively, skip= first block > >> + start_pos =3D 0 > >> + for block in iter: > >> + end_pos =3D block.start() > >> + ports.append(TestPmdPort.parse(output[start_pos:end_p= os])) > >> + start_pos =3D end_pos > >> + > >> + ports.append(TestPmdPort.parse(output[start_pos:])) > >> + > >> + return ports > > > > Can this be done the same way it's done in the last commit? > > > > iter =3D re.finditer(r"(^ #*.+#*$[^#]+)^ #*$", output, re.MULTILINE) > > return [TestPmdPortStats.parse(block.group(1)) for block in iter] > > > > Looks much better. > > I agree that it looks much better. I gave it a first attempt to come up > with a regular expression that is not too complicated and is able to > match blocks individually. I've noticed that blocks start with: > > \n********* Infos for port X ************ > > but don't have an actual ending delimiter, unlike for the stats. Ah, so that's the difference and the reason. I guess the ending delimiter is either the start of the next section of the prompt (or the end of the string). > I'll > experiment with some look ahead constructs. The easiest solution is to > match everything that is not * ([^*]+) but can we be certain that there > won't be any asterisk in the actual information? We can't. But we can be reasonably certain there won't be five consecutive asterisks, so maybe we can work with that.