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 2CC3243E92; Wed, 17 Apr 2024 15:06:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9DCD640E09; Wed, 17 Apr 2024 15:06:20 +0200 (CEST) Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by mails.dpdk.org (Postfix) with ESMTP id 5961440E09 for ; Wed, 17 Apr 2024 15:06:19 +0200 (CEST) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-570175e8e6fso5496221a12.3 for ; Wed, 17 Apr 2024 06:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1713359179; x=1713963979; 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=MfWumMaeixXTey66J4sZhsizHtQBqCnjM5wb6nathI8=; b=o6em1AadK8hfpHiLq8hZ5yzVzMAwZAoLQded6awS831c0OwV6hrYEoWKzIWWwcQa4P z2rP21C/2PSyCuBzg2cgwwLMXWsM3H0VUkTGTiZuEr+HD/rRmsbBj02EjwXoRkONa7G0 VIddVugoDDUylSeJ82qYP/vhhafs1/Su8GSZpO73hJWvyagQCgX0PomCZNFAR5LufpE0 LocF4jynxTO7wLjVtwad4xYBEP68CDAB2usnpUWCjsDdnkeMpLGIofTa41Nu7cO7BRpg TET5U8spELNIV1POks/MTyvJ7RICFbo2NC/UhtpPW7Rg/k+rKs3/sb5VCYPwIBvgsRdL JgZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713359179; x=1713963979; 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=MfWumMaeixXTey66J4sZhsizHtQBqCnjM5wb6nathI8=; b=uu6QAmEjbK5L51VuhFbrHyEyoddx1IMRnHirDx3BX+VejtPnrejZ2kqG2hM0MC16JD 5sM67JRTAr67ILYYw1OA3PoC05fhw+BuwOnIn7mQOtdxVgI2XZO7zNT2GWek8ZF9m6FC TDh2wGF/HT+0hha7rDRlY4A+oUcELH27/2gfSl50dMl/oOpOjrQBeauge6sTU/FRWcTF YWxU1Tx1BTGvnD8Pw2MuFc/WEE+WxaGmkuzho9B4Nvge1UmV5lbg69wNLq/q7EZw3t8E DQUF5ODRWm365ubVk3a0zU/jTQH6i7LBc/GShHA9ehkyBd6RxOat+ci2R3SD7dGcFLhS mbFA== X-Gm-Message-State: AOJu0YxfrgC11fnotSeas7rJxCiatXaQARMEhODFPTef2eFgQ/dFBb8z qwC6PxLCbEL9KFf3uyNjIn/69mcFA06qo/ocbh1AWKtXAO4KSR7V/n6E/sPPjAi2De4zihjFTGb tV08ITsppS6ESY7+EAofjBXPaXns+ktsFURJOug== X-Google-Smtp-Source: AGHT+IEuRn6Ml62aZl4Mi5u4055TYrrShrZgzzsHxORpjsjX05Rq7JG1bh522ASVA9YnYaoLGmZLfbmhe6sc+DaEUwk= X-Received: by 2002:a50:f61a:0:b0:56d:e73d:6d74 with SMTP id c26-20020a50f61a000000b0056de73d6d74mr10517700edn.12.1713359178891; Wed, 17 Apr 2024 06:06:18 -0700 (PDT) MIME-Version: 1.0 References: <20240412111136.3470304-1-luca.vizzarro@arm.com> <20240412111136.3470304-2-luca.vizzarro@arm.com> In-Reply-To: From: =?UTF-8?Q?Juraj_Linke=C5=A1?= Date: Wed, 17 Apr 2024 15:06:08 +0200 Message-ID: Subject: Re: [PATCH 1/5] dts: fix InteractiveShell command prompt filtering To: Luca Vizzarro Cc: dev@dpdk.org, Jeremy Spewock , Paul Szczepanek , Jack Bond-Preston 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:12=E2=80=AFPM Luca Vizzarro wrote: > > Thank you for your review Juraj! > > On 16/04/2024 09:40, Juraj Linke=C5=A1 wrote: > > >> When sending a command using an instance of InteractiveShell the outpu= t > >> is meant to filter out the leading shell prompt. The filtering logic i= s > >> present but the line is appended anyways. > >> > > > > I don't think that's what's happening here. The output collecting > > logic is "stop when we encounter a prompt, but not the prompt with the > > command we sent". We could change the comment though. > > Yeah, I actually identified the behaviour better after writing this. > Will update the commit body accordingly. And I mixed-up leading with > trailing! This is meant to say "trailing shell prompt". > > >> @@ -132,11 +132,11 @@ def send_command(self, command: str, prompt: str= | None =3D None) -> str: > >> self._stdin.flush() > >> out: str =3D "" > >> for line in self._stdout: > >> - out +=3D line > >> if prompt in line and not line.rstrip().endswith( > >> command.rstrip() > >> ): # ignore line that sent command > >> break > >> + out +=3D line > > > > If we do this, we'll only filter out the last prompt, which may not be > > desirable, since the last prompt is there only because all of our > > interactive shells force an extra prompt with _command_extra_chars. > > Could you please expand more on this? > Actually, filtering out the last prompt is fine. I got this mixed up with processing the last prompt. We must process the last prompt, but we don't need to print it (and there's not much reason to do so). And the reason we must process it is because we're consuming the output line by line. A line appears in (or is yielded by) self._stdout only after a newline appears in the output. For a typical command output: prompt> command\n \n prompt> The last line in self._stdout is the last line of because that's the last line with a newline. We send _command_extra_chars to force another prompt into the output: prompt> command\n \n prompt>\n prompt> Now the last line with a newline contains a prompt. The actual extra trailing prompt is then pushed to the next command execution: prompt_from_command1> command2\n \n Maybe you already knew this but maybe we could archive this and point to it in case anyone asks. :-) > > One thing we could improve though is removing the distribution welcome > > message from logs, or at least separate it from the first command sent > > with the interactive shell. The second option will allow us to see > > clearly that an interactive session has been established, although we > > could just emit a shorter log (something like "Started a testpmd > > session" and then flush the welcome screen output). > > I am not sure what you are referring to exactly, could you also expand > more on this please? > Let's look at logs. The first thing to note is we don't log when we start the interactive session. The first log from the session is the output from the first command, such as testpmd: 2024/04/11 13:29:27 - test_suite - dts.SUT 1 - INFO - Sending: 'sudo -- sh -c '/tmp/dpdk-22.07/x86_64-linux-native-gcc/app/dpdk-testpmd -l 1-2 -n 4 --file-prefix=3Ddpdk_71695_20240411132902 -a 0000:07:00.0 -a 0000:08:00.0 -- -i --nb-cores=3D1 --port-topology=3Dpaired --numa --tx-ip=3D198.18.0.1,198.18.0.2 --tx-udp=3D9 --forward-mode=3Dio --hairpin-mode=3D0x0 --rx-offloads=3D0x0 --rx-mq-mode=3D0x7 --tx-offloads=3D0x0 --mask-event=3Dintr_lsc --no-mlockall'' 2024/04/11 13:29:28 - test_suite - dts.SUT 1 - DEBUG - Got output: Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-97-generic x86_64)^M Last login: Thu Apr 11 11:24:44 2024 from 192.168.122.1^M^M sudo -- sh -c '/tmp/dpdk-22.07/x86_64-linux-native-gcc/app/dpdk-testpmd -l 1-2 -n 4 --file-prefix=3Ddpdk_71695_20240411132902 -a 0000:07:00.0 -a 0000:08:00.0 -- -i --nb-cores=3D1 --port-topology=3Dpaired --numa --tx-ip=3D198.18.0.1,198.18.0.2 --tx-udp=3D9 --forward-mode=3Dio --hairpin-mode=3D0x0 --rx-offloads=3D0x0 --rx-mq-mode=3D0x7 --tx-offloads=3D0x0 --mask-event=3Dintr_lsc --no-mlockall'^M ^M ^[[?2004hjlinkes@dts-sut:~$ sudo -- sh -c '/tmp/dpdk-22.07/x86_64-linux-native-gcc/app/dpdk-testpmd -l 1-2 -n 4 --file-prefix=3Ddpdk_71695_20240411132902 -a 0000:07:00.0 -a 0000:08:00.0 -- -i --nb-cores=3D1 --port-topology=3Dpaired --numa --tx-ip=3D198.18.0.1,198.18.0.2 --tx-udp=3D9 --forward-mode=3Dio --hairpin-mode=3D0x0 --rx-offloads=3D0x0 --rx-mq-mode=3D0x7 --tx-offloads=3D0x0 --mask-event=3Dintr_lsc --no-mlockall'^M ^[[?2004l^M^M EAL: Detected CPU lcores: 4^M Done^M testpmd> ^M^M 2024/04/11 13:29:28 - test_suite - dts.SUT 1 - INFO - Sending: 'show device info all' What we see is the testpmd command being sent and then the output is: Welcome screen Testpmd command we've sent Testpmd command echoed with the os prompt Testpmd output The next command What's extra is the welcome screen with the first command we've sent. We don't capture any output right after establishing the channel so it all stays there to be captured by the first command we send. > Given it's not particularly explained, I thought having two command > prompts (especially a trailing one) was an error. The main reason behind > this is that when we go to parse the port info, the last entry which is > "device private info" appears to be open ended, and I couldn't gather > much information from the testpmd source code. So I opted to parse > everything until the end. With a trailing command prompt this meant > that: device_private_info=3D"....testpmd> ". So the command output doesn't end with a newline? What's the exact output that's captured?