[Buildroot] [PATCH 1/1] support/testing/infra/emulator.py: prevent the commands from wrapping

Yann E. MORIN yann.morin.1998 at free.fr
Tue Oct 5 20:01:11 UTC 2021


Edgar, All,

+Thomas

On 2021-10-05 19:17 +0200, Edgar Bonet spake thusly:
> Traditional VT-10x terminals (and their emulators) have a "magic
> margins" feature that enables the last character position to be updated
> without scrolling the screen: whenever a character is printed on the
> last column, the cursor stays over the character, instead of moving to
> the next line.
> 
> The Busybox shell, ash, attempts to defeat this feature by printing
> CF,LF right after echoing a character to the last column.[1] This
> doesn't play well with emulator.py. The run() method of the Emulator
> class captures the output of the emulated system and assumes the first
> line it reads is the echo of the command, and all subsequent lines are
> the command's output. If the line made by the command + shell prompt is
> longer than 80 characters, then it is echoed as two or more lines, and
> all but the first one are mistaken for the command's output.
> 
> We fix this by telling the emulated system that we are using an
> ultra-wide terminal with 29999 columns. Larger values would be ignored
> and replaced by the default, namely 80 columns.[2]
> 
> [1] https://git.busybox.net/busybox/tree/libbb/lineedit.c?h=1_34_0#n412
> [2] https://git.busybox.net/busybox/tree/libbb/xfuncs.c?h=1_34_0#n258

Woot! Very, very good commit log, thanks!

So I decided to investigate those "magic margins" (I'm a grey beard,
but not that grey yet, so I missed that info). And thus I stumbled on
that (and yes, I've now bookmarked that for future reference; I'm just
torn between bookmarking in the "software" or "hardware" categories...
:-] ):

    https://vt100.net/docs/vt100-ug/chapter3.html

    DECAWM – Autowrap Mode (DEC Private)

    The reset state causes any displayable characters received when the
    cursor is at the right margin to replace any previous characters
    there. The set state causes these characters to advance to the start
    of the next line, doing a scroll up if required and permitted.

But that seems to be DEC-only, and I could not get a better, more
generic hit.

> Signed-off-by: Edgar Bonet <bonet at grenoble.cnrs.fr>
> Reported-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
> Co-authored-by: Yann E. MORIN <yann.morin.1998 at free.fr>
> ---
>  support/testing/infra/emulator.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> Note that I tested that the command
> 
>     stty columns 29999
> 
> does fix the wrapping behavior on an actual board, while using a serial
> connection. I did not test the script emulator.py, as I am unfamiliar
> with the testing infrastructure. Would someone volunteer to do that
> test?

The thing is, as Thomas said, he had the issue with new tests he was
adding to the infra; we currently do not have tests with commands that
are too long to be wrapped.

Thomas?

> diff --git a/support/testing/infra/emulator.py b/support/testing/infra/emulator.py
> index 0a77eb80fc..f1f5eac3a8 100644
> --- a/support/testing/infra/emulator.py
> +++ b/support/testing/infra/emulator.py
> @@ -100,6 +100,8 @@ class Emulator(object):
>          if index != 0:
>              raise SystemError("Cannot login")
>          self.run("dmesg -n 1")
> +        # Prevent the shell from wrapping the commands at 80 columns.
> +        self.run("stty columns 29999")

I would do that even before running dmesg. No need to resend, we can
change when applying, unless there is a good reason not to.

Regards,
Yann E. MORIN.

>      # Run the given 'cmd' with a 'timeout' on the target
>      # return a tuple (output, exit_code)
> -- 
> 2.25.1
> _______________________________________________
> buildroot mailing list
> buildroot at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'


More information about the buildroot mailing list