[PATCH lkp-tests] tests: fix error when running host-info in vm

Error: Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No such file or directory Signed-off-by: Zhang Yu <2134782174@qq.com> --- tests/host-info | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/host-info b/tests/host-info index 0ab8e6c97..7513d6073 100755 --- a/tests/host-info +++ b/tests/host-info @@ -102,8 +102,9 @@ get_ipmi_ip() # 802.1q VLAN ID : Disabled # RMCP+ Cipher Suites : 0,1,2,3,17 # Cipher Suite Priv Max : XuuaXXXXXXXXXXX - is_virt && return - is_docker && return + [[ -e /dev/ipmi0 ]] || return + [[ -e /dev/ipmi/0 ]] || return + [[ -e /dev/ipmidev/0 ]] || return local ip=$(ipmitool lan print | awk 'NR==3{print $4}') [ -n "$ip" ] && echo "ipmi_ip: $ip" -- 2.23.0

- is_virt && return - is_docker && return + [[ -e /dev/ipmi0 ]] || return + [[ -e /dev/ipmi/0 ]] || return + [[ -e /dev/ipmidev/0 ]] || return local ip=$(ipmitool lan print | awk 'NR==3{print $4}') [ -n "$ip" ] && echo "ipmi_ip: $ip"
Please keep the context consistent: All '[[ ]]' or '[ ]'. Thanks, RenWen
-- 2.23.0

On Wed, Dec 16, 2020 at 03:37:38PM +0800, Zhang Yu wrote:
Error: Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No such file or directory
Signed-off-by: Zhang Yu <2134782174@qq.com> --- tests/host-info | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tests/host-info b/tests/host-info index 0ab8e6c97..7513d6073 100755 --- a/tests/host-info +++ b/tests/host-info @@ -102,8 +102,9 @@ get_ipmi_ip() # 802.1q VLAN ID : Disabled # RMCP+ Cipher Suites : 0,1,2,3,17 # Cipher Suite Priv Max : XuuaXXXXXXXXXXX - is_virt && return - is_docker && return + [[ -e /dev/ipmi0 ]] || return + [[ -e /dev/ipmi/0 ]] || return + [[ -e /dev/ipmidev/0 ]] || return
需要三个文件都存在吗? 还是一个就够了? 看看ipmitool具体啥要求。
local ip=$(ipmitool lan print | awk 'NR==3{print $4}') [ -n "$ip" ] && echo "ipmi_ip: $ip"
-- 2.23.0
participants (3)
-
Ren Wen
-
Wu Fengguang
-
Zhang Yu