Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
language: php
php:
- 5.5
- 5.4
- 5.3
#- 5.4
#- 5.3
env:
- LIBMEMCACHED_VERSION=1.0.17
- LIBMEMCACHED_VERSION=1.0.16
- LIBMEMCACHED_VERSION=1.0.15
- LIBMEMCACHED_VERSION=1.0.14
- LIBMEMCACHED_VERSION=1.0.10
- LIBMEMCACHED_VERSION=1.0.8
- LIBMEMCACHED_VERSION=1.0.7
- LIBMEMCACHED_VERSION=1.0.6
- LIBMEMCACHED_VERSION=1.0.2
- LIBMEMCACHED_VERSION=0.53
- LIBMEMCACHED_VERSION=0.44

services:
- memcached # will start memcached

before_script:
- ./travis.sh before_script $LIBMEMCACHED_VERSION
- ./.travis/travis.sh before_script $LIBMEMCACHED_VERSION

script:
- ./travis.sh script $LIBMEMCACHED_VERSION
- ./.travis/travis.sh script $LIBMEMCACHED_VERSION
250 changes: 250 additions & 0 deletions .travis/travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
#!/bin/bash

function version_compare() {
DPKG=`which dpkg`

if [ "x$DPKG" = "x" ]; then
echo "dpkg not found, cannot compare versions"
exit 1
fi

$DPKG --compare-versions "$1" "$2" "$3"
return $?
}

function check_protocol_support() {
version_compare "$LIBMEMCACHED_VERSION" gt 1.0.15
if [ $? = 0 ]; then
ENABLE_PROTOOCOL=yes
else
ENABLE_PROTOOCOL=no
fi
}

function check_sasl_support() {
version_compare "$LIBMEMCACHED_VERSION" gt 1.0.15
if [ $? = 0 ]; then
ENABLE_SASL=yes
else
ENABLE_SASL=no
fi
}

function validate_package_xml() {
retval=0
for file in tests/*.phpt; do
grep $(basename $file) package.xml >/dev/null
if [ $? != 0 ]; then
echo "Missing $file from package.xml"
retval=1;
fi
done
return $retval
}

function install_libmemcached() {

wget "https://launchpad.net/libmemcached/1.0/${LIBMEMCACHED_VERSION}/+download/libmemcached-${LIBMEMCACHED_VERSION}.tar.gz" -O libmemcached-${LIBMEMCACHED_VERSION}.tar.gz

tar xvfz libmemcached-${LIBMEMCACHED_VERSION}.tar.gz
pushd "libmemcached-${LIBMEMCACHED_VERSION}"

local protocol_flag=""
if test "x$ENABLE_PROTOOCOL" = "xyes"; then
protocol_flag="--enable-libmemcachedprotocol"
fi

./configure --prefix="$LIBMEMCACHED_PREFIX" $protocol_flag LDFLAGS="-lpthread"
make
make install
popd
}

function install_igbinary() {
git clone https://github.com/igbinary/igbinary.git
pushd igbinary
phpize
./configure
make
make install
popd
}

function install_msgpack() {
git clone https://github.com/msgpack/msgpack-php.git
pushd msgpack-php
phpize
./configure
make
make install
popd
}

function install_sasl() {

wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz -O memcached-1.4.15.tar.gz
tar xfz memcached-1.4.15.tar.gz

pushd memcached-1.4.15
./configure --enable-sasl --prefix="${HOME}/memcached"
make
make install
popd

sudo apt-get install sasl2-bin
export SASL_CONF_PATH="${HOME}/sasl2"

# Create config path
mkdir "${SASL_CONF_PATH}"

# Create configuration
cat<<EOF > "${SASL_CONF_PATH}/memcached.conf"
mech_list: PLAIN
plainlog_level: 5
sasldb_path: ${SASL_CONF_PATH}/sasldb2
EOF

# Create password
echo "test" | /usr/sbin/saslpasswd2 -c memcached -a memcached -f "${SASL_CONF_PATH}/sasldb2"

# Run memcached on port 11212 with SASL support
"${HOME}/memcached/bin/memcached" -S -d -p 11212
}

function build_php_memcached() {
pear package
mkdir "$PHP_MEMCACHED_BUILD_DIR"
tar xfz "memcached-${PHP_MEMCACHED_VERSION}.tgz" -C "$PHP_MEMCACHED_BUILD_DIR"
pushd "${PHP_MEMCACHED_BUILD_DIR}/memcached-${PHP_MEMCACHED_VERSION}"
phpize

local protocol_flag=""
if test "x$ENABLE_PROTOCOL" = "xyes"; then
protocol_flag="--enable-memcached-protocol"
fi

local sasl_flag="--disable-memcached-sasl"
if test "x$ENABLE_SASL" = "xyes"; then
sasl_flag="--enable-memcached-sasl"
fi

./configure --with-libmemcached-dir="$LIBMEMCACHED_PREFIX" $protocol_flag $sasl_flag --enable-memcached-json --enable-memcached-igbinary --enable-memcached-msgpack
make
make install
popd
}

function create_memcached_test_configuration() {
cat<<EOF > "${PHP_MEMCACHED_BUILD_DIR}/memcached-${PHP_MEMCACHED_VERSION}/tests/config.inc.local"
<?php
define ("MEMC_SERVER_HOST", "127.0.0.1");
define ("MEMC_SERVER_PORT", 11211);

define ("MEMC_SASL_SERVER_HOST", "127.0.0.1");
define ("MEMC_SASL_SERVER_PORT", 11212);

define ('MEMC_SASL_USER', 'memcached');
define ('MEMC_SASL_PASS', 'test');
EOF
}

function run_memcached_tests() {
export NO_INTERACTION=1
export REPORT_EXIT_STATUS=1
export TEST_PHP_EXECUTABLE=`which php`

pushd "${PHP_MEMCACHED_BUILD_DIR}/memcached-${PHP_MEMCACHED_VERSION}"
# We have one xfail test, we run it separately
php run-tests.php -d extension=msgpack.so -d extension=igbinary.so -d extension=memcached.so -n ./tests/expire.phpt
rm ./tests/expire.phpt

# Run normal tests
php run-tests.php -d extension=msgpack.so -d extension=igbinary.so -d extension=memcached.so -n ./tests/*.phpt
retval=$?
for i in `ls tests/*.out 2>/dev/null`; do
echo "-- START ${i}";
cat $i;
echo "";
echo "-- END";
done
popd

return $retval;
}

# Command line arguments
ACTION=$1
LIBMEMCACHED_VERSION=$2

if test "x$ACTION" = "x"; then
echo "Usage: $0 <action> <libmemcached version>"
exit 1
fi

if test "x$LIBMEMCACHED_VERSION" = "x"; then
echo "Usage: $0 <action> <libmemcached version>"
exit 1
fi

# the extension version
PHP_MEMCACHED_VERSION=$(php -r '$sxe = simplexml_load_file ("package.xml"); echo (string) $sxe->version->release;')

# Libmemcached install dir
LIBMEMCACHED_PREFIX="${HOME}/libmemcached-${LIBMEMCACHED_VERSION}"

# Where to do the build
PHP_MEMCACHED_BUILD_DIR="/tmp/php-memcached-build"

# Check whether to enable building with protoocol and sasl support
check_protocol_support
check_sasl_support

echo "Enable protocol: $ENABLE_PROTOOCOL"
echo "Enable sasl: $ENABLE_SASL"

set -e

case $ACTION in
before_script)
# validate the package.xml
validate_package_xml || exit 1

# Install libmemcached version
install_libmemcached

# Install igbinary extension
install_igbinary

# install msgpack
install_msgpack

# install SASL
if test "x$ENABLE_SASL" = "xyes"; then
install_sasl
fi
;;

script)
# Build the extension
build_php_memcached

# Create configuration
if test "x$ENABLE_SASL" = "xyes"; then
create_memcached_test_configuration
fi

# Run tests
set +e
run_memcached_tests || exit 1
;;

*)
echo "Unknown action. Valid actions are: before_script and script"
exit 1
;;
esac





1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Version 2.2.0b1
* Added support for memcached protocol handlers
* Added Memcached::setBucket for virtual bucket support
* Added support for msgpack serialization
* Memcached::setSaslAuthData returns correct status on success

Version 2.1.0
-------------
Expand Down
42 changes: 35 additions & 7 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,6 @@ if test "$PHP_MEMCACHED" != "no"; then
AC_MSG_RESULT([disabled])
fi


if test "$PHP_MEMCACHED_SASL" != "no"; then
AC_CHECK_HEADERS([sasl/sasl.h], [memcached_enable_sasl="yes"], [memcached_enable_sasl="no"])
AC_MSG_CHECKING([whether to enable sasl support])
AC_MSG_RESULT([$memcached_enable_sasl])
fi

AC_MSG_CHECKING([for libmemcached location])
export ORIG_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"

Expand Down Expand Up @@ -362,6 +355,41 @@ if test "$PHP_MEMCACHED" != "no"; then
)
])

AC_MSG_CHECKING([whether to enable sasl support])
if test "$PHP_MEMCACHED_SASL" != "no"; then
AC_MSG_RESULT(yes)

AC_CHECK_HEADERS([sasl/sasl.h], [ac_cv_have_memc_sasl_h="yes"], [ac_cv_have_memc_sasl_h="no"])

if test "$ac_cv_have_memc_sasl_h" = "yes"; then

AC_CACHE_CHECK([whether libmemcached supports sasl], ac_cv_memc_sasl_support, [
AC_TRY_COMPILE(
[ #include <libmemcached/memcached.h> ],
[
#if LIBMEMCACHED_WITH_SASL_SUPPORT
/* yes */
#else
# error "no sasl support"
#endif
],
[ ac_cv_memc_sasl_support="yes" ],
[ ac_cv_memc_sasl_support="no" ]
)
])

if test "$ac_cv_memc_sasl_support" = "yes"; then
AC_DEFINE(HAVE_MEMCACHED_SASL, 1, [Have SASL support])
else
AC_MSG_ERROR([no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check])
fi
else
AC_MSG_ERROR([no, sasl.h is not available. Run configure with --disable-memcached-sasl to disable this check])
fi
else
AC_MSG_RESULT([no])
fi

CFLAGS="$ORIG_CFLAGS"
LIBS="$ORIG_LIBS"

Expand Down
3 changes: 3 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Added support for memcached protocol handlers
- Added Memcached::setBucket for virtual bucket support
- Added support for msgpack serialization
- Memcached::setSaslAuthData returns correct status on success
</notes>
<contents>
<dir name="/">
Expand All @@ -63,6 +64,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file role='src' name='config.w32'/>
<file role='src' name='php_memcached.c'/>
<file role='src' name='php_memcached.h'/>
<file role='src' name='php_memcached_private.h'/>
<file role='src' name='php_memcached_session.c'/>
<file role='src' name='php_memcached_session.h'/>
<file role='src' name='php_libmemcached_compat.h'/>
Expand Down Expand Up @@ -147,6 +149,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file role='test' name='keys.phpt'/>
<file role='test' name='testdata.res'/>
<file role='test' name='config.inc'/>
<file role='test' name='sasl_basic.phpt'/>
</dir>
</dir>
</contents>
Expand Down
6 changes: 6 additions & 0 deletions php_libmemcached_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ memcached_st *php_memc_create_str (const char *str, size_t str_len);
# define MEMCACHED_SERVER_TEMPORARILY_DISABLED (1024 << 2)
#endif

#ifdef HAVE_MEMCACHED_INSTANCE_ST
typedef const memcached_instance_st * php_memcached_instance_st;
#else
typedef memcached_server_instance_st php_memcached_instance_st;
#endif

#endif
Loading