[libvirt-tck PATCH] Support version compare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Dan Zheng <dzheng@xxxxxxxxxx>

Some APIs are only supported from new version. This is to compare
the current running version to the supporting version in order to
decide if one test should be skipped.

Signed-off-by: Dan Zheng <dzheng@xxxxxxxxxx>
---
 lib/Sys/Virt/TCK.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
index a641d01..98ea945 100644
--- a/lib/Sys/Virt/TCK.pm
+++ b/lib/Sys/Virt/TCK.pm
@@ -1229,6 +1229,21 @@ sub get_host_block_device {
     return $match ? $device : undef;
 }
 
+sub compare_version {
+    my $self = shift;
+    my $to_version = shift;
+
+    my $from_version = `rpm -q perl-Sys-Virt | cut -d'-' -f4`;
+    $from_version =~ s/\R//g;
+    print "Current version:$from_version compares to $to_version\n";
+    $from_version =~ /(\d+).(\d+).(\d+)/;
+    $from_version = $1 * 1000000 + $2 * 1000 + $3;
+
+    $to_version =~ /(\d+).(\d+).(\d+)/;
+    $to_version = $1 * 1000000 + $2 * 1000 + $3;
+    return ($from_version ge $to_version)? 1 : 0;
+}
+
 sub get_host_network_device {
     my $self = shift;
     my $devindex = @_ ? shift : 0;
-- 
2.18.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux