tests: converted part of the test suite to run with cwrap

That allows several tests to run as non-root.
This commit is contained in:
Nikos Mavrogiannopoulos
2015-11-19 10:44:31 +01:00
parent a09d4f51ab
commit 345a752676
23 changed files with 185 additions and 102 deletions

View File

@@ -22,9 +22,21 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#this test can only be run as root
id|grep root >/dev/null 2>&1
if [ $? != 0 ];then
exit 77
OPENCONNECT=/usr/sbin/openconnect
if test -z "$NO_NEED_ROOT";then
id|grep root >/dev/null 2>&1
if [ $? != 0 ];then
exit 77
fi
else
SOCKDIR=${srcdir}/sockwrap.$$.tmp
mkdir -p $SOCKDIR
export SOCKET_WRAPPER_DIR=$SOCKDIR
export SOCKET_WRAPPER_DEFAULT_IFACE=2
ADDRESS=127.0.0.$SOCKET_WRAPPER_DEFAULT_IFACE
OPENCONNECT="eval LD_PRELOAD=libsocket_wrapper.so /usr/sbin/openconnect"
fi
if ! test -x /usr/sbin/openconnect;then
@@ -32,7 +44,6 @@ if ! test -x /usr/sbin/openconnect;then
exit 77
fi
OPENCONNECT=/usr/sbin/openconnect
fail() {
PID=$1
@@ -54,8 +65,24 @@ launch_server() {
fi
}
launch_sr_server() {
LD_PRELOAD=libsocket_wrapper.so:libuid_wrapper.so UID_WRAPPER=1 UID_WRAPPER_ROOT=1 $SERV $* >/dev/null 2>&1 &
LOCALPID="$!";
trap "[ ! -z \"${LOCALPID}\" ] && kill ${LOCALPID};" 15
wait "${LOCALPID}"
LOCALRET="$?"
if [ "${LOCALRET}" != "0" ] && [ "${LOCALRET}" != "143" ] ; then
# Houston, we'v got a problem...
exit 1
fi
}
launch_simple_sr_server() {
LD_PRELOAD=libsocket_wrapper.so:libuid_wrapper.so UID_WRAPPER=1 UID_WRAPPER_ROOT=1 $SERV $* >/dev/null 2>&1 &
}
launch_simple_server() {
$SERV $* >/dev/null 2>&1 &
$PRELOAD_CMD $SERV $* >/dev/null 2>&1 &
}
launch_debug_server() {
@@ -75,4 +102,10 @@ wait_server() {
sleep 5
}
cleanup() {
kill $PID
wait
test -n "$SOCKDIR" && rm -rf $SOCKDIR
}
trap "fail \"Failed to launch the server, aborting test... \"" 10