"Das U-Boot" Source Tree
at master 115 lines 2.6 kB view raw
1.. SPDX-License-Identifier: GPL-2.0+ 2 3.. index:: 4 single: itest (command) 5 6itest command 7============= 8 9Synopsis 10-------- 11 12:: 13 14 itest[.b | .w | .l | .q | .s] [*]<value1> <op> [*]<value2> 15 16Description 17----------- 18 19The itest command is used to compare two values. The return value $? is set 20accordingly. 21 22By default it is assumed that the values are 4 byte integers. By appending a 23postfix (.b, .w, .l, .q, .s) the size can be specified: 24 25======= ====================================================== 26postfix meaning 27======= ====================================================== 28.b 1 byte integer 29.w 2 byte integer 30.l 4 byte integer 31.q 8 byte integer (only available if CONFIG_PHYS_64BIT=y) 32.s string 33======= ====================================================== 34 35value1, value2 36 values to compare. Numeric values are hexadecimal. If '*' is prefixed a 37 hexadecimal address is passed, which points to the value to be compared. 38 39op 40 operator, see table 41 42 ======== ====================== 43 operator meaning 44 ======== ====================== 45 -lt less than 46 < less than 47 -le less or equal 48 <= less or equal 49 -eq equal 50 == equal 51 -ne not equal 52 != not equal 53 <> not equal 54 -ge greater or equal 55 >= greater or equal 56 -gt greater than 57 > greater than 58 ======== ====================== 59 60Examples 61-------- 62 63The itest command sets the result variable $? to true (0) or false (1): 64 65:: 66 67 => itest 3 < 4; echo $? 68 0 69 => itest 3 == 4; echo $? 70 1 71 72This value can be used in the :doc:`if <if>` command: 73 74:: 75 76 => if itest 0x3002 < 0x4001; then echo true; else echo false; fi 77 true 78 79Numbers will be truncated according to the postfix before comparing: 80 81:: 82 83 => if itest.b 0x3002 < 0x4001; then echo true; else echo false; fi 84 false 85 86Postfix .s causes a string compare. The string '0xa1234' is alphabetically 87smaller than '0xb'. 88 89:: 90 91 => if itest.s 0xa1234 < 0xb; then echo true; else echo false; fi 92 true 93 94A value prefixed by '*' is a pointer to the value in memory. 95 96:: 97 98 => mm 0x4000 99 00004000: 00000004 ? 100 00004004: 00000003 ? => 101 => if itest *0x4000 == 4; then echo true; else echo false; fi 102 true 103 => if itest *0x4004 == 3; then echo true; else echo false; fi 104 true 105 106Configuration 107------------- 108 109The command is only available if CONFIG_CMD_ITEST=y. 110 111Return value 112------------ 113 114The return value $? is 0 (true) if the condition is true and 1 (false) 115otherwise.