mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Practracker: add an integration test.
This test runs practracker with a set of 0 thresholds, to make sure that it enumerates all its values right. It tries running with an empty exceptions file, and with an exceptions file that covers _some_ of the data, and it makes sure that the outputs are as expected.
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
umask 077
|
||||
|
||||
TMPDIR=""
|
||||
clean () {
|
||||
if [ -n "$TMPDIR" ] && [ -d "$TMPDIR" ]; then
|
||||
rm -rf "$TMPDIR"
|
||||
fi
|
||||
}
|
||||
trap clean EXIT HUP INT TERM
|
||||
|
||||
if test "${PRACTRACKER_DIR}" = "" ||
|
||||
test ! -e "${PRACTRACKER_DIR}/practracker.py" ; then
|
||||
PRACTRACKER_DIR=$(dirname "$0")
|
||||
fi
|
||||
|
||||
TMPDIR="$(mktemp -d -t pracktracker.test.XXXXXX)"
|
||||
if test -z "${TMPDIR}" || test ! -d "${TMPDIR}" ; then
|
||||
echo >&2 "mktemp failed."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
DATA="${PRACTRACKER_DIR}/testdata"
|
||||
|
||||
run_practracker() {
|
||||
"${PYTHON:-python}" "${PRACTRACKER_DIR}/practracker.py" \
|
||||
--max-include-count=0 --max-file-size=0 --max-function-size=0 --terse \
|
||||
"${DATA}/" "$@";
|
||||
}
|
||||
|
||||
echo "ex0:"
|
||||
|
||||
run_practracker --exceptions "${DATA}/ex0.txt" > "${TMPDIR}/ex0-received.txt"
|
||||
|
||||
if cmp "${TMPDIR}/ex0-received.txt" "${DATA}/ex0-expected.txt" ; then
|
||||
echo " OK"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "ex1:"
|
||||
|
||||
run_practracker --exceptions "${DATA}/ex1.txt" > "${TMPDIR}/ex1-received.txt"
|
||||
|
||||
if cmp "${TMPDIR}/ex1-received.txt" "${DATA}/ex1-expected.txt" ;then
|
||||
echo " OK"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user