[PATCH] cmd: test: Add operators to deal with hexadecimal numbers.
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
> 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
>  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.
More information about the U-Boot