Message ID | 20231123023058.2963551-2-lizhijian@fujitsu.com |
---|---|
State | New, archived |
Headers | show |
Series | [ndctl,1/3] test/cxl-region-sysfs.sh: covert size and resource to hex before test | expand |
Li Zhijian wrote: > Fix errors: > line 111: [: 0x80000000: integer expression expected > line 112: [: 0x3ff110000000: integer expression expected > line 141: [: 0x80000000: integer expression expected > line 143: [: 0x3ff110000000: integer expression expected Similar commentary on how found and how someone knows that they need this patch, and maybe a note about which version of bash is upset about this given this problem has been present for a long time without issue. > > Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> > --- > test/cxl-region-sysfs.sh | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh > index ded7aa1..89f21a3 100644 > --- a/test/cxl-region-sysfs.sh > +++ b/test/cxl-region-sysfs.sh > @@ -108,8 +108,8 @@ do > > sz=$(cat /sys/bus/cxl/devices/$i/size) > res=$(cat /sys/bus/cxl/devices/$i/start) > - [ $sz -ne $region_size ] && err "$LINENO: decoder: $i sz: $sz region_size: $region_size" > - [ $res -ne $region_base ] && err "$LINENO: decoder: $i base: $res region_base: $region_base" > + [ "$sz" != "$region_size" ] && err "$LINENO: decoder: $i sz: $sz region_size: $region_size" > + [ "$res" != "$region_base" ] && err "$LINENO: decoder: $i base: $res region_base: $region_base" maybe use ((sz != region_size)) to make it explicit that this is an arithmetic comparison? I would defer to Vishal's preference here.
On 07/12/2023 05:35, Dan Williams wrote: > Li Zhijian wrote: >> Fix errors: >> line 111: [: 0x80000000: integer expression expected >> line 112: [: 0x3ff110000000: integer expression expected >> line 141: [: 0x80000000: integer expression expected >> line 143: [: 0x3ff110000000: integer expression expected > > Similar commentary on how found and how someone knows that they need > this patch, and maybe a note about which version of bash is upset about > this given this problem has been present for a long time without issue. I think it impacted all version of BASH (tested on bash 4.1, 4.2, 5.0, 5.1) > >> >> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> >> --- >> test/cxl-region-sysfs.sh | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh >> index ded7aa1..89f21a3 100644 >> --- a/test/cxl-region-sysfs.sh >> +++ b/test/cxl-region-sysfs.sh >> @@ -108,8 +108,8 @@ do >> >> sz=$(cat /sys/bus/cxl/devices/$i/size) >> res=$(cat /sys/bus/cxl/devices/$i/start) >> - [ $sz -ne $region_size ] && err "$LINENO: decoder: $i sz: $sz region_size: $region_size" >> - [ $res -ne $region_base ] && err "$LINENO: decoder: $i base: $res region_base: $region_base" >> + [ "$sz" != "$region_size" ] && err "$LINENO: decoder: $i sz: $sz region_size: $region_size" >> + [ "$res" != "$region_base" ] && err "$LINENO: decoder: $i base: $res region_base: $region_base" > > maybe use ((sz != region_size)) to make it explicit that this is an > arithmetic comparison? I would defer to Vishal's preference here. Per bash man page, we can also use [[ ]] instead of [ ], so that we are able to get rid of patch1 arg1 OP arg2 OP is one of -eq, -ne, -lt, -le, -gt, or -ge. These arithmetic binary operators return true if arg1 is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to arg2, respectively. Arg1 and arg2 may be positive or negative integers. When used with the [[ command, Arg1 and Arg2 are evaluated as arithmetic expressions (see ARITHMETIC EVALUATION above).
diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh index ded7aa1..89f21a3 100644 --- a/test/cxl-region-sysfs.sh +++ b/test/cxl-region-sysfs.sh @@ -108,8 +108,8 @@ do sz=$(cat /sys/bus/cxl/devices/$i/size) res=$(cat /sys/bus/cxl/devices/$i/start) - [ $sz -ne $region_size ] && err "$LINENO: decoder: $i sz: $sz region_size: $region_size" - [ $res -ne $region_base ] && err "$LINENO: decoder: $i base: $res region_base: $region_base" + [ "$sz" != "$region_size" ] && err "$LINENO: decoder: $i sz: $sz region_size: $region_size" + [ "$res" != "$region_base" ] && err "$LINENO: decoder: $i base: $res region_base: $region_base" done # validate all switch decoders have the correct settings @@ -143,9 +143,9 @@ do res=$(decimal_to_hex $(echo $decoder | jq -r ".resource")) sz=$(decimal_to_hex $(echo $decoder | jq -r ".size")) - [ $sz -ne $region_size ] && err \ + [ "$sz" != "$region_size" ] && err \ "$LINENO: decoder: $i sz: $sz region_size: $region_size" - [ $res -ne $region_base ] && err \ + [ "$res" != "$region_base" ] && err \ "$LINENO: decoder: $i base: $res region_base: $region_base" done
Fix errors: line 111: [: 0x80000000: integer expression expected line 112: [: 0x3ff110000000: integer expression expected line 141: [: 0x80000000: integer expression expected line 143: [: 0x3ff110000000: integer expression expected Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> --- test/cxl-region-sysfs.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)