forked from distributed-system-analysis/configtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunittests
executable file
·56 lines (43 loc) · 1.31 KB
/
unittests
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
#! /bin/bash
# -*- mode: shell-script -*-
tmp=/tmp/configtools.test.$$
mkdir -p $tmp
# trap "rm -rf $tmp" EXIT INT QUIT
ver=$(python -c 'import sys; print("%d.%d" % sys.version_info[:2])')
python setup.py build
# So *always* use the in-tree version of configtools here.
# prefix better be right at this point
if [[ ! -f build/scripts-$ver/getconf.py ]]
then
echo "Cannot find getconf.py: build/scripts-$ver/getconf.py" 1>&2
exit 1
fi
ppathins() {
if [ -d "$1" ] && [[ ":$PYTHONPATH:" != *":$1:"* ]]; then
PYTHONPATH="$1:$PYTHONPATH"
fi
}
export PYTHONPATH
ppathins $PWD/build/lib
bin=$PWD/build/scripts-$ver
function run_test {
testnum=$1
shift
dir=$1
shift
eval "$bin/$dir $*" > $tmp/test.out 2>&1
echo Test $testnum
if diff $tmp/test.out gold/$dir/$testnum.out ; then
echo PASS
else
echo FAIL
fi
}
run_test 1 getconf.py --config samples/foo.conf bar foo
run_test 2 getconf.py --config samples/foo.conf baz foo
run_test 3 getconf.py --config samples/foo.conf -a foo
run_test 4 getconf.py --config samples/foo.conf foo foo
run_test 1 gethosts.py --config samples/hosts.conf -a
run_test 2 gethosts.py --config samples/hosts.conf -c clients
run_test 3 gethosts.py --config samples/hosts.conf -c servers
run_test 4 gethosts.py --config samples/hosts.conf -L