source: web/old/remctl-2.14/php/test-wrapper @ f6f3e91

web
Last change on this file since f6f3e91 was f6f3e91, checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago

Preserve directory hierarchy (not sure what happened to it)

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