Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Edgar Bonet <bonet@grenoble.cnrs.fr>, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] support/testing/infra/emulator.py: prevent the commands from wrapping
Date: Wed, 6 Oct 2021 09:11:04 +0200	[thread overview]
Message-ID: <20211006091104.0e61efd6@windsurf> (raw)
In-Reply-To: <20211005200111.GC2081069@scaer>

Hello Yann,

On Tue, 5 Oct 2021 22:01:11 +0200
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> 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!

And very good investigation too!

> 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?

We do:

  ./support/testing/tests/package/test_python_flask_expects_json.py

is such a test. The test is doing:

        self.assertEqual(output[-1], str(expects))

instead of:

        self.assertEqual(output[0], str(expects))

precisely to work around this issue. I.e instead of getting the first
line of the output (which would be the end of the command being
executed), I test against the last line of the output. It works in my
case because I know my "interesting" output has only a single line.

So, if that test works by using output[0] instead of output[-1], then
the fix of using stty columns 29999 would be confirmed to work!

Best regards,

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2021-10-06  7:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 17:17 [Buildroot] [PATCH 1/1] support/testing/infra/emulator.py: prevent the commands from wrapping Edgar Bonet
2021-10-05 20:01 ` Yann E. MORIN
2021-10-06  7:11   ` Thomas Petazzoni [this message]
2021-10-06 10:22     ` Edgar Bonet
2021-10-06 19:47       ` Yann E. MORIN
2021-10-06 19:56 ` Yann E. MORIN
2021-10-09 11:28 ` Peter Korsgaard

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=20211006091104.0e61efd6@windsurf \
    --to=thomas.petazzoni@bootlin.com \
    --cc=bonet@grenoble.cnrs.fr \
    --cc=buildroot@buildroot.org \
    --cc=yann.morin.1998@free.fr \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox