[PATCH v3 compass-ci 2/2] my-qemu.sh: add `-h|--help`, `-d|--debug` params for my-qemu.sh

Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/my-qemu.sh | 35 +++++++++++++++++++++++++++++++++++ providers/qemu/kvm.sh | 13 +++++++------ providers/qemu/pxe.sh | 10 ++++++++-- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/providers/my-qemu.sh b/providers/my-qemu.sh index 8845a346e195..fc98ea97360d 100755 --- a/providers/my-qemu.sh +++ b/providers/my-qemu.sh @@ -2,6 +2,41 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + +help() +{ + cat <<-'EOF' + Usage: ./my-qemu.sh [OPTION]... + Ask scheduler service whether there is a job, and start a local vm if there is a job. + Scheduler api: http://${SCHED_HOST}:${SCHED_PORT}/boot.ipxe/mac/${mac} + + Mandatory arguments to long options are mandatory for short options too. + -h, --help display this help and exit + -d, --debug open the local vm serial port in the current shell + EOF + + exit 0 +} + +while true +do + [ $# -eq 0 ] && break + case "$1" in + -h|--help) + help;; + -d|--debug) + export DEBUG=true;; + *) + log_error "Unknown param: $1" + help + exit 1;; + esac + shift +done + [[ $tbox_group ]] || tbox_group=vm-2p8g export hostname=$tbox_group.$USER-$$ diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 93977ec15438..ec8c00887283 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -122,11 +122,11 @@ set_qemu() print_message() { - echo SCHED_PORT: $SCHED_PORT - echo kernel: $kernel - echo initrds: $initrds - echo append: $append - echo less $log_file + log_info SCHED_PORT: $SCHED_PORT + log_info kernel: $kernel + log_info initrds: $initrds + log_info append: $append + [ "$DEBUG" == "true" ] || log_info less $log_file sleep 5 } @@ -143,9 +143,10 @@ public_option() -k en-us -no-reboot -nographic - -serial file:${log_file} -monitor null ) + + [ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${log_file}) } individual_option() diff --git a/providers/qemu/pxe.sh b/providers/qemu/pxe.sh index fa688331964a..0ba052c8276e 100755 --- a/providers/qemu/pxe.sh +++ b/providers/qemu/pxe.sh @@ -4,6 +4,10 @@ # - nr_cpu # - memory +: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + : ${nr_cpu:=1} : ${memory:=1G} @@ -18,7 +22,7 @@ fi qemu=qemu-system-aarch64 command -v $qemu >/dev/null || qemu=qemu-kvm -echo less $serial_log +[ "$DEBUG" == "true" ] || log_info less $serial_log kvm=( $qemu @@ -33,7 +37,9 @@ kvm=( -k en-us -no-reboot -nographic - -serial file:${serial_log} -monitor null ) + +[ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${serial_log}) + "${kvm[@]}" -- 2.23.0

On Tue, Jan 19, 2021 at 03:23:30PM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/my-qemu.sh | 35 +++++++++++++++++++++++++++++++++++ providers/qemu/kvm.sh | 13 +++++++------ providers/qemu/pxe.sh | 10 ++++++++-- 3 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/providers/my-qemu.sh b/providers/my-qemu.sh index 8845a346e195..fc98ea97360d 100755 --- a/providers/my-qemu.sh +++ b/providers/my-qemu.sh @@ -2,6 +2,41 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + +help() +{ + cat <<-'EOF' + Usage: ./my-qemu.sh [OPTION]... + Ask scheduler service whether there is a job, and start a local vm if there is a job. + Scheduler api: http://${SCHED_HOST}:${SCHED_PORT}/boot.ipxe/mac/${mac} + + Mandatory arguments to long options are mandatory for short options too. + -h, --help display this help and exit + -d, --debug open the local vm serial port in the current shell + EOF + + exit 0 +} + +while true +do + [ $# -eq 0 ] && break + case "$1" in + -h|--help) + help;; + -d|--debug) + export DEBUG=true;;
^--- if the first times use '-d' option, 'DEBUG' will be env variable; when the second times run the script, whether 'DEBUG' will still be effective? Thanks, Liushaofei
+ *) + log_error "Unknown param: $1" + help + exit 1;; + esac + shift +done + [[ $tbox_group ]] || tbox_group=vm-2p8g export hostname=$tbox_group.$USER-$$ diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 93977ec15438..ec8c00887283 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -122,11 +122,11 @@ set_qemu()
print_message() { - echo SCHED_PORT: $SCHED_PORT - echo kernel: $kernel - echo initrds: $initrds - echo append: $append - echo less $log_file + log_info SCHED_PORT: $SCHED_PORT + log_info kernel: $kernel + log_info initrds: $initrds + log_info append: $append + [ "$DEBUG" == "true" ] || log_info less $log_file
sleep 5 } @@ -143,9 +143,10 @@ public_option() -k en-us -no-reboot -nographic - -serial file:${log_file} -monitor null ) + + [ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${log_file}) }
individual_option() diff --git a/providers/qemu/pxe.sh b/providers/qemu/pxe.sh index fa688331964a..0ba052c8276e 100755 --- a/providers/qemu/pxe.sh +++ b/providers/qemu/pxe.sh @@ -4,6 +4,10 @@ # - nr_cpu # - memory
+: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + : ${nr_cpu:=1} : ${memory:=1G}
@@ -18,7 +22,7 @@ fi qemu=qemu-system-aarch64 command -v $qemu >/dev/null || qemu=qemu-kvm
-echo less $serial_log +[ "$DEBUG" == "true" ] || log_info less $serial_log
kvm=( $qemu @@ -33,7 +37,9 @@ kvm=( -k en-us -no-reboot -nographic - -serial file:${serial_log} -monitor null ) + +[ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${serial_log}) + "${kvm[@]}" -- 2.23.0

On Tue, Jan 19, 2021 at 03:36:27PM +0800, Liu Shaofei wrote:
On Tue, Jan 19, 2021 at 03:23:30PM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/my-qemu.sh | 35 +++++++++++++++++++++++++++++++++++ providers/qemu/kvm.sh | 13 +++++++------ providers/qemu/pxe.sh | 10 ++++++++-- 3 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/providers/my-qemu.sh b/providers/my-qemu.sh index 8845a346e195..fc98ea97360d 100755 --- a/providers/my-qemu.sh +++ b/providers/my-qemu.sh @@ -2,6 +2,41 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + +help() +{ + cat <<-'EOF' + Usage: ./my-qemu.sh [OPTION]... + Ask scheduler service whether there is a job, and start a local vm if there is a job. + Scheduler api: http://${SCHED_HOST}:${SCHED_PORT}/boot.ipxe/mac/${mac} + + Mandatory arguments to long options are mandatory for short options too. + -h, --help display this help and exit + -d, --debug open the local vm serial port in the current shell + EOF + + exit 0 +} + +while true +do + [ $# -eq 0 ] && break + case "$1" in + -h|--help) + help;; + -d|--debug) + export DEBUG=true;;
^--- if the first times use '-d' option, 'DEBUG' will be env variable; when the second times run the script, whether 'DEBUG' will still be effective?
export effect current shell and subshell Thanks, Shenwei
Thanks, Liushaofei
+ *) + log_error "Unknown param: $1" + help + exit 1;; + esac + shift +done + [[ $tbox_group ]] || tbox_group=vm-2p8g export hostname=$tbox_group.$USER-$$ diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 93977ec15438..ec8c00887283 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -122,11 +122,11 @@ set_qemu()
print_message() { - echo SCHED_PORT: $SCHED_PORT - echo kernel: $kernel - echo initrds: $initrds - echo append: $append - echo less $log_file + log_info SCHED_PORT: $SCHED_PORT + log_info kernel: $kernel + log_info initrds: $initrds + log_info append: $append + [ "$DEBUG" == "true" ] || log_info less $log_file
sleep 5 } @@ -143,9 +143,10 @@ public_option() -k en-us -no-reboot -nographic - -serial file:${log_file} -monitor null ) + + [ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${log_file}) }
individual_option() diff --git a/providers/qemu/pxe.sh b/providers/qemu/pxe.sh index fa688331964a..0ba052c8276e 100755 --- a/providers/qemu/pxe.sh +++ b/providers/qemu/pxe.sh @@ -4,6 +4,10 @@ # - nr_cpu # - memory
+: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + : ${nr_cpu:=1} : ${memory:=1G}
@@ -18,7 +22,7 @@ fi qemu=qemu-system-aarch64 command -v $qemu >/dev/null || qemu=qemu-kvm
-echo less $serial_log +[ "$DEBUG" == "true" ] || log_info less $serial_log
kvm=( $qemu @@ -33,7 +37,9 @@ kvm=( -k en-us -no-reboot -nographic - -serial file:${serial_log} -monitor null ) + +[ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${serial_log}) + "${kvm[@]}" -- 2.23.0

+while true +do + [ $# -eq 0 ] && break + case "$1" in + -h|--help) + help;; + -d|--debug) + export DEBUG=true;;
^--- if the first times use '-d' option, 'DEBUG' will be env variable; when the second times run the script, whether 'DEBUG' will still be effective?
export effect current shell and subshell
Nice. -------- Thanks Yu Chuan
Thanks, Shenwei
Thanks, Liushaofei
+ *) + log_error "Unknown param: $1" + help + exit 1;; + esac + shift +done + [[ $tbox_group ]] || tbox_group=vm-2p8g export hostname=$tbox_group.$USER-$$ diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 93977ec15438..ec8c00887283 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -122,11 +122,11 @@ set_qemu()
print_message() { - echo SCHED_PORT: $SCHED_PORT - echo kernel: $kernel - echo initrds: $initrds - echo append: $append - echo less $log_file + log_info SCHED_PORT: $SCHED_PORT + log_info kernel: $kernel + log_info initrds: $initrds + log_info append: $append + [ "$DEBUG" == "true" ] || log_info less $log_file
sleep 5 } @@ -143,9 +143,10 @@ public_option() -k en-us -no-reboot -nographic - -serial file:${log_file} -monitor null ) + + [ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${log_file}) }
individual_option() diff --git a/providers/qemu/pxe.sh b/providers/qemu/pxe.sh index fa688331964a..0ba052c8276e 100755 --- a/providers/qemu/pxe.sh +++ b/providers/qemu/pxe.sh @@ -4,6 +4,10 @@ # - nr_cpu # - memory
+: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + : ${nr_cpu:=1} : ${memory:=1G}
@@ -18,7 +22,7 @@ fi qemu=qemu-system-aarch64 command -v $qemu >/dev/null || qemu=qemu-kvm
-echo less $serial_log +[ "$DEBUG" == "true" ] || log_info less $serial_log
kvm=( $qemu @@ -33,7 +37,9 @@ kvm=( -k en-us -no-reboot -nographic - -serial file:${serial_log} -monitor null ) + +[ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${serial_log}) + "${kvm[@]}" -- 2.23.0

On Tue, Jan 19, 2021 at 03:23:30PM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/my-qemu.sh | 35 +++++++++++++++++++++++++++++++++++ providers/qemu/kvm.sh | 13 +++++++------ providers/qemu/pxe.sh | 10 ++++++++-- 3 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/providers/my-qemu.sh b/providers/my-qemu.sh index 8845a346e195..fc98ea97360d 100755 --- a/providers/my-qemu.sh +++ b/providers/my-qemu.sh @@ -2,6 +2,41 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + +help() +{ + cat <<-'EOF' + Usage: ./my-qemu.sh [OPTION]... + Ask scheduler service whether there is a job, and start a local vm if there is a job.
Ask => Request and => then Thanks, Xueliang
+ Scheduler api: http://${SCHED_HOST}:${SCHED_PORT}/boot.ipxe/mac/${mac} + + Mandatory arguments to long options are mandatory for short options too. + -h, --help display this help and exit + -d, --debug open the local vm serial port in the current shell + EOF + + exit 0 +} + +while true +do + [ $# -eq 0 ] && break + case "$1" in + -h|--help) + help;; + -d|--debug) + export DEBUG=true;; + *) + log_error "Unknown param: $1" + help + exit 1;; + esac + shift +done + [[ $tbox_group ]] || tbox_group=vm-2p8g export hostname=$tbox_group.$USER-$$ diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 93977ec15438..ec8c00887283 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -122,11 +122,11 @@ set_qemu()
print_message() { - echo SCHED_PORT: $SCHED_PORT - echo kernel: $kernel - echo initrds: $initrds - echo append: $append - echo less $log_file + log_info SCHED_PORT: $SCHED_PORT + log_info kernel: $kernel + log_info initrds: $initrds + log_info append: $append + [ "$DEBUG" == "true" ] || log_info less $log_file
sleep 5 } @@ -143,9 +143,10 @@ public_option() -k en-us -no-reboot -nographic - -serial file:${log_file} -monitor null ) + + [ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${log_file}) }
individual_option() diff --git a/providers/qemu/pxe.sh b/providers/qemu/pxe.sh index fa688331964a..0ba052c8276e 100755 --- a/providers/qemu/pxe.sh +++ b/providers/qemu/pxe.sh @@ -4,6 +4,10 @@ # - nr_cpu # - memory
+: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + : ${nr_cpu:=1} : ${memory:=1G}
@@ -18,7 +22,7 @@ fi qemu=qemu-system-aarch64 command -v $qemu >/dev/null || qemu=qemu-kvm
-echo less $serial_log +[ "$DEBUG" == "true" ] || log_info less $serial_log
kvm=( $qemu @@ -33,7 +37,9 @@ kvm=( -k en-us -no-reboot -nographic - -serial file:${serial_log} -monitor null ) + +[ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${serial_log}) + "${kvm[@]}" -- 2.23.0

On Wed, Jan 20, 2021 at 09:05:16AM +0800, Cao Xueliang wrote:
On Tue, Jan 19, 2021 at 03:23:30PM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan <13186087857@163.com> --- providers/my-qemu.sh | 35 +++++++++++++++++++++++++++++++++++ providers/qemu/kvm.sh | 13 +++++++------ providers/qemu/pxe.sh | 10 ++++++++-- 3 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/providers/my-qemu.sh b/providers/my-qemu.sh index 8845a346e195..fc98ea97360d 100755 --- a/providers/my-qemu.sh +++ b/providers/my-qemu.sh @@ -2,6 +2,41 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + +help() +{ + cat <<-'EOF' + Usage: ./my-qemu.sh [OPTION]... + Ask scheduler service whether there is a job, and start a local vm if there is a job.
Ask => Request and => then
OK. -------- Thanks Yu Chuan
Thanks, Xueliang
+ Scheduler api: http://${SCHED_HOST}:${SCHED_PORT}/boot.ipxe/mac/${mac} + + Mandatory arguments to long options are mandatory for short options too. + -h, --help display this help and exit + -d, --debug open the local vm serial port in the current shell + EOF + + exit 0 +} + +while true +do + [ $# -eq 0 ] && break + case "$1" in + -h|--help) + help;; + -d|--debug) + export DEBUG=true;; + *) + log_error "Unknown param: $1" + help + exit 1;; + esac + shift +done + [[ $tbox_group ]] || tbox_group=vm-2p8g export hostname=$tbox_group.$USER-$$ diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index 93977ec15438..ec8c00887283 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -122,11 +122,11 @@ set_qemu()
print_message() { - echo SCHED_PORT: $SCHED_PORT - echo kernel: $kernel - echo initrds: $initrds - echo append: $append - echo less $log_file + log_info SCHED_PORT: $SCHED_PORT + log_info kernel: $kernel + log_info initrds: $initrds + log_info append: $append + [ "$DEBUG" == "true" ] || log_info less $log_file
sleep 5 } @@ -143,9 +143,10 @@ public_option() -k en-us -no-reboot -nographic - -serial file:${log_file} -monitor null ) + + [ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${log_file}) }
individual_option() diff --git a/providers/qemu/pxe.sh b/providers/qemu/pxe.sh index fa688331964a..0ba052c8276e 100755 --- a/providers/qemu/pxe.sh +++ b/providers/qemu/pxe.sh @@ -4,6 +4,10 @@ # - nr_cpu # - memory
+: ${LKP_SRC:="/c/lkp-tests"} + +source ${LKP_SRC}/lib/log.sh + : ${nr_cpu:=1} : ${memory:=1G}
@@ -18,7 +22,7 @@ fi qemu=qemu-system-aarch64 command -v $qemu >/dev/null || qemu=qemu-kvm
-echo less $serial_log +[ "$DEBUG" == "true" ] || log_info less $serial_log
kvm=( $qemu @@ -33,7 +37,9 @@ kvm=( -k en-us -no-reboot -nographic - -serial file:${serial_log} -monitor null ) + +[ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${serial_log}) + "${kvm[@]}" -- 2.23.0
participants (4)
-
Cao Xueliang
-
Liu Shaofei
-
Xiao Shenwei
-
Yu Chuan