[libvirt-php PATCH 18/35] fix libvirt_version + add test

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

 



From: Remi Collet <fedora@xxxxxxxxxxxxxxxxx>

---
 src/libvirt-php.c               |  2 +-
 src/tests/skipif.inc            |  3 +++
 src/tests/test-version-get.phpt | 27 +++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 src/tests/skipif.inc
 create mode 100644 src/tests/test-version-get.phpt

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 3977302..1977039 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -9595,7 +9595,7 @@ PHP_FUNCTION(libvirt_version)
     add_assoc_long(return_value, "libvirt.minor",(long)((libVer/1000) % 1000));
     add_assoc_long(return_value, "libvirt.major",(long)((libVer/1000000) % 1000));
 
-    add_assoc_string_ex(return_value, "connector.version", 18, PHP_LIBVIRT_WORLD_VERSION VIRT_COPY_OPT);
+    add_assoc_string(return_value, "connector.version", PHP_LIBVIRT_WORLD_VERSION VIRT_COPY_OPT);
     add_assoc_long(return_value, "connector.major", VERSION_MAJOR);
     add_assoc_long(return_value, "connector.minor", VERSION_MINOR);
     add_assoc_long(return_value, "connector.release", VERSION_MICRO);
diff --git a/src/tests/skipif.inc b/src/tests/skipif.inc
new file mode 100644
index 0000000..9f3159b
--- /dev/null
+++ b/src/tests/skipif.inc
@@ -0,0 +1,3 @@
+<?php
+  if (!extension_loaded('libvirt')) die('skip libvirt extension not available');
+?>
diff --git a/src/tests/test-version-get.phpt b/src/tests/test-version-get.phpt
new file mode 100644
index 0000000..b0ab5a3
--- /dev/null
+++ b/src/tests/test-version-get.phpt
@@ -0,0 +1,27 @@
+--TEST--
+libvirt_version
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+var_dump(libvirt_version());
+?>
+Done
+--EXPECTF--
+array(7) {
+  ["libvirt.release"]=>
+  int(%d)
+  ["libvirt.minor"]=>
+  int(%d)
+  ["libvirt.major"]=>
+  int(%d)
+  ["connector.version"]=>
+  string(%d) "%s"
+  ["connector.major"]=>
+  int(%d)
+  ["connector.minor"]=>
+  int(%d)
+  ["connector.release"]=>
+  int(%d)
+}
+Done
-- 
2.5.5

--
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]