]> git.proxmox.com Git - ovs.git/blame - tests/unixctl-py.at
command-line: Add function to print all options.
[ovs.git] / tests / unixctl-py.at
CommitLineData
0a68ffd2
EJ
1AT_BANNER([unixctl])
2
f4ec6ff4
EJ
3m4_define([APPCTL], [ovs-appctl --timeout 20])
4m4_define([PYAPPCTL], [$PYTHON $srcdir/appctl.py --timeout 20])
5
0a68ffd2
EJ
6AT_SETUP([unixctl ovs-vswitchd exit - Python])
7AT_SKIP_IF([test $HAVE_PYTHON = no])
8OVS_VSWITCHD_START
9
f4ec6ff4 10AT_CHECK([PYAPPCTL -t ovs-vswitchd exit], [0], [])
0a68ffd2
EJ
11OVS_WAIT_WHILE([test -s ovs-vswitchd.pid])
12
f4ec6ff4 13AT_CHECK([PYAPPCTL -t ovsdb-server exit], [0], [])
0a68ffd2
EJ
14OVS_WAIT_WHILE([test -s ovsdb-server.pid])
15AT_CLEANUP
16
17AT_SETUP([unixctl ovs-vswitchd help - Python])
18AT_SKIP_IF([test $HAVE_PYTHON = no])
19OVS_VSWITCHD_START
20
f4ec6ff4 21AT_CHECK([APPCTL help], [0], [stdout])
0a68ffd2
EJ
22AT_CHECK([head -1 stdout], [0], [dnl
23The available commands are:
24])
25mv stdout expout
f4ec6ff4 26AT_CHECK([PYAPPCTL help], [0], [expout])
0a68ffd2
EJ
27
28OVS_VSWITCHD_STOP
29AT_CLEANUP
30
31
32AT_SETUP([unixctl ovs-vswitchd arguments - Python])
33AT_SKIP_IF([test $HAVE_PYTHON = no])
34OVS_VSWITCHD_START
35
f4ec6ff4 36AT_CHECK([APPCTL bond/hash], [2], [], [stderr])
0a68ffd2
EJ
37AT_CHECK([head -1 stderr], [0], [dnl
38"bond/hash" command requires at least 1 arguments
39])
40sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 41AT_CHECK([PYAPPCTL bond/hash], [2], [], [experr])
0a68ffd2 42
f4ec6ff4 43AT_CHECK([APPCTL bond/hash mac], [2], [], [stderr])
0a68ffd2
EJ
44AT_CHECK([head -1 stderr], [0], [dnl
45invalid mac
46])
47sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 48AT_CHECK([PYAPPCTL bond/hash mac], [2], [], [experr])
0a68ffd2 49
f4ec6ff4 50AT_CHECK([APPCTL bond/hash mac vlan], [2], [], [stderr])
0a68ffd2
EJ
51AT_CHECK([head -1 stderr], [0], [dnl
52invalid vlan
53])
54sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 55AT_CHECK([PYAPPCTL bond/hash mac vlan], [2], [], [experr])
0a68ffd2 56
f4ec6ff4 57AT_CHECK([APPCTL bond/hash mac vlan basis], [2], [], [stderr])
0a68ffd2
EJ
58AT_CHECK([head -1 stderr], [0], [dnl
59invalid vlan
60])
61sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 62AT_CHECK([PYAPPCTL bond/hash vlan basis], [2], [], [experr])
0a68ffd2 63
f4ec6ff4 64AT_CHECK([APPCTL bond/hash mac vlan basis extra], [2], [], [stderr])
0a68ffd2
EJ
65AT_CHECK([head -1 stderr], [0], [dnl
66"bond/hash" command takes at most 3 arguments
67])
68sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 69AT_CHECK([PYAPPCTL bond/hash mac vlan basis extra], [2], [], [experr])
0a68ffd2
EJ
70
71OVS_VSWITCHD_STOP
72AT_CLEANUP
73
74AT_SETUP([unixctl bad target - Python])
37d03458 75OVS_RUNDIR=`pwd`; export OVS_RUNDIR
f973f2af 76OVS_DBDIR=`pwd`; export OVS_DBDIR
0a68ffd2
EJ
77AT_SKIP_IF([test $HAVE_PYTHON = no])
78
f4ec6ff4 79AT_CHECK([PYAPPCTL -t bogus doit], [1], [], [stderr])
0a68ffd2 80AT_CHECK_UNQUOTED([tail -1 stderr], [0], [dnl
37d03458 81appctl.py: cannot read pidfile "`pwd`/bogus.pid" (No such file or directory)
0a68ffd2
EJ
82])
83
f4ec6ff4 84AT_CHECK([PYAPPCTL -t /bogus/path.pid doit], [1], [], [stderr])
0a68ffd2
EJ
85AT_CHECK([tail -1 stderr], [0], [dnl
86appctl.py: cannot connect to "/bogus/path.pid" (No such file or directory)
87])
88
89AT_CLEANUP
90
91AT_SETUP([unixctl server - Python])
92AT_SKIP_IF([test $HAVE_PYTHON = no])
37d03458
BP
93OVS_RUNDIR=`pwd`; export OVS_RUNDIR
94OVS_LOGDIR=`pwd`; export OVS_LOGDIR
f973f2af 95OVS_DBDIR=`pwd`; export OVS_DBDIR
37d03458 96OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
0b7140bb 97ON_EXIT([kill `cat test-unixctl.py.pid`])
37d03458 98AT_CAPTURE_FILE([`pwd`/test-unixctl.py.log])
0a68ffd2
EJ
99AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file --pidfile --detach])
100
f4ec6ff4 101AT_CHECK([APPCTL -t test-unixctl.py help], [0], [stdout])
0a68ffd2
EJ
102AT_CHECK([cat stdout], [0], [dnl
103The available commands are:
f4ec6ff4 104 block
0a68ffd2
EJ
105 echo [[arg ...]]
106 echo_error [[arg ...]]
107 exit
108 help
8ba37945 109 log [[arg ...]]
0a68ffd2 110 version
f26ddb5b 111 vlog/list
8ba37945 112 vlog/reopen
f26ddb5b 113 vlog/set spec
0a68ffd2
EJ
114])
115mv stdout expout
f4ec6ff4 116AT_CHECK([PYAPPCTL -t test-unixctl.py help], [0], [expout])
0a68ffd2 117
c9a2d670 118AT_CHECK([ovs-vsctl --version | sed 's/ovs-vsctl/test-unixctl.py/' | head -1 > expout])
f4ec6ff4
EJ
119AT_CHECK([APPCTL -t test-unixctl.py version], [0], [expout])
120AT_CHECK([PYAPPCTL -t test-unixctl.py version], [0], [expout])
0a68ffd2 121
f4ec6ff4 122AT_CHECK([APPCTL -t test-unixctl.py echo robot ninja], [0], [stdout])
0a68ffd2
EJ
123AT_CHECK([cat stdout], [0], [dnl
124[[u'robot', u'ninja']]
125])
126mv stdout expout
f4ec6ff4 127AT_CHECK([PYAPPCTL -t test-unixctl.py echo robot ninja], [0], [expout])
0a68ffd2 128
f4ec6ff4 129AT_CHECK([APPCTL -t test-unixctl.py echo_error robot ninja], [2], [], [stderr])
0a68ffd2
EJ
130AT_CHECK([cat stderr], [0], [dnl
131[[u'robot', u'ninja']]
132ovs-appctl: test-unixctl.py: server returned an error
133])
134sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 135AT_CHECK([PYAPPCTL -t test-unixctl.py echo_error robot ninja], [2], [], [experr])
0a68ffd2 136
f4ec6ff4 137AT_CHECK([APPCTL -t test-unixctl.py echo], [2], [], [stderr])
0a68ffd2
EJ
138AT_CHECK([cat stderr], [0], [dnl
139"echo" command requires at least 1 arguments
140ovs-appctl: test-unixctl.py: server returned an error
141])
142sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 143AT_CHECK([PYAPPCTL -t test-unixctl.py echo], [2], [], [experr])
0a68ffd2 144
f4ec6ff4 145AT_CHECK([APPCTL -t test-unixctl.py echo robot ninja pirates], [2], [], [stderr])
0a68ffd2
EJ
146AT_CHECK([cat stderr], [0], [dnl
147"echo" command takes at most 2 arguments
148ovs-appctl: test-unixctl.py: server returned an error
149])
150sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 151AT_CHECK([PYAPPCTL -t test-unixctl.py echo robot ninja pirates], [2], [], [experr])
0a68ffd2 152
f4ec6ff4 153AT_CHECK([APPCTL -t test-unixctl.py bogus], [2], [], [stderr])
0a68ffd2
EJ
154AT_CHECK([cat stderr], [0], [dnl
155"bogus" is not a valid command
156ovs-appctl: test-unixctl.py: server returned an error
157])
158sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 159AT_CHECK([PYAPPCTL -t test-unixctl.py bogus], [2], [], [experr])
0a68ffd2 160
f4ec6ff4 161AT_CHECK([APPCTL -t test-unixctl.py exit])
0a68ffd2
EJ
162AT_CLEANUP
163
164
165AT_SETUP([unixctl server errors - Python])
166AT_SKIP_IF([test $HAVE_PYTHON = no])
37d03458 167AT_CHECK($PYTHON $srcdir/test-unixctl.py --unixctl "`pwd`"/bogus/path, [1], [], [ignore])
0a68ffd2 168AT_CLEANUP