From 96ff6348b6ee4e3014a4b2d0ed0acce7ebb39b92 Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Wed, 8 Jan 2020 14:43:37 +0100 Subject: [PATCH] test/nvme-perf: move executable lines from common file Move executable lines from common.sh body into a function. Otherwise these are run when file is sourced. Leaving getopts as only executable in common.sh, this can be fixed later and does not cause problems now. Change-Id: Iddbfd9aff5cd006cf3afb579f627f3463663ea6a Signed-off-by: Karol Latecki Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479816 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Pawel Kaminski Reviewed-by: Tomasz Zawadzki --- test/nvme/perf/common.sh | 29 +++++++++++++++-------------- test/nvme/perf/run_perf.sh | 3 +++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/test/nvme/perf/common.sh b/test/nvme/perf/common.sh index dd1b3eda8..48d1f4194 100755 --- a/test/nvme/perf/common.sh +++ b/test/nvme/perf/common.sh @@ -328,6 +328,21 @@ function wait_for_nvme_reload() { shopt -q extglob } +function verify_disk_number() { + # Check if we have appropriate number of disks to carry out the test + if [[ $PLUGIN == "bdev" ]] || [[ $PLUGIN == "bdevperf" ]]; then + $ROOT_DIR/scripts/gen_nvme.sh >> $BASE_DIR/bdev.conf + fi + + disks=($(get_disks $PLUGIN)) + if [[ $DISKNO == "ALL" ]] || [[ $DISKNO == "all" ]]; then + DISKNO=${#disks[@]} + elif [[ $DISKNO -gt ${#disks[@]} ]] || [[ ! $DISKNO =~ ^[0-9]+$ ]]; then + echo "error: Required devices number ($DISKNO) is not a valid number or it's larger than the number of devices found (${#disks[@]})" + false + fi +} + function usage() { set +x @@ -397,17 +412,3 @@ while getopts 'h-:' optchar; do *) usage $0 "Invalid argument '$optchar'"; exit 1 ;; esac done - -trap 'rm -f *.state $BASE_DIR/bdev.conf; print_backtrace' ERR SIGTERM SIGABRT -mkdir -p $BASE_DIR/results -if [[ $PLUGIN == "bdev" ]] || [[ $PLUGIN == "bdevperf" ]]; then - $ROOT_DIR/scripts/gen_nvme.sh >> $BASE_DIR/bdev.conf -fi - -disks=($(get_disks $PLUGIN)) -if [[ $DISKNO == "ALL" ]] || [[ $DISKNO == "all" ]]; then - DISKNO=${#disks[@]} -elif [[ $DISKNO -gt ${#disks[@]} ]] || [[ ! $DISKNO =~ ^[0-9]+$ ]]; then - echo "error: Required devices number ($DISKNO) is not a valid number or it's larger than the number of devices found (${#disks[@]})" - exit 1 -fi diff --git a/test/nvme/perf/run_perf.sh b/test/nvme/perf/run_perf.sh index 2ac411172..210c5503e 100755 --- a/test/nvme/perf/run_perf.sh +++ b/test/nvme/perf/run_perf.sh @@ -34,6 +34,9 @@ BASE_DIR=$(readlink -f $(dirname $0)) . $BASE_DIR/common.sh +trap 'rm -f *.state $BASE_DIR/bdev.conf; print_backtrace' ERR SIGTERM SIGABRT +verify_disk_number + DISK_NAMES=$(get_disks $PLUGIN) DISKS_NUMA=$(get_numa_node $PLUGIN "$DISK_NAMES") CORES=$(get_cores "$CPUS_ALLOWED")