1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
#! /bin/sh
#
# This wrapper exists for two reasons: to work around a bug in the
# phpize-generated test suite on Debian, and because I'm not a PHP programmer
# and didn't want to figure out how to spawn a test version of remctld inside
# PHP.
#
# This script starts a remctl server, if the right configuration is available,
# and works around the Debian bug, then runs make test, and then cleans up.
# It takes the path to the top of the remctl build directory and the top of
# the source directory as its arguments and should be run from the php
# directory.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2008-2009
# The Board of Trustees of the Leland Stanford Junior University
#
# SPDX-License-Identifier: MIT
if [ -z "$1" ] ; then
echo 'Missing top build directory argument' >&2
exit 1
fi
top="$1"
if [ -z "$2" ] ; then
echo 'Missing top source directory argument' >&2
exit 1
fi
source="$2"
# Debian loads additional modules from /etc/php5/cli/conf.d, and the test
# framework doesn't deal with this. PHP only allows one module directory, so
# when the test framework overrides the module directory, none of the standard
# modules can be found. This causes initialization to fail and the tests to
# fail.
#
# Work around it by extracting the regular PHP module directory from the
# generated Makefile and then symlinking all modules in that directory into
# the modules/ subdirectory used by the test suite.
path=`grep '^EXTENSION_DIR *=' Makefile | sed 's/.* //'`
if [ -z "$path" ] ; then
echo 'Cannot find EXTENSION_DIR in Makefile' >&2
exit 1
fi
for module in "$path"/*.so ; do
name=`basename "$module"`
if [ "$name" = "remctl.so" ] ; then
continue
fi
ln -s "$module" modules/"$name"
done
# Check whether we have a Kerberos configuration. If we do, we'll start a
# remctl daemon and obtain a local ticket cache, and then touch a file telling
# PHP to do the tests that require authentication.
if [ -f "$top/tests/config/keytab" ] ; then
rm -f remctl-test.pid
principal=`cat "$top/tests/config/principal"`
keytab="$top/tests/config/keytab"
( cd "$source/tests" && "$top/server/remctld" -m -p 14373 \
-s "$principal" -P "$top/php/remctl-test.pid" -f "data/conf-simple" \
-d -S -F -k "$keytab" 2>&1 &) > remctl-test.out
# Try a few different syntaxes for kinit to allow for Heimdal, MIT, or the
# Stanford-local hack.
KRB5CCNAME="`pwd`"/remctl-test.cache
export KRB5CCNAME
kinit --no-afslog -k -t "$keytab" "$principal" >/dev/null 2>&1 </dev/null
status=$?
if [ $status != 0 ] ; then
kinit -k -t "$keytab" "$principal" >/dev/null 2>&1 </dev/null
status=$?
fi
if [ $status != 0 ] ; then
kinit -t "$keytab" "$principal" >/dev/null 2>&1 </dev/null
status=$?
fi
if [ $status != 0 ] ; then
kinit -k -K "$keytab" "$principal" >/dev/null 2>&1 </dev/null
status=$?
fi
# Wait for the remctl server to finish starting. Then, if we couldn't get
# Kerberos tickets, kill the remctl server.
[ -f remctl-test.pid ] || sleep 1
if [ $status != 0 ] ; then
echo 'Unable to obtain Kerberos tickets' >&2
if [ -f remctl-test.pid ] ; then
kill -HUP `cat remctl-test.pid`
fi
rm -f remctl-test.pid
else
if [ ! -f remctl-test.pid ] ; then
echo 'remctld did not start' >&2
else
echo "$principal" > remctl-test.princ
fi
fi
fi
# Now we can finally run the tests, which will use remctl-test.pid as a flag
# for whether to try the Kerberos tests.
env LD_LIBRARY_PATH="$top"/client/.libs make test
status=$?
# Kill the remctl server.
rm -f remctl-test.cache remctl-test.princ
if [ "$status" = 0 ] ; then
rm -f remctl-test.out
fi
if [ -f remctl-test.pid ] ; then
kill -TERM `cat remctl-test.pid`
rm -f remctl-test.pid
fi
# Clean up our symlinks.
for file in modules/* ; do
if [ `basename "$file"` != remctl.so ] ; then
rm "$file"
fi
done
# Exit with the exit status of the tests.
exit "$status"
|