[Pkg-php-commits] [php/debian-sid] Test the mysql extensions too
Raphael Geissert
geissert at debian.org
Wed May 5 21:06:32 UTC 2010
---
debian/control | 2 +
debian/rules | 32 +++++++++++++++++------
debian/setup-mysql.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 92 insertions(+), 9 deletions(-)
create mode 100755 debian/setup-mysql.sh
diff --git a/debian/control b/debian/control
index c2667a8..b295add 100644
--- a/debian/control
+++ b/debian/control
@@ -56,7 +56,9 @@ Build-Depends: apache2-prefork-dev,
libxml2-dev,
libxslt1-dev (>= 1.0.18),
locales-all,
+ mysql-server,
netbase,
+ netcat-traditional,
quilt,
re2c,
unixodbc-dev,
diff --git a/debian/rules b/debian/rules
index 8b086ca..1677f36 100755
--- a/debian/rules
+++ b/debian/rules
@@ -24,6 +24,13 @@ PHP5_SOURCE_VERSION = $(shell dpkg-parsechangelog | grep ^Version | sed "s/Ver
PHP5_UPSTREAM_VERSION = $(shell echo $(PHP5_SOURCE_VERSION) | sed -e "s/-.*//" -e "s/.*://")
PHP5_DEBIAN_REVISION = $(shell echo $(PHP5_SOURCE_VERSION) | sed "s/.*-//")
+MYSQL_PORT := $(shell for i in $$(seq 1025 3600); do nc -z localhost $$i || { echo $$i; exit; } ; done)
+MYSQL_DATA_DIR ?= $(shell readlink -f mysql_db)
+ifeq (,$(MYSQL_PORT))
+ $(error Could not find available port for mysql server)
+endif
+MYSQL_SOCKET = $(MYSQL_DATA_DIR)/mysql.sock
+
# specify some options to our patch system
QUILT_DIFF_OPTS=-p
QUILT_NO_DIFF_TIMESTAMPS=1
@@ -149,28 +156,35 @@ unprepared:
test-results.txt: build-apache2-stamp build-cli-stamp build-cgi-stamp
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
mkdir -p temp_session_store
+ # start our own mysql server for the tests
+ $(SHELL) debian/setup-mysql.sh $(MYSQL_PORT) $(MYSQL_DATA_DIR)
extensions=""; \
for f in $(CURDIR)/apache2-build/modules/*.so; do \
ext=`basename "$$f"`; \
test -d "$(CURDIR)/ext/$${ext%.so}/tests" || continue; \
- test ! -f "$(CURDIR)/ext/$${ext%.so}/tests/config.inc" || continue; \
- test ! -f "$(CURDIR)/ext/$${ext%.so}/tests/README" || continue; \
- test "$${ext#pdo}" = "$$ext" || test "$${ext#pdo}" = ".so" || continue; \
- test "$$ext" != "mysql.so" || continue; \
- test "$$ext" != "mysqli.so" || continue; \
- test "$$ext" != "snmp.so" || continue; \
+ test "$$ext" != "imap.so" || continue; \
test "$$ext" != "interbase.so" || continue; \
+ test "$$ext" != "ldap.so" || continue; \
+ test "$$ext" != "odbc.so" || continue; \
+ test "$$ext" != "pgsql.so" || continue; \
+ test "$$ext" != "pdo_dblib.so" || continue; \
+ test "$$ext" != "pdo_firebird.so" || continue; \
+ test "$$ext" != "pdo_odbc.so" || continue; \
+ test "$$ext" != "pdo_pgsql.so" || continue; \
+ test "$$ext" != "snmp.so" || continue; \
extensions="$$extensions -d extension=$$ext"; \
done; \
[ "$$extensions" ] || { echo "extensions list is empty"; exit 1; }; \
- env NO_INTERACTION=1 TEST_PHP_CGI_EXECUTABLE=$(CURDIR)/cgi-build/sapi/cgi/cgi-bin.php5 TEST_PHP_EXECUTABLE=$(CURDIR)/cli-build/sapi/cli/php $(CURDIR)/cli-build/sapi/cli/php run-tests.php -d extension_dir=$(CURDIR)/apache2-build/modules/ $$extensions| tee test-results.txt
+ env MYSQL_TEST_PORT=$(MYSQL_PORT) MYSQL_TEST_SOCKET=$(MYSQL_SOCKET) PDO_MYSQL_TEST_PORT=$(MYSQL_PORT) PDO_MYSQL_TEST_SOCKET=$(MYSQL_SOCKET) NO_INTERACTION=1 TEST_PHP_CGI_EXECUTABLE=$(CURDIR)/cgi-build/sapi/cgi/cgi-bin.php5 TEST_PHP_EXECUTABLE=$(CURDIR)/cli-build/sapi/cli/php \
+ $(CURDIR)/cli-build/sapi/cli/php run-tests.php -d mysql.default_socket=$(MYSQL_SOCKET) -d mysqli.default_socket=$(MYSQL_SOCKET) -d extension_dir=$(CURDIR)/apache2-build/modules/ $$extensions| tee test-results.txt
rm -rf temp_session_store
- @for test in `find . -name '*.log' -a '!' -name 'config.log'`; do \
+ @for test in `find . -name '*.log' -a '!' -name 'config.log' -a '!' -name 'bootstrap.log' -a '!' -name 'run.log'`; do \
echo; \
echo -n "$${test#./}:"; \
cat $$test; \
echo; \
done | tee -a test-results.txt
+ $(SHELL) debian/setup-mysql.sh $(MYSQL_PORT) $(MYSQL_DATA_DIR) stop
else
echo 'nocheck found in DEB_BUILD_OPTIONS' | tee test-results.txt
endif
@@ -365,7 +379,7 @@ clean: unprepared unpatch
rm -rf cli-build
rm -rf pear-build pear-build-download
rm -f debian/copyright
- rm -f test-results.txt
+ rm -f test-results.txt $(MYSQL_DATA_DIR)
dh_clean -Xorig
# clean up autogenerated cruft
diff --git a/debian/setup-mysql.sh b/debian/setup-mysql.sh
new file mode 100755
index 0000000..57dc293
--- /dev/null
+++ b/debian/setup-mysql.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+set -eu
+
+[ $# -ge 2 ] || {
+ echo "Usage: debian/setup-mysql.sh port data-dir" >&2
+ exit 1
+}
+
+# CLI arguments #
+port=$1
+datadir=$2
+action=${3:-start}
+
+# Some vars #
+
+socket=$datadir/mysql.sock
+# Commands:
+mysqladmin="mysqladmin -u root -P $port -h localhost --socket=$socket"
+mysqld="/usr/sbin/mysqld --no-defaults --bind-address=localhost --port=$port --socket=$socket --datadir=$datadir"
+
+# Main code #
+
+if [ "$action" = "stop" ]; then
+ $mysqladmin shutdown
+ exit
+fi
+
+rm -rf $datadir
+mkdir -p $datadir
+chown go-rx $datadir
+
+mysql_install_db --datadir=$datadir --rpm --force >> $datadir/bootstrap.log 2>&1
+
+tmpf=$(mktemp)
+cat > "$tmpf" <<EOF
+USE mysql;
+UPDATE user SET password=PASSWORD('') WHERE user='root';
+FLUSH PRIVILEGES;
+EOF
+
+$mysqld --bootstrap --skip-grant-tables < "$tmpf" >> $datadir/bootstrap.log 2>&1
+
+unlink "$tmpf"
+
+# Start the daemon
+$mysqld > $datadir/run.log 2>&1 &
+
+pid=$!
+
+# wait for the server to be actually available
+c=0;
+while ! nc -z localhost $port; do
+ c=$(($c+1));
+ sleep 3;
+ if [ $c -gt 20 ]; then
+ echo "Timed out waiting for mysql server to be available" >&2
+ if [ "$pid" ]; then
+ kill $pid || :
+ sleep 2
+ kill -s KILL $pid || :
+ fi
+ exit 1
+ fi
+done
+
+$mysqladmin create test
--
1.6.5
More information about the Pkg-php-commits
mailing list