From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 134925A0276 for ; Thu, 23 Nov 2023 03:36:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1700706991; bh=HeMtXjDT3I/C/+yhYBI86Jqd7QNKOlZNRovSApi1M9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kXPaIbh9+mwToOtVYQNJKOtcSezq76lTrK+3kkkzb4M1LVZmor6IdC1ahuH3194Np v+vYdmWO6rUAwo/UE0uMPECpo4jpcxv6/hOY+2z1HZ07HHg+FMbhtuW7h4tYzFjYvT +znafXzwSLQHx7CvWlX4rAvY881Cu3Q+jgnMXDEY= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SbMgg6G9Zz4xR5; Thu, 23 Nov 2023 13:36:31 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 1/6] test: Make handling of shell prompts with escapes a little more reliable Date: Thu, 23 Nov 2023 13:36:24 +1100 Message-ID: <20231123023629.2024938-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231123023629.2024938-1-david@gibson.dropbear.id.au> References: <20231123023629.2024938-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: EU4IKTIGU6IWEKSGVCHUFNY2KJ7S7PHI X-Message-ID-Hash: EU4IKTIGU6IWEKSGVCHUFNY2KJ7S7PHI X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When using the old-style "pane" methods of executing commands during the tests, we need to scan the shell output for prompts in order to tell when commands have finished. This is inherently unreliable because commands could output things that look like prompts, and prompts might not look like we expect them to. The only way to really fix this is to use a better way of dispatching commands, like the newer "context" system. However, it's awkward to convert everything to "context" right at the moment, so we're still relying on some tests that do work most of the time. It is, however, particularly sensitive to fancy coloured prompts using escape sequences. Currently we try to handle this by stripping actual ESC characters with tr, then looking for some common variants. We can do a bit better: instead strip all escape sequences using sed before looking for our prompt. Or, at least, any one using [a-zA-Z] as the terminating character. Strictly speaking ANSI escapes can be terminated by any character in 0x40..0x7e, which isn't easily expressed in a regexp. This should capture all common ones, though. With this transformation we can simplify the list of patterns we then look for as a prompt, removing some redundant variants. Signed-off-by: David Gibson --- test/lib/term | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/lib/term b/test/lib/term index aa05bf1..262937e 100755 --- a/test/lib/term +++ b/test/lib/term @@ -203,11 +203,9 @@ pane_wait() { __done=0 while - __l="$(tail -1 ${LOGDIR}/pane_${__lc}.log | tr -d [:cntrl:])" + __l="$(tail -1 ${LOGDIR}/pane_${__lc}.log | sed 's/[[][^a-zA-Z]*[a-zA-Z]//g')" case ${__l} in - '$ ' | '# ' | '# # ' | *"$ " | *"# ") return ;; - *" #[m " | *" #[m [K" | *"]# ["*) return ;; - *' $ [6n' | *' # [6n' ) return ;; + *"$ " | *"# ") return ;; esac do sleep 0.1 || sleep 1; done } -- 2.42.0