[U-Boot] test vs itest command confusion when using setexpr
Jörg Krause
joerg.krause at embedded.rocks
Sat Jan 19 22:05:24 UTC 2019
Hi,
I noticed a difference between the `test` and the `itest` command when
using `setexpr`:
Running the test vs the itest command in the shell:
```
=> setexpr i 0xf; while test ${i} -gt 0; do echo $i; setexpr i ${i} - 1; done
=> setexpr i 0xf; while itest ${i} -gt 0; do echo $i; setexpr i ${i} - 1; done
f
e
d
c
b
a
9
8
7
6
5
4
3
2
1
=>
```
The difference between the test and the itest command is that the
integer operations for the test command is done using the base of 10
while for the itest command the operations are done using a base of 16.
lib/test.c
```
simple_strtol(ap[0], NULL, 10) > simple_strtol(ap[2], NULL, 10);
```
lib/itest.c
```
simple_strtol(s, NULL, 16) > simple_strtol(t, NULL, 16);
```
As setexpr stores the variables as hex values, it becomes obvious why
`itest` works, but `test` does not. Is this different behaviour
intended?
Best regards
Jörg Krause
More information about the U-Boot
mailing list