From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
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 [thread overview]
Message-ID: <20231123023629.2024938-2-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20231123023629.2024938-1-david@gibson.dropbear.id.au>
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 <david@gibson.dropbear.id.au>
---
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
}
--
@@ -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
next prev parent reply other threads:[~2023-11-23 2:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 2:36 [PATCH 0/6] Introduce unified flow table, first steps David Gibson
2023-11-23 2:36 ` David Gibson [this message]
2023-11-23 2:36 ` [PATCH 2/6] flow, tcp: Generalise connection types David Gibson
2023-11-23 2:36 ` [PATCH 3/6] flow, tcp: Move TCP connection table to unified flow table David Gibson
2023-11-23 2:36 ` [PATCH 4/6] flow, tcp: Consolidate flow pointer<->index helpers David Gibson
2023-11-23 2:36 ` [PATCH 5/6] flow: Make unified version of flow table compaction David Gibson
2023-11-23 2:36 ` [PATCH 6/6] flow, tcp: Add logging helpers for connection related messages David Gibson
2023-11-23 6:58 ` Stefano Brivio
2023-11-23 22:14 ` David Gibson
2023-11-23 4:46 ` [PATCH 0/6] Introduce unified flow table, first steps David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231123023629.2024938-2-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).