ceph/src/test/run-cli-tests
Tommi Virtanen 5a0bc6b78f Sanitize environment before running clitests.
This avoids CEPH_KEYRING etc from slipping in.
2011-01-14 17:27:59 -08:00

44 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
set -e
if ! command -v pip >/dev/null; then
echo "$0: PIP not installed, skipping python-using tests." 1>&2
exit 1
fi
SRCDIR="$(dirname "$0")"
# build directory, if different, can be passed as an argument;
# it is expected to point to the equivalent subdirectory of the
# tree as where this script is stored
BUILDDIR="$SRCDIR"
case "$1" in
''|-*)
# not set or looks like a flag to cram
;;
*)
# looks like the builddir
BUILDDIR="$1"
shift
;;
esac
VENV="$BUILDDIR/virtualenv"
CRAM_BIN="$VENV/bin/cram"
if [ ! -e "$CRAM_BIN" ]; then
pip -E "$VENV" install "$SRCDIR/downloads/cram-0.5.0ceph.2011-01-14.tar.gz"
fi
SRCDIR_ABS="$(readlink -f "$SRCDIR")"
BUILDDIR_ABS="$(readlink -f "$BUILDDIR")"
# cram doesn't like seeing the same foo.t basename twice on the same
# run, so run it once per directory
for tool in "$SRCDIR"/cli/*; do
toolname="$(basename "$tool")"
install -d -m0755 -- "$BUILDDIR/cli/$toolname"
env --ignore-environment \
PATH="$BUILDDIR_ABS/..:$SRCDIR_ABS/..:$PATH" \
"$CRAM_BIN" -v "$@" --error-dir="$BUILDDIR/cli/$toolname" -- "$tool"/*.t
done