[PATCH v4 compass-ci 1/2] qemu/kvm.sh: optimize the prompt when the error occurs

Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/qemu/kvm.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 35678fbd44ef..f8246e828359 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -6,6 +6,9 @@ : ${nr_cpu:=1} : ${memory:=1G} +: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh check_logfile() { @@ -52,15 +55,23 @@ parse_ipxe_script() check_option_value() { + [ -n "$kernel" ] || { + log_info "Can not find job for current hostname: $hostname." + exit 0 + } + [ -s "$kernel" ] || { - echo "The kernel does not exist: $kernel" - exit + log_error "Can not find kernel file or kernel file is empty: $kernel." + exit 1 } # debian has both qemu-system-x86_64 and qemu-system-riscv64 command [[ $kernel =~ 'riscv64' ]] && qemu=qemu-system-riscv64 - [ -n "$initrds" ] || exit + [ -n "$initrds" ] || { + log_error "The current initrds is null." + exit 1 + } } set_initrd() -- 2.23.0

On Wed, Jan 20, 2021 at 09:11:46AM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/qemu/kvm.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 35678fbd44ef..f8246e828359 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -6,6 +6,9 @@
: ${nr_cpu:=1} : ${memory:=1G} +: ${LKP_SRC:="/c/lkp-tests"} ^ no need add this line, on qemu.sh have been used $LKP_SRC so you can use it directly
+ +source ${LKP_SRC}/lib/log.sh
i tnink use . may be better Thanks, Shenwei
check_logfile() { @@ -52,15 +55,23 @@ parse_ipxe_script()
check_option_value() { + [ -n "$kernel" ] || { + log_info "Can not find job for current hostname: $hostname." + exit 0 + } + [ -s "$kernel" ] || { - echo "The kernel does not exist: $kernel" - exit + log_error "Can not find kernel file or kernel file is empty: $kernel." + exit 1 }
# debian has both qemu-system-x86_64 and qemu-system-riscv64 command [[ $kernel =~ 'riscv64' ]] && qemu=qemu-system-riscv64
- [ -n "$initrds" ] || exit + [ -n "$initrds" ] || { + log_error "The current initrds is null." + exit 1 + } }
set_initrd() -- 2.23.0
participants (2)
-
Xiao Shenwei
-
Yu Chuan