Skip to content

Commit

Permalink
qa: fix ceph_version_test
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
smithfarm committed Jul 26, 2018
1 parent af19020 commit 5ef54ec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qa/common/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down

0 comments on commit 5ef54ec

Please sign in to comment.