[PATCH lkp-tests] tests/host-info: fix host-info script running error

[why] The ipmi command just run in physical machine, the vm not support use ipmi command [how] Add a judgment only physical machine run ipmi operation Signed-off-by: Zhang Yu <2134782174@qq.com> --- tests/host-info | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/host-info b/tests/host-info index 84f796dcb..f222a7287 100755 --- a/tests/host-info +++ b/tests/host-info @@ -1,5 +1,7 @@ #!/bin/bash +. $LKP_SRC/lib/env.sh + get_memory() { memory_total=$(cat /proc/meminfo |grep MemTotal | awk '{print $2}') @@ -101,6 +103,7 @@ get_ipmi_ip() # 802.1q VLAN ID : Disabled # RMCP+ Cipher Suites : 0,1,2,3,17 # Cipher Suite Priv Max : XuuaXXXXXXXXXXX + [ is_virt || is_docker ] && return local ip=$(ipmitool lan print | awk 'NR==3{print $4}') [ -n "$ip" ] && echo "ipmi_ip:" $ip -- 2.23.0

On Tue, Dec 15, 2020 at 05:23:29PM +0800, Zhang Yu wrote:
[why] The ipmi command just run in physical machine, the vm not support use ipmi command
[how] Add a judgment only physical machine run ipmi operation
Signed-off-by: Zhang Yu <2134782174@qq.com> --- tests/host-info | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/tests/host-info b/tests/host-info index 84f796dcb..f222a7287 100755 --- a/tests/host-info +++ b/tests/host-info @@ -1,5 +1,7 @@ #!/bin/bash
+. $LKP_SRC/lib/env.sh + get_memory() { memory_total=$(cat /proc/meminfo |grep MemTotal | awk '{print $2}') @@ -101,6 +103,7 @@ get_ipmi_ip() # 802.1q VLAN ID : Disabled # RMCP+ Cipher Suites : 0,1,2,3,17 # Cipher Suite Priv Max : XuuaXXXXXXXXXXX + [ is_virt || is_docker ] && return
Can't use '||' with '[' in bash. FYI: - https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.ht... - https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.htm... Thanks, RenWen
local ip=$(ipmitool lan print | awk 'NR==3{print $4}') [ -n "$ip" ] && echo "ipmi_ip:" $ip
-- 2.23.0

On Tue, Dec 15, 2020 at 05:41:29PM +0800, Ren Wen wrote:
On Tue, Dec 15, 2020 at 05:23:29PM +0800, Zhang Yu wrote:
[why] The ipmi command just run in physical machine, the vm not support use ipmi command
[how] Add a judgment only physical machine run ipmi operation
Signed-off-by: Zhang Yu <2134782174@qq.com> --- tests/host-info | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/tests/host-info b/tests/host-info index 84f796dcb..f222a7287 100755 --- a/tests/host-info +++ b/tests/host-info @@ -1,5 +1,7 @@ #!/bin/bash
+. $LKP_SRC/lib/env.sh + get_memory() { memory_total=$(cat /proc/meminfo |grep MemTotal | awk '{print $2}') @@ -101,6 +103,7 @@ get_ipmi_ip() # 802.1q VLAN ID : Disabled # RMCP+ Cipher Suites : 0,1,2,3,17 # Cipher Suite Priv Max : XuuaXXXXXXXXXXX + [ is_virt || is_docker ] && return
Can't use '||' with '[' in bash.
how about -o , it means 'or' Thanks, Kaiyi
FYI: - https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.ht... - https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.htm...
Thanks, RenWen
local ip=$(ipmitool lan print | awk 'NR==3{print $4}') [ -n "$ip" ] && echo "ipmi_ip:" $ip
-- 2.23.0

Can't use '||' with '[' in bash.
how about -o , it means 'or'
good, Thanks, Zhangyu
Thanks, Kaiyi
FYI: - https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.ht... - https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.htm...
Thanks, RenWen
local ip=$(ipmitool lan print | awk 'NR==3{print $4}') [ -n "$ip" ] && echo "ipmi_ip:" $ip
-- 2.23.0

Can't use '||' with '[' in bash.
ok, Thanks, Zhangyu
FYI: - https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.ht... - https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.htm...
Thanks, RenWen
local ip=$(ipmitool lan print | awk 'NR==3{print $4}') [ -n "$ip" ] && echo "ipmi_ip:" $ip
-- 2.23.0
participants (3)
-
Lu Kaiyi
-
Ren Wen
-
Zhang Yu