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

Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/qemu/kvm.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 35678fbd44ef..f1d65272dbf9 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -52,15 +52,23 @@ parse_ipxe_script() check_option_value() { + [ -n "$kernel" ] || { + echo "[ERROR] Can not find job for current hostname: $hostname." + exit 1 + } + [ -s "$kernel" ] || { - echo "The kernel does not exist: $kernel" - exit + echo "[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" ] || { + echo "[ERROR] Can not find any initrd for current vm." + exit 1 + } } set_initrd() -- 2.23.0

On Fri, Jan 15, 2021 at 05:59:18PM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/qemu/kvm.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 35678fbd44ef..f1d65272dbf9 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -52,15 +52,23 @@ parse_ipxe_script()
check_option_value() { + [ -n "$kernel" ] || { + echo "[ERROR] Can not find job for current hostname: $hostname." + exit 1 + } + [ -s "$kernel" ] || { - echo "The kernel does not exist: $kernel" - exit + echo "[ERROR] Can not find kernel file or kernel file is empty: $kernel."
no job is normal, why define it error? if we do this, when i read this message, i feel an error occurred in the program Thanks, Shenwei
+ 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" ] || { + echo "[ERROR] Can not find any initrd for current vm." + exit 1 + } }
set_initrd() -- 2.23.0

On Mon, Jan 18, 2021 at 09:50:03AM +0800, Xiao Shenwei wrote:
On Fri, Jan 15, 2021 at 05:59:18PM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/qemu/kvm.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 35678fbd44ef..f1d65272dbf9 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -52,15 +52,23 @@ parse_ipxe_script()
check_option_value() { + [ -n "$kernel" ] || { + echo "[ERROR] Can not find job for current hostname: $hostname." + exit 1 + } + [ -s "$kernel" ] || { - echo "The kernel does not exist: $kernel" - exit + echo "[ERROR] Can not find kernel file or kernel file is empty: $kernel."
no job is normal, why define it error?
if we do this, when i read this message, i feel an error occurred in the program
Good! I'll modify here as follow: no job => INFO have job, but cannot wget kernel file or kernel file is empty => ERROR -------- Thanks Yu Chuan
Thanks, Shenwei
+ 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" ] || { + echo "[ERROR] Can not find any initrd for current vm." + exit 1 + } }
set_initrd() -- 2.23.0

+ echo "[ERROR] Can not find kernel file or kernel file is empty: $kernel."
no job is normal, why define it error?
if we do this, when i read this message, i feel an error occurred in the program
Good! I'll modify here as follow: no job => INFO have job, but cannot wget kernel file or kernel file is empty => ERROR
一个日志函数会不会好一些. 用一个日志模板去输出信息, 以后想修改的话直接修改模板就行. Thanks, RenWen
-------- Thanks Yu Chuan
Thanks, Shenwei
+ 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" ] || { + echo "[ERROR] Can not find any initrd for current vm." + exit 1 + } }
set_initrd() -- 2.23.0

On Mon, Jan 18, 2021 at 02:53:10PM +0800, Ren Wen wrote:
+ echo "[ERROR] Can not find kernel file or kernel file is empty: $kernel."
no job is normal, why define it error?
if we do this, when i read this message, i feel an error occurred in the program
Good! I'll modify here as follow: no job => INFO have job, but cannot wget kernel file or kernel file is empty => ERROR
一个日志函数会不会好一些. 用一个日志模板去输出信息, 以后想修改的话直接修改模板就行.
Good, lkp-tests has log.sh and log.rb in lib/ dir, I have been wondering why there is no such a file in compass-ci. -------- Thanks Yu Chuan
Thanks, RenWen
-------- Thanks Yu Chuan
Thanks, Shenwei
+ 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" ] || { + echo "[ERROR] Can not find any initrd for current vm." + exit 1 + } }
set_initrd() -- 2.23.0
participants (3)
-
Ren Wen
-
Xiao Shenwei
-
Yu Chuan