Whamcloud - gitweb
LU-5965 tests: fix parsing for older Lustre versions 93/28793/2
authorAndreas Dilger <andreas.dilger@intel.com>
Wed, 30 Aug 2017 06:57:03 +0000 (00:57 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 10 Sep 2017 04:54:59 +0000 (04:54 +0000)
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 <andreas.dilger@intel.com>
Change-Id: Ifd7dc95aaf0d6edf3558e18b85a78bea861248d0
Reviewed-on: https://review.whamcloud.com/28793
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/test-framework.sh

index e94f941..3e46015 100755 (executable)
@@ -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
 }