Signed-off-by: Yu Chuan 13186087857@163.com --- lib/log.sh | 32 ++++++++++++++++++++++++++++++++ providers/qemu/kvm.sh | 12 ++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 lib/log.sh
diff --git a/lib/log.sh b/lib/log.sh new file mode 100644 index 000000000000..56b08f77b3d0 --- /dev/null +++ b/lib/log.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +die() +{ + log_error "$@" + exit 1 +} + +log() +{ + log_info "$@" +} + +log_info() +{ + echo "$(date +'%F %T') INFO -- $*" +} + +log_debug() +{ + echo "$(date +'%F %T') DEBUG -- $*" +} + +log_warn() +{ + echo "$(date +'%F %T') WARN -- $*" >&2 +} + +log_error() +{ + echo "$(date +'%F %T') ERROR -- $*" >&2 +} diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 35678fbd44ef..a136c8ff45cb 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -4,6 +4,8 @@ # - nr_cpu # - memory
+source $CCI_SRC/lib/log.sh + : ${nr_cpu:=1} : ${memory:=1G}
@@ -52,15 +54,17 @@ parse_ipxe_script()
check_option_value() { - [ -s "$kernel" ] || { - echo "The kernel does not exist: $kernel" - exit + [ -n "$kernel" ] || { + log_info "Can not find job for current hostname: $hostname." + exit 0 } + + [ -s "$kernel" ] || die "Can not find kernel file or kernel file is empty: $kernel." # debian has both qemu-system-x86_64 and qemu-system-riscv64 command [[ $kernel =~ 'riscv64' ]] && qemu=qemu-system-riscv64
- [ -n "$initrds" ] || exit + [ -n "$initrds" ] || die "Can not find any initrd for current vm." }
set_initrd()
On Mon, Jan 18, 2021 at 03:41:41PM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan 13186087857@163.com
lib/log.sh | 32 ++++++++++++++++++++++++++++++++ providers/qemu/kvm.sh | 12 ++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 lib/log.sh
lkp-tests also have same file log.sh, why not use that one?
Thanks, Yinsi
diff --git a/lib/log.sh b/lib/log.sh new file mode 100644 index 000000000000..56b08f77b3d0 --- /dev/null +++ b/lib/log.sh @@ -0,0 +1,32 @@ +#!/bin/bash
+die() +{
- log_error "$@"
- exit 1
+}
+log() +{
- log_info "$@"
+}
+log_info() +{
- echo "$(date +'%F %T') INFO -- $*"
+}
+log_debug() +{
- echo "$(date +'%F %T') DEBUG -- $*"
+}
+log_warn() +{
- echo "$(date +'%F %T') WARN -- $*" >&2
+}
+log_error() +{
- echo "$(date +'%F %T') ERROR -- $*" >&2
+} diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 35678fbd44ef..a136c8ff45cb 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -4,6 +4,8 @@ # - nr_cpu # - memory
+source $CCI_SRC/lib/log.sh
: ${nr_cpu:=1} : ${memory:=1G}
@@ -52,15 +54,17 @@ parse_ipxe_script()
check_option_value() {
- [ -s "$kernel" ] || {
echo "The kernel does not exist: $kernel"
exit
[ -n "$kernel" ] || {
log_info "Can not find job for current hostname: $hostname."
exit 0
}
[ -s "$kernel" ] || die "Can not find kernel file or kernel file is empty: $kernel."
# debian has both qemu-system-x86_64 and qemu-system-riscv64 command [[ $kernel =~ 'riscv64' ]] && qemu=qemu-system-riscv64
- [ -n "$initrds" ] || exit
- [ -n "$initrds" ] || die "Can not find any initrd for current vm."
}
set_initrd()
2.23.0
On Tue, Jan 19, 2021 at 09:36:00AM +0800, Liu Yinsi wrote:
On Mon, Jan 18, 2021 at 03:41:41PM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan 13186087857@163.com
lib/log.sh | 32 ++++++++++++++++++++++++++++++++ providers/qemu/kvm.sh | 12 ++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 lib/log.sh
lkp-tests also have same file log.sh, why not use that one?
good.
What i consider is to make it effective without lkp-tests, but i see that there are many places in compass-ci that use lkp-tests directly.
So I'll modify here in v3.
-------- Thanks Yu Chuan
Thanks, Yinsi
diff --git a/lib/log.sh b/lib/log.sh new file mode 100644 index 000000000000..56b08f77b3d0 --- /dev/null +++ b/lib/log.sh @@ -0,0 +1,32 @@ +#!/bin/bash
+die() +{
- log_error "$@"
- exit 1
+}
+log() +{
- log_info "$@"
+}
+log_info() +{
- echo "$(date +'%F %T') INFO -- $*"
+}
+log_debug() +{
- echo "$(date +'%F %T') DEBUG -- $*"
+}
+log_warn() +{
- echo "$(date +'%F %T') WARN -- $*" >&2
+}
+log_error() +{
- echo "$(date +'%F %T') ERROR -- $*" >&2
+} diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 35678fbd44ef..a136c8ff45cb 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -4,6 +4,8 @@ # - nr_cpu # - memory
+source $CCI_SRC/lib/log.sh
: ${nr_cpu:=1} : ${memory:=1G}
@@ -52,15 +54,17 @@ parse_ipxe_script()
check_option_value() {
- [ -s "$kernel" ] || {
echo "The kernel does not exist: $kernel"
exit
[ -n "$kernel" ] || {
log_info "Can not find job for current hostname: $hostname."
exit 0
}
[ -s "$kernel" ] || die "Can not find kernel file or kernel file is empty: $kernel."
# debian has both qemu-system-x86_64 and qemu-system-riscv64 command [[ $kernel =~ 'riscv64' ]] && qemu=qemu-system-riscv64
- [ -n "$initrds" ] || exit
- [ -n "$initrds" ] || die "Can not find any initrd for current vm."
}
set_initrd()
2.23.0