diff options
author | Tom Rini <trini@konsulko.com> | 2024-03-28 16:01:03 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-03-28 16:01:03 -0400 |
commit | 9468bf3a69b05bda05adb06f954b089ace301afc (patch) | |
tree | 69f66ca86003dd040bddfad5ef4b7a4874ebd163 /doc/usage | |
parent | a5ec56aea1a56737a4e124d058a6920d16f5e686 (diff) | |
parent | d2fbe1fa29190fc1209364b3d5e33294009da9bd (diff) |
Merge tag 'doc-2024-04-rc6' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request doc-2024-04-rc6
Documentation:
* man page of 'itest'
* tee: sandbox: fix spelling errors in function documentation
Diffstat (limited to 'doc/usage')
-rw-r--r-- | doc/usage/cmd/if.rst | 6 | ||||
-rw-r--r-- | doc/usage/cmd/itest.rst | 113 | ||||
-rw-r--r-- | doc/usage/index.rst | 1 |
3 files changed, 117 insertions, 3 deletions
diff --git a/doc/usage/cmd/if.rst b/doc/usage/cmd/if.rst index 6b3dbe7b0a..813f903a8d 100644 --- a/doc/usage/cmd/if.rst +++ b/doc/usage/cmd/if.rst @@ -33,11 +33,11 @@ test statement $? becomes 0 (true) the statements after the **then** statement will be executed. Otherwise the statements after the **else** statement. -Example -------- +Examples +-------- The examples shows how the value of a numeric variable can be tested with -**itest**. +the :doc:`itest <itest>` command. :: diff --git a/doc/usage/cmd/itest.rst b/doc/usage/cmd/itest.rst new file mode 100644 index 0000000000..ab933db760 --- /dev/null +++ b/doc/usage/cmd/itest.rst @@ -0,0 +1,113 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +.. index:: + single: itest (command) + +itest command +============= + +Synopsis +-------- + +:: + + itest[.b | .w | .l | .q | .s] [*]<value1> <op> [*]<value2> + +Description +----------- + +The itest command is used to compare two values. The return value $? is set +accordingly. + +By default it is assumed that the values are 4 byte integers. By appending a +postfix (.b, .w, .l, .q, .s) the size can be specified: + +======= ====================================================== +postfix meaning +======= ====================================================== +.b 1 byte integer +.w 2 byte integer +.l 4 byte integer +.q 8 byte integer (only available if CONFIG_PHYS_64BIT=y) +.s string +======= ====================================================== + +value1, value2 + values to compare. Numeric values are hexadecimal. If '*' is prefixed a + hexadecimal address is passed, which points to the value to be compared. + +op + operator, see table + + ======== ====================== + operator meaning + ======== ====================== + -lt less than + < less than + -le less or equal + <= less or equal + -eq equal + == equal + -ne not equal + != not equal + <> not equal + -ge greater or equal + >= greater or equal + -gt greater than + > greater than + ======== ====================== + +Examples +======== + +The itest command sets the result variable $? to true (0) or false (1): + +:: + + => itest 3 < 4; echo $? + 0 + => itest 3 == 4; echo $? + 1 + +This value can be used in the :doc:`if <if>` command: + +:: + + => if itest 0x3002 < 0x4001; then echo true; else echo false; fi + true + +Numbers will be truncated according to the postfix before comparing: + +:: + + => if itest.b 0x3002 < 0x4001; then echo true; else echo false; fi + false + +Postfix .s causes a string compare. The string '0xa1234' is alphabetically +smaller than '0xb'. + + => if itest.s 0xa1234 < 0xb; then echo true; else echo false; fi + true + +A value prefixed by '*' is a pointer to the value in memory. + +:: + + => mm 0x4000 + 00004000: 00000004 ? + 00004004: 00000003 ? => + => if itest *0x4000 == 4; then echo true; else echo false; fi + true + => if itest *0x4004 == 3; then echo true; else echo false; fi + true + +Configuration +------------- + +The command is only available if CONFIG_CMD_ITEST=y. + +Return value +------------ + +The return value $? is 0 (true) if the condition is true and 1 (false) +otherwise. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 66d73e70cc..2f211f748a 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -72,6 +72,7 @@ Shell commands cmd/history cmd/host cmd/if + cmd/itest cmd/imxtract cmd/load cmd/loadb |