]>
Commit | Line | Data |
---|---|---|
81a114e5 BP |
1 | #! /bin/sh |
2 | ||
3 | set -e | |
4 | ||
5 | run () { | |
6 | echo "$@" | |
7 | "$@" || exit 1 | |
8 | } | |
9 | ||
10 | # Put built tools early in $PATH. | |
11 | builddir=`pwd` | |
12 | if test ! -e vswitchd/ovs-vswitchd; then | |
13 | echo >&2 'not in build directory, please change directory or run via \"make check-oftest' | |
14 | exit 1 | |
15 | fi | |
16 | PATH=$builddir/ovsdb:$builddir/vswitchd:$builddir/utilities:$PATH; export PATH | |
17 | ||
18 | # Find srcdir. | |
19 | case $srcdir in | |
20 | '') srcdir=$builddir ;; | |
21 | /*) ;; | |
22 | *) srcdir=`pwd`/$srcdir ;; | |
23 | esac | |
3c8a3b31 | 24 | if test ! -e "$srcdir"/README.rst; then |
81a114e5 BP |
25 | echo >&2 'source directory not found, please set $srcdir or run via \"make check-oftest' |
26 | exit 1 | |
27 | fi | |
28 | ||
29 | # Make sure oftest is available. | |
30 | if test X"$OFT" = X; then | |
31 | OFT=oft | |
32 | fi | |
33 | if ($OFT --version) >/dev/null 2>&1; then | |
34 | : | |
35 | else | |
36 | echo >&2 'OFTest "oft" binary not found or cannot be run, please add to $PATH or set $OFT' | |
37 | exit 1 | |
38 | fi | |
39 | ||
40 | # Create sandbox. | |
41 | rm -rf sandbox | |
42 | mkdir sandbox | |
43 | cd sandbox | |
44 | sandbox=`pwd` | |
45 | ||
46 | # Set up environment for OVS programs to sandbox themselves. | |
47 | OVS_RUNDIR=$sandbox; export OVS_RUNDIR | |
48 | OVS_LOGDIR=$sandbox; export OVS_LOGDIR | |
49 | OVS_DBDIR=$sandbox; export OVS_DBDIR | |
50 | OVS_SYSCONFDIR=$sandbox; export OVS_SYSCONFDIR | |
51 | ||
52 | trap 'kill `cat *.pid`' 0 1 2 3 13 14 15 | |
53 | ||
54 | # Create database and start ovsdb-server. | |
55 | touch .conf.db.~lock~ | |
56 | rm -f conf.db | |
57 | run ovsdb-tool create conf.db "$srcdir"/vswitchd/vswitch.ovsschema | |
58 | run ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \ | |
59 | --remote=punix:"$sandbox"/db.sock | |
60 | ||
61 | # Start ovs-vswitchd. | |
62 | run ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file \ | |
63 | --enable-dummy --disable-system -vvconn -vnetdev_dummy | |
64 | ||
65 | # Add a bridge and some ports for OFTest to use, | |
66 | # and configure ovs-vswitchd to connect to OFTest. | |
67 | run ovs-vsctl --no-wait \ | |
68 | -- add-br br0 \ | |
69 | -- set bridge br0 datapath-type=dummy fail-mode=secure | |
70 | for port in p1 p2 p3 p4; do | |
71 | run ovs-vsctl --no-wait \ | |
5a0e4aec BP |
72 | -- add-port br0 $port \ |
73 | -- set interface $port type=dummy \ | |
81a114e5 BP |
74 | options:pstream=punix:$OVS_RUNDIR/$port |
75 | done | |
76 | run ovs-vsctl \ | |
91a5b5be | 77 | -- set-controller br0 tcp:127.0.0.1:6653 \ |
81a114e5 BP |
78 | -- set controller br0 connection-mode=out-of-band max-backoff=1000 |
79 | ||
80 | # Run OFTest. | |
81 | run $OFT -P ovs-dummy $OFTFLAGS; status=$? | |
82 | ||
83 | cat <<EOF | |
84 | ||
85 | ---------------------------------------------------------------------- | |
86 | Logs may be found under $sandbox, e.g.: | |
5a0e4aec BP |
87 | $sandbox/oft.log |
88 | $sandbox/ovs-vswitchd.log | |
89 | $sandbox/ovsdb-server.log | |
81a114e5 BP |
90 | ---------------------------------------------------------------------- |
91 | EOF | |
92 | ||
93 | # Propagate OFTest exit status. | |
94 | exit $status |