[PATCH v2] cmd: cat: add new command
Roger Knecht
rknecht at pm.me
Thu Aug 18 17:52:57 CEST 2022
------- Original Message -------
On Sunday, June 19th, 2022 at 15:08, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
>
> On 6/19/22 16:23, Roger Knecht wrote:
>
> > On Thursday, June 9th, 2022 at 22:27, Roger Knecht rknecht at pm.me wrote:
> >
> > > On Wednesday, June 8th, 2022 at 15:59, Tom Rini trini at konsulko.com wrote:
> > >
> > > > On Sat, Jun 04, 2022 at 11:19:15AM +0000, Roger Knecht wrote:
> > > >
> > > > > Add cat command to print file content to standard out
> > > > >
> > > > > Signed-off-by: Roger Knecht rknecht at pm.me
> > > > > ---
> > > > > v2:
> > > > > - Moved cat from boot to shell commands
> > > > > - Added MAINTAINERS entry
> > > > > - Added comments
> > > > > - Improved variable naming
> > > > >
> > > > > MAINTAINERS | 5 +++++
> > > > > cmd/Kconfig | 6 ++++++
> > > > > cmd/Makefile | 1 +
> > > > > cmd/cat.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > > > 4 files changed, 70 insertions(+)
> > > > > create mode 100644 cmd/cat.c
> > > > >
> > > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > > index 56be0bfad0..7c5cd178d9 100644
> > > > > --- a/MAINTAINERS
> > > > > +++ b/MAINTAINERS
> > > > > @@ -729,6 +729,11 @@ M: Simon Glass sjg at chromium.org
> > > > > S: Maintained
> > > > > F: tools/buildman/
> > > > >
> > > > > +CAT
> > > > > +M: Roger Knecht rknecht at pm.me
> > > > > +S: Maintained
> > > > > +F: cmd/cat.c
> > > > > +
> > > > > CFI FLASH
> > > > > M: Stefan Roese sr at denx.de
> > > > > S: Maintained
> > > > > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > > > > index 69c1814d24..8b531c7ebe 100644
> > > > > --- a/cmd/Kconfig
> > > > > +++ b/cmd/Kconfig
> > > > > @@ -1492,6 +1492,12 @@ endmenu
> > > > >
> > > > > menu "Shell scripting commands"
> > > > >
> > > > > +config CMD_CAT
> > > > > + bool "cat"
> > > > > + default y
> > > >
> > > > New commands shouldn't be default enabled. I also don't see a test.
> > > > Please add a test, and enable the command in sandbox so the test is run.
> > > > Thanks!
> > >
> > > Thanks for the review. Will be fixed in the next version.
> >
> > Hi Tom,
> >
> > I'm running into issues when writing a test for cat:
>
>
> Dear Roger,
>
> tests for console commands should be written in Python, see
> https://u-boot.readthedocs.io/en/latest/develop/py_testing.html.
>
> You will need a test fixture that generates the disk image with the file
> that you want to load and display in the test function. Have a look at
> test/py/tests/test_efi_bootmgr/ as an example.
Thanks Heinrich, that was helpful.
>
> We have different files that may be worth printing with 'cat':
>
> * UTF-8 text files like uEnv.txt
run_command() (test/py/u_boot_console_base.py) is causing problems when UTF-8 strings are returned.
I will skip the Unicode test for now. I might have time later to dig deeper.
> * script files like boot.scr that can be executed with the 'source' command
> * binary files
>
> I suggest that the 'cat' command should support all of these. For binary
> files you can use the print_hex_dump() function for console output.
This would require to auto detected binary files or at least need an additional parameter.
The Unix utility 'cat' does not have a hex mode.
As alternative I propose to implement a minimal 'xxd' for u-boot.
I hope that is alright for you.
>
> Please, provide a man-page for the 'cat' command in doc/usage/cmd/.
> You can use doc/usage/cmd/fatinfo.rst as a template.
Will do.
>
> Best regards
>
> Heinrich
Best regards,
Roger
More information about the U-Boot
mailing list