[PATCH] cmd: test: Add operators to deal with hexadecimal numbers.
Simon Glass
sjg at chromium.org
Thu Mar 12 04:22:57 CET 2020
On Wed, 11 Mar 2020 at 16:47, Christoph Muellner <
christoph.muellner at theobroma-systems.com> wrote:
>
> The DLUG states the following:
> Almost all U-Boot commands expect numbers to be entered in hexadecimal
> input format.
>
> Besides this fact, also most commands output hex values.
>
> Given this facts, we need to be able to use the information provided
> by to/from commands in scripts. The test command does not support
> operating on hexadecimal input formats. This leads to very surprising
> tests like this (simple_strtol("ff", 10) == 0):
>
> => if test "ff" -eq 0; then echo "equal"; fi
> equal
> =>
>
> This patch introduces comparison operators for the test command,
> that allow parameters in hexadecimal format. So the test above
> can be implemented as follows:
>
> => if test "ff" -heq 0; then echo "equal"; fi
> =>
>
> [1] https://www.denx.de/wiki/view/DULG/UBootCommandLineInterface
>
> Signed-off-by: Christoph Muellner <
christoph.muellner at theobroma-systems.com>
>
> ---
>
> cmd/test.c | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
Reviewed-by: Simon Glass <sjg at chromium.org>
This is a good oppty to add a test in cmd_ut.c
See ut_assert_nextline() for example.
Regards,
SImon
More information about the U-Boot
mailing list