[RFC PATCH 0/6] Add C tests for hush
Francis Laniel
francis.laniel at amarulasolutions.com
Fri Aug 20 17:48:33 CEST 2021
Hi everyone.
First, I hope you are fine and the same for your relatives.
This series introduces C tests for hush.
The main goal of these tests is to act as regression tests in case of hush being
modified.
During their writings some bugs were found, unfortunately I did not write
patches to fix them.
First, I think these bugs were present in Busybox when hush was taken from.
Also, as the whole U-Boot board scripts seem to work with these bugs maybe
correcting them can lead to breaking things somewhere...
This is why I marked this series as RFC as I would like the hear the opinion of
the community on this problem.
Regarding the series, first commit introduces a new subcommand to ut: ut hush.
Then, others add tests for the following:
* if test condition: All these tests were taken from test_hush_if_test.py which
was then removed.
* variable expansion: These tests ensures variable expansion is correct. While
writing them a bug was found in hush where the following:
foo='bar "quux'
echo $foo
prints:
bar quux
instead of:
bar "quux
* commands lists: These tests test several command separated by ';', "&&" and
"||". Here also, some bugs were found, indeed the following:
false && false || true
returns 0 in actual (2021) hush's Busybox, while it returns 1 in U-Boot.
* loops: This test is quite simple as we do not have math support in U-Boot,
this can be tricky to heavily test while and until loops.
To conclude, here is this series diffstat:
Francis Laniel (6):
test: Add framework to test hush behavior.
test: hush: Test hush if/else.
test/py: hush_if_test: Remove the test file.
test: hush: Test hush variable expansion.
test: hush: Test hush commands list.
test: hush: Test hush loops.
include/test/hush.h | 15 ++
include/test/suites.h | 1 +
test/Makefile | 3 +
test/cmd_ut.c | 6 +
test/hush/Makefile | 10 +
test/hush/cmd_ut_hush.c | 20 ++
test/hush/dollar.c | 188 ++++++++++++++++++
test/hush/if.c | 308 +++++++++++++++++++++++++++++
test/hush/list.c | 79 ++++++++
test/hush/loop.c | 64 ++++++
test/py/tests/test_hush_if_test.py | 192 ------------------
11 files changed, 694 insertions(+), 192 deletions(-)
create mode 100644 include/test/hush.h
create mode 100644 test/hush/Makefile
create mode 100644 test/hush/cmd_ut_hush.c
create mode 100644 test/hush/dollar.c
create mode 100644 test/hush/if.c
create mode 100644 test/hush/list.c
create mode 100644 test/hush/loop.c
delete mode 100644 test/py/tests/test_hush_if_test.py
Best regards.
--
2.25.1
More information about the U-Boot
mailing list