summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2017-02-09 16:01:24 +0100
committerRemi Collet <fedora@famillecollet.com>2017-02-09 16:01:24 +0100
commitc65efaa60905db2be99e1c298aaf826003693f5d (patch)
tree5010133d94ae941a5e102fa112d7b275ba17556a
parentc52f0a87b5c5ad2d581c201bcb9af100c8c3d49c (diff)
php-pecl-memcached: test build
-rw-r--r--incrdecr_64.phpt75
-rw-r--r--incrdecr_bykey_64.phpt69
-rw-r--r--php-pecl-memcached-php7.spec9
-rw-r--r--skipif.inc16
4 files changed, 168 insertions, 1 deletions
diff --git a/incrdecr_64.phpt b/incrdecr_64.phpt
new file mode 100644
index 0000000..d71c050
--- /dev/null
+++ b/incrdecr_64.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Memcached::increment() Memcached::decrement() on 64bits
+--SKIPIF--
+<?php
+include "skipif.inc";
+if (PHP_INT_SIZE < 8) die("skip valid for 64-bit only");
+?>
+--FILE--
+<?php
+include dirname (__FILE__) . '/config.inc';
+$m = memc_get_instance ();
+
+echo "Not there\n";
+$m->delete('foo');
+var_dump($m->increment('foo', 1));
+var_dump($m->getResultCode());
+var_dump($m->decrement('foo', 1));
+var_dump($m->getResultCode());
+var_dump($m->get('foo'));
+var_dump($m->getResultCode());
+
+echo "Normal\n";
+$m->set('foo', 1);
+var_dump($m->get('foo'));
+$m->increment('foo');
+var_dump($m->get('foo'));
+$m->increment('foo', 2);
+var_dump($m->get('foo'));
+$m->decrement('foo');
+var_dump($m->get('foo'));
+$m->decrement('foo', 2);
+var_dump($m->get('foo'));
+
+error_reporting(0);
+
+echo "Negative offset\n";
+$php_errormsg = '';
+$m->increment('foo', -1);
+echo $php_errormsg, "\n";
+var_dump($m->get('foo'));
+
+$php_errormsg = '';
+$m->decrement('foo', -1);
+echo $php_errormsg, "\n";
+var_dump($m->get('foo'));
+
+echo "Enormous offset\n";
+$m->increment('foo', 4294967296);
+var_dump($m->get('foo'));
+
+$m->decrement('foo', 4294967296);
+var_dump($m->get('foo'));
+
+--EXPECT--
+Not there
+bool(false)
+int(16)
+bool(false)
+int(16)
+bool(false)
+int(16)
+Normal
+int(1)
+int(2)
+int(4)
+int(3)
+int(1)
+Negative offset
+Memcached::increment(): offset cannot be a negative value
+int(1)
+Memcached::decrement(): offset cannot be a negative value
+int(1)
+Enormous offset
+int(4294967297)
+int(1)
diff --git a/incrdecr_bykey_64.phpt b/incrdecr_bykey_64.phpt
new file mode 100644
index 0000000..b1f2e4d
--- /dev/null
+++ b/incrdecr_bykey_64.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Memcached::incrementByKey() Memcached::decrementByKey() on 64bits
+--SKIPIF--
+<?php
+include "skipif.inc";
+if (PHP_INT_SIZE < 8) die("skip valid for 64-bit only");
+?>
+--FILE--
+<?php
+include dirname (__FILE__) . '/config.inc';
+$m = memc_get_instance ();
+
+echo "Not there\n";
+$m->delete('foo');
+var_dump($m->incrementByKey('foo', 'foo', 1));
+var_dump($m->decrementByKey('foo', 'foo', 1));
+var_dump($m->get('foo'));
+
+echo "Normal\n";
+$m->set('foo', 1);
+var_dump($m->get('foo'));
+$m->incrementByKey('foo', 'foo');
+var_dump($m->get('foo'));
+$m->incrementByKey('foo', 'foo', 2);
+var_dump($m->get('foo'));
+$m->decrementByKey('foo', 'foo');
+var_dump($m->get('foo'));
+$m->decrementByKey('foo', 'foo', 2);
+var_dump($m->get('foo'));
+
+error_reporting(0);
+
+echo "Negative offset\n";
+$php_errormsg = '';
+$m->incrementByKey('foo', 'foo', -1);
+echo $php_errormsg, "\n";
+var_dump($m->get('foo'));
+
+$php_errormsg = '';
+$m->decrementByKey('foo', 'foo', -1);
+echo $php_errormsg, "\n";
+var_dump($m->get('foo'));
+
+echo "Enormous offset\n";
+$m->incrementByKey('foo', 'foo', 4294967296);
+var_dump($m->get('foo'));
+
+$m->decrementByKey('foo', 'foo', 4294967296);
+var_dump($m->get('foo'));
+
+--EXPECT--
+Not there
+bool(false)
+bool(false)
+bool(false)
+Normal
+int(1)
+int(2)
+int(4)
+int(3)
+int(1)
+Negative offset
+Memcached::incrementByKey(): offset cannot be a negative value
+int(1)
+Memcached::decrementByKey(): offset cannot be a negative value
+int(1)
+Enormous offset
+int(4294967297)
+int(1)
diff --git a/php-pecl-memcached-php7.spec b/php-pecl-memcached-php7.spec
index 8027ef8..bdd3b98 100644
--- a/php-pecl-memcached-php7.spec
+++ b/php-pecl-memcached-php7.spec
@@ -27,12 +27,15 @@
Summary: Extension to work with the Memcached caching daemon
Name: %{?sub_prefix}php-pecl-memcached
Version: 3.0.1
-Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
+Release: 3%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
License: PHP
Group: Development/Languages
URL: http://pecl.php.net/package/%{pecl_name}
Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
+Source1: skipif.inc
+Source2: incrdecr_64.phpt
+Source3: incrdecr_bykey_64.phpt
# https://github.com/php-memcached-dev/php-memcached/pull/319
Patch0: %{pecl_name}-pr319.patch
@@ -133,6 +136,7 @@ sed -e 's/role="test"/role="src"/' \
-i package.xml
cd NTS
+cp %{SOURCE1} %{SOURCE2} %{SOURCE3} tests/
%patch0 -p1 -b .pr319
%if %{with_fastlz}
@@ -337,6 +341,9 @@ exit $ret
%changelog
+* Thu Feb 9 2017 Remi Collet <remi@fedoraproject.org> - 3.0.1-3
+- test build for https://github.com/php-memcached-dev/php-memcached/pull/320
+
* Thu Feb 9 2017 Remi Collet <remi@fedoraproject.org> - 3.0.1-2
- switch to pecl sources
- enable test suite
diff --git a/skipif.inc b/skipif.inc
new file mode 100644
index 0000000..9ef73b0
--- /dev/null
+++ b/skipif.inc
@@ -0,0 +1,16 @@
+<?php
+if (!extension_loaded("memcached")) {
+ die("skip memcached is not loaded\n");
+}
+
+include dirname(__FILE__) . "/config.inc";
+
+if (($m = memc_get_instance()) === NULL) {
+ die ("skip can not connect to server\n");
+}
+
+if (isset($min_version)) {
+ if (version_compare(memc_get_version($m), $min_version, "<")) {
+ die("skip version of server pool is too old, $min_version is required\n");
+ }
+}