From 5ef54ec12097ce08fdadba0505362b626c66c1d8 Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Wed, 25 Jul 2018 16:39:10 +0200 Subject: [PATCH] qa: fix ceph_version_test This function could have produced a false positive if both the RPM and Ceph version strings failed the regex match. (In that case, both the variables would have been empty and the equality test might have passed.) With this commit, the test explicity checks that the regex match actually produced a string that can be usefully compared. Signed-off-by: Nathan Cutler --- qa/common/common.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qa/common/common.sh b/qa/common/common.sh index 25adb2672..db2359f4c 100644 --- a/qa/common/common.sh +++ b/qa/common/common.sh @@ -343,11 +343,13 @@ function ceph_version_test { rpm -q ceph local RPM_NAME=$(rpm -q ceph) local RPM_CEPH_VERSION=$(perl -e '"'"$RPM_NAME"'" =~ m/ceph-(\d+\.\d+\.\d+)/; print "$1\n";') - echo "According to RPM, the ceph upstream version is $RPM_CEPH_VERSION" + echo "According to RPM, the ceph upstream version is ->$RPM_CEPH_VERSION<-" + test -n "$RPM_CEPH_VERSION" ceph --version local BUFFER=$(ceph --version) local CEPH_CEPH_VERSION=$(perl -e '"'"$BUFFER"'" =~ m/ceph version (\d+\.\d+\.\d+)/; print "$1\n";') - echo "According to \"ceph --version\", the ceph upstream version is $CEPH_CEPH_VERSION" + echo "According to \"ceph --version\", the ceph upstream version is ->$CEPH_CEPH_VERSION<-" + test -n "$RPM_CEPH_VERSION" test "$RPM_CEPH_VERSION" = "$CEPH_CEPH_VERSION" }