From 05014abdded2d93927443bfe6eb7eac719b25740 Mon Sep 17 00:00:00 2001 From: Frank Liepold Date: Wed, 8 Jan 2014 08:22:14 +0100 Subject: [PATCH] test_suite: refactoring --- test_suite/scripts/modules/23_lv_config.sh | 27 ++++++++++--------- test_suite/scripts/modules/81_lib_linktree.sh | 3 ++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/test_suite/scripts/modules/23_lv_config.sh b/test_suite/scripts/modules/23_lv_config.sh index 797a4ca4..cf73f517 100644 --- a/test_suite/scripts/modules/23_lv_config.sh +++ b/test_suite/scripts/modules/23_lv_config.sh @@ -70,26 +70,29 @@ function lv_config_lvremove lib_remote_idfile $host lvremove -f $logical_volume_path || lib_exit 1 } -function lv_config_extract_int_from_lv_size +# removes trailing unit letters (e.g. 9G -> 9) +function lv_config_extract_int_from_lv_size_with_unit { - local lv_size=$1 - expr "$lv_size" : "^ *\([0-9][0-9]*\)" + local lv_size_with_unit=$1 + expr "$lv_size_with_unit" : "^ *\([0-9][0-9]*\)" } function lv_config_check_volume_group_existence_and_size { - local host lvg_size rc + local host lvg_size_with_unit rc for host in "${main_host_list[@]}"; do lib_vmsg " checking volume group $lv_config_lvg_name on $host" - lvg_size=$(lib_remote_idfile $host vgs --noheadings \ - --units G -o vg_size $lv_config_lvg_name) + lvg_size_with_unit=$(lib_remote_idfile $host vgs --noheadings \ + --units G -o vg_size $lv_config_lvg_name) rc=$? if [ $rc -ne 0 ];then lib_vmsg " vg $host:$lv_config_lvg_name will be created" return - fi + fi # 11.1G -> 11 - lvg_size=$(lv_config_extract_int_from_lv_size $lvg_size) + local lvg_size + lvg_size=$(lv_config_extract_int_from_lv_size_with_unit \ + $lvg_size_with_unit) [ "$lvg_size" -ge $lv_config_min_lvg_size ] || \ lib_exit 1 "size $lvg_size of volume group $lv_config_lvg_name not >= $lv_config_min_lvg_size" done @@ -151,14 +154,14 @@ function lv_config_get_lv_name function lv_config_get_size_logical_volume { local host=$1 lv_dev=$2 - local lv_size rc - lv_size=$(lib_remote_idfile $host lvdisplay --units G --noheadings \ - -C $lv_dev -o lv_size) + local lv_size_with_unit rc lv_size + lv_size_with_unit=$(lib_remote_idfile $host lvdisplay --units G \ + --noheadings -C $lv_dev -o lv_size) rc=$? if [ $rc -ne 0 ]; then return $rc fi - lv_size=$(lv_config_extract_int_from_lv_size $lv_size) + lv_size=$(lv_config_extract_int_from_lv_size_with_unit $lv_size_unit) echo $lv_size } diff --git a/test_suite/scripts/modules/81_lib_linktree.sh b/test_suite/scripts/modules/81_lib_linktree.sh index 5d51f439..352aff8a 100644 --- a/test_suite/scripts/modules/81_lib_linktree.sh +++ b/test_suite/scripts/modules/81_lib_linktree.sh @@ -38,12 +38,13 @@ function lib_linktree_print_linktree lib_remote_idfile $host 'ls -l --full-time $(find /'"$main_mars_directory"' \! -type d | sort)' } +# the required link value may be specified with an unit (e.g. 3G) function lib_linktree_check_link_int_value { [ $# -eq 5 ] || lib_exit 1 "wrong number $# of arguments (args = $*)" local host=$1 res=$2 link=$3 link_value_req=$4 value_unit=$5 local link link_value_act waited=0 - link_value_req=$(lv_config_extract_int_from_lv_size $link_value_req) + link_value_req=$(lv_config_extract_int_from_lv_size_with_unit $link_value_req) case $link in #(( size) link="${resource_dir_list[$res]}/$link" ;;