From 1b109418d6eeccb9d134e1d555656fb8dad11dd8 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Wed, 30 Aug 2017 00:57:03 -0600 Subject: [PATCH] LU-5965 tests: fix parsing for older Lustre versions Fix parsing of Lustre version generated by "lctl get_param version" before release 2.7. The old code generated a valid version number even for older releases, except in the case where the "build:" line did not start with a numeric value, since that line was incorrectly being parsed instead of the "lustre:" line due to "$ver" not being double-quoted properly, so "$ver" was being treated as a single line and "head -n 1" was doing nothing. This was offset by sed dropping everything before the _last_ ":" instead of before the _first_ ":", and then using the "build: " line. Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: Ifd7dc95aaf0d6edf3558e18b85a78bea861248d0 Reviewed-on: https://review.whamcloud.com/28793 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: James Nunez Reviewed-by: Oleg Drokin --- lustre/tests/test-framework.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index e94f941..3e46015 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -441,15 +441,13 @@ export LINUX_VERSION_CODE=$(version_code ${LINUX_VERSION//\./ }) # output: prints version string to stdout in (up to 4) dotted-decimal values lustre_build_version() { local facet=${1:-client} - local ver - local ver=$(do_facet $facet "$LCTL get_param -n version 2>/dev/null || $LCTL lustre_build_version 2>/dev/null || $LCTL --version 2>/dev/null | cut -d' ' -f2") - local lver=$(egrep -i "lustre: |version: " <<<$ver | head -n 1) + local lver=$(egrep -i "lustre: |version: " <<<"$ver" | head -n 1) [ -n "$lver" ] && ver="$lver" - sed -e 's/.*: //' -e 's/^v//' -e 's/-.*//' -e 's/_/./g' <<<$ver | + sed -e 's/[^:]*: //' -e 's/^v//' -e 's/[ -].*//' -e 's/_/./g' <<<$ver | cut -d. -f1-4 } -- 1.8.3.1