From 7e0aeeec0bbff30956ce862546a1c71e322af5a9 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Mon, 7 Dec 2020 13:08:45 -0700 Subject: [PATCH] LU-11848 tests: handle 4-digit version numbers properly Allow version_code() to handle and compare 4-digit version numbers properly. Signed-off-by: Andreas Dilger Change-Id: I8f57537f87bb1c087def277d0d6192def43ebbe5 Reviewed-on: https://review.whamcloud.com/40897 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: James Nunez Reviewed-by: Oleg Drokin --- lustre/tests/sanity.sh | 9 +++++---- lustre/tests/test-framework.sh | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a79e409..e8c0832 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -241,12 +241,13 @@ test_0d() { # LU-3397 [ "$exp_val" == "$imp_val" ] || error "export flags '$exp_val' != import flags '$imp_val'" - # Compare the value of client version + # Compare client versions. Only compare top-3 fields for compatibility exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp) - exp_val=$(version_code $exp_client_version) - imp_val=$CLIENT_VERSION + exp_val=$(version_code $(cut -d. -f1,2,3 <<<$exp_client_version)) + imp_val=$(version_code $(lustre_build_version client | cut -d. -f1,2,3)) [ "$exp_val" == "$imp_val" ] || - error "export client version '$exp_val' != '$imp_val'" + error "exp version '$exp_client_version'($exp_val) != " \ + "'$(lustre_build_version client)'($imp_val)" } run_test 0d "check export proc =============================" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 4bfec65..033e32a 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -455,10 +455,10 @@ check_cpt_number() { # Return a numeric version code based on a version string. The version # code is useful for comparison two version strings to see which is newer. version_code() { - # split arguments like "1.8.6-wc3" into "1", "8", "6", "wc3" - eval set -- $(tr "[:punct:]" " " <<< $*) + # split arguments like "1.8.6-wc3" into "1", "8", "6", "3" + eval set -- $(tr "[:punct:][a-z]" " " <<< $*) - echo -n $(((${1:-0} << 16) | (${2:-0} << 8) | ${3:-0})) + echo -n $(((${1:-0}<<24) | (${2:-0}<<16) | (${3:-0}<<8) | (${4:-0}))) } export LINUX_VERSION=$(uname -r | sed -e "s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/") -- 1.8.3.1