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 74626456F4; Tue, 30 Jul 2024 17:48:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 01163402F1; Tue, 30 Jul 2024 17:48:46 +0200 (CEST) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by mails.dpdk.org (Postfix) with ESMTP id 98463402EB for ; Tue, 30 Jul 2024 17:41:14 +0200 (CEST) Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2ef2687d604so4927581fa.0 for ; Tue, 30 Jul 2024 08:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1722354074; x=1722958874; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/sRHg4Oode7a2E4v/6mxOym1PHDiQRy3cfeSwXFrG60=; b=UaVz/BPupV03FUF64wKWBJmg8PItf/3tqXriavy4V4GGphz2jvQaB+s9QPm3xTx3Gx ETMw+4KpFxiBgkr+1cUEq2bB4UWqRgo4PJ89Nz2o/NPEMUHKXChqcFP/gpnwyhPCdIlM VG6F6AgxfpK8QnpTNf01t/9EvKbk6l7zV9Pic= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722354074; x=1722958874; h=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=/sRHg4Oode7a2E4v/6mxOym1PHDiQRy3cfeSwXFrG60=; b=JqDOKDriWXA7j2+I2c+kGaU+E5rIm8P9t3Xvz+6G8zaLG+aBDP/UaKr+P6YtOqMG9m 0a7ZmcxdjaUMrJu2YG2yolkyaZvUMv2WYTMEC+4tOuMtbrEmdRxV0IqG9GLqobC33VCn rQcd23Xc0FkAYLyCMNKnXrgnklWbPQFMe2+9TxUpZkcQETi6X5UkUDmhAM3Ow+WZ2cg1 MnTUVW1Fh2Qw70KTLhU6A0UlZgIU1W7wSLMpHz3z2GBN4upE8hR6GvWasxd82oUNZ9h+ 1gOISHEsOIDVk9klZ8HYGb17EK6DvV2GdHgRssPXLA3/lBgl2U2nsAKQ65B/EAKA2LK8 h5CQ== X-Forwarded-Encrypted: i=1; AJvYcCVRBFZYl7XDQxi6XtUKUvKbRrvjwJHhhqTQ86QqUMLhHQ1kH0cZkNbEWlwU+7HPjEX3qjW/wbS80ksdVFw= X-Gm-Message-State: AOJu0YzZMaNSuVcQmQ0saO9/tZfJXQr3wO8GTqGK56mRKuVNySngtSdZ 5jqrryHfEELgmblzN09YVoi3VLowPslurc3xn22NhnDsm9CT1I5tVy5kJH1F2l/NdPnVIF1TNLM BIU1+Oqx129nQkZt34lgfzkn18Uw6J+vtngD3Kw== X-Google-Smtp-Source: AGHT+IEzNczSi/GRACyW8Y7YbRcd9SMtdfgQmEZGjwYlZiX+DqLO+746BUlmSHQCFY72ZQXQMXZmyFD5HunHd3pbr2g= X-Received: by 2002:a2e:be13:0:b0:2f0:1a95:7102 with SMTP id 38308e7fff4ca-2f03c7b8a37mr81795841fa.6.1722354073802; Tue, 30 Jul 2024 08:41:13 -0700 (PDT) MIME-Version: 1.0 References: <20240729203955.267942-1-jspewock@iol.unh.edu> <20240730133459.21907-1-jspewock@iol.unh.edu> <20240730133459.21907-2-jspewock@iol.unh.edu> In-Reply-To: <20240730133459.21907-2-jspewock@iol.unh.edu> From: Nicholas Pratte Date: Tue, 30 Jul 2024 11:41:02 -0400 Message-ID: Subject: Re: [PATCH v2 1/1] dts: add text parser for testpmd verbose output To: jspewock@iol.unh.edu Cc: yoan.picchi@foss.arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, Luca.Vizzarro@arm.com, juraj.linkes@pantheon.tech, wathsala.vithanage@arm.com, dev@dpdk.org Content-Type: text/plain; charset="UTF-8" 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 Good work! I left some probing/clarifying comments below for you. > +@dataclass > +class TestPmdVerboseOutput(TextParser): > + """Verbose output generated by Testpmd. > + > + This class is the top level of the output, containing verbose output delimited by > + "port X/queue Y: sent/received Z packets". > + """ > + > + #: ID of the port that handled the packet. > + port_id: int = field(metadata=TextParser.find_int(r"port (\d+)/queue \d+")) > + #: ID of the queue that handled the packet. > + queue_id: int = field(metadata=TextParser.find_int(r"port \d+/queue (\d+)")) > + #: Whether the packet was received or sent by the queue/port. > + was_received: bool = field(metadata=TextParser.find(r"received \d+ packets")) > + #: List of packets handed by the port/queue in this section. > + packets: list[TestPmdVerbosePacket] = field( > + metadata=TextParser.wrap( > + TextParser.find_all(r"(src=[\w\s=:-]+ol_flags: [\w ]+)"), > + lambda matches_arr: list(map(TestPmdVerbosePacket.parse, matches_arr)), > + ) > + ) > + > + > class TestPmdShell(DPDKShell): > """Testpmd interactive shell. > > @@ -645,7 +767,7 @@ def start(self, verify: bool = True) -> None: > "Not all ports came up after starting packet forwarding in testpmd." > ) > > - def stop(self, verify: bool = True) -> None: > + def stop(self, verify: bool = True) -> str: > """Stop packet forwarding. > > Args: > @@ -656,6 +778,9 @@ def stop(self, verify: bool = True) -> None: > Raises: > InteractiveCommandExecutionError: If `verify` is :data:`True` and the command to stop > forwarding results in an error. > + > + Returns: > + Output gathered from sending the stop command. > """ > stop_cmd_output = self.send_command("stop") > if verify: > @@ -665,6 +790,7 @@ def stop(self, verify: bool = True) -> None: > ): > self._logger.debug(f"Failed to stop packet forwarding: \n{stop_cmd_output}") > raise InteractiveCommandExecutionError("Testpmd failed to stop packet forwarding.") > + return stop_cmd_output > > + @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) > + return [TestPmdVerboseOutput.parse(s.group(0)) for s in iter] > + I'm trying to think of circumstances where we as developers would be looking for anything else besides verbose output from the stop method. Running the command outputs some statistics, but information like port stats is displayed after the stop command is initiated. I'm implementing this system right now for one of my test suites, and I'm wondering if there might be any feasible way to extract output without needing to input any explicit outputs into this method. I'm putting output = testpmd.stop() and then calling this method. It looks something like this: verbose_output = testpmd.extract_verbose_output(testpmd.stop()) This is easy enough, but it might be a bit confusing for someone new to the framework. The way that output is gathered is still elusive to me, and I'm guessing that any commands run in-between setting verbose mode and when you stop testpmd might influence how output is generated. But in my experience so far, any statistics or information I need is gathered before packets are sent, and the need for verbose output in test cases is one after the other (i send a packet, look at verbose output, and then move onto the next packet).