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 0116F4570F; Thu, 1 Aug 2024 10:41:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E1DD402C8; Thu, 1 Aug 2024 10:41:16 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 2DDAD4014F for ; Thu, 1 Aug 2024 10:41:15 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 326D01007; Thu, 1 Aug 2024 01:41:40 -0700 (PDT) Received: from [10.1.38.17] (JR4XG4HTQC.cambridge.arm.com [10.1.38.17]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 20EC23F766; Thu, 1 Aug 2024 01:41:13 -0700 (PDT) Message-ID: Date: Thu, 1 Aug 2024 09:41:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/1] dts: add text parser for testpmd verbose output Content-Language: en-GB To: jspewock@iol.unh.edu, yoan.picchi@foss.arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, npratte@iol.unh.edu, thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, wathsala.vithanage@arm.com Cc: dev@dpdk.org References: <20240729203955.267942-1-jspewock@iol.unh.edu> <20240730133459.21907-1-jspewock@iol.unh.edu> <20240730133459.21907-2-jspewock@iol.unh.edu> From: Luca Vizzarro In-Reply-To: <20240730133459.21907-2-jspewock@iol.unh.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Great work Jeremy! Just a couple of minor passable improvement points. On 30/07/2024 14:34, jspewock@iol.unh.edu wrote: > +@dataclass > +class TestPmdVerbosePacket(TextParser): > + """Packet information provided by verbose output in Testpmd. > + > + The "receive/sent queue" information is not included in this dataclass because this value is > + captured on the outer layer of input found in :class:`TestPmdVerboseOutput`. > + """ > + > + #: > + src_mac: str = field(metadata=TextParser.find(r"src=({})".format(REGEX_FOR_MAC_ADDRESS))) Just a(n optional) nit: TextParser.find(f"src=({REGEX_FOR_MAC_ADDRESS})") The raw string is only needed to prevent escaping, which we don't do here. > + #: > + dst_mac: str = field(metadata=TextParser.find(r"dst=({})".format(REGEX_FOR_MAC_ADDRESS))) As above. > + #: Memory pool the packet was handled on. > + pool: str = field(metadata=TextParser.find(r"pool=(\S+)")) > + #: Packet type in hex. > + p_type: int = field(metadata=TextParser.find_int(r"type=(0x[a-fA-F\d]+)")) > + #: > + @staticmethod > + def extract_verbose_output(output: str) -> list[TestPmdVerboseOutput]: > + """Extract the verbose information present in given testpmd output. > + > + This method extracts sections of verbose output that begin with the line > + "port X/queue Y: sent/received Z packets" and end with the ol_flags of a packet. > + > + Args: > + output: Testpmd output that contains verbose information > + > + Returns: > + List of parsed packet information gathered from verbose information in `output`. > + """ > + iter = re.finditer(r"(port \d+/queue \d+:.*?(?=port \d+/queue \d+|$))", output, re.S) How about using a regex that matches what you described? ;) Keeping re.S: (port \d+/queue \d+.+?ol_flags: [\w ]+) Would spare you from using complex lookahead constructs and 4.6x less steps. Maybe it doesn't work with every scenario? Looks like it works well with the sample output I have. Let me know if it works for you. Best, Luca