-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathruntest
executable file
·87 lines (71 loc) · 1.83 KB
/
runtest
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
#!/bin/sh -e
TOP_SRCDIR=$(readlink -f $(dirname $0))
PYTHON=${PYTHON:-$(which python3)}
if [ "$1" = "PYTHON" ]
then
CMD="$PYTHON -m unittest discover --verbose -s ${TOP_SRCDIR}/python"
DEBUG_CMD="$CMD"
else
CMD=$(readlink -f "$1")
DEBUG_CMD="$CMD"
fi
## Run under eatmydata if available
libeatmydata="/usr/lib/x86_64-linux-gnu/libeatmydata.so"
if [ -e $libeatmydata ]
then
if [ -n "$LD_PRELOAD" ]; then
export LD_PRELOAD="$libeatmydata $LD_PRELOAD"
else
export LD_PRELOAD="$libeatmydata"
fi
fi
## Set up the test environment
export WREPORT_TABLES=$TOP_SRCDIR/tables
export WREPORT_TESTDATA=$TOP_SRCDIR/testdata
# See https://docs.python.org/3/library/devmode.html
export PYTHONDEVMODE=1
ORIGDIR=`pwd`
TESTDIR="`mktemp -d`"
echo "Moving to test directory $TESTDIR"
cd "$TESTDIR"
## Clean up the test environment at exit unless asked otherwise
cleanup() {
if [ ! -z "$PAUSE" ]
then
echo "Post-test inspection requested."
echo "Exit this shell to cleanup the test environment."
bash
fi
test -z "$PRESERVE" && rm -rf "$TESTDIR"
}
trap cleanup EXIT
## Run the tests
#id=`date +%y%m%d%H%M%S`
#$DEBUGGER $BIN $ARGS 2>&1 | tee `pwd`/testrun-$id
#echo Output saved in `pwd`/testrun-$id
# Try to debug the libtool executable, if present
if [ ! -z "$DEBUGGER" ]
then
if [ "$DEBUGGER" = "valgrind" ]
then
# See https://stackoverflow.com/questions/20112989/how-to-use-valgrind-with-python
export PYTHONMALLOC=malloc
fi
echo "Running $DEBUGGER $DEBUG_CMD $ARGS"
RES=0
if ! libtool --mode=execute $DEBUGGER $DEBUG_CMD $ARGS
then
RES=$?
echo "Failed with result $RES"
fi
else
echo "Running $CMD $ARGS"
if $CMD $ARGS
then
RES=0
else
RES=$?
echo "Failed with result $RES"
fi
fi
exit $RES