]> git.proxmox.com Git - ovs.git/blame - tests/unixctl-py.at
pktbuf: Move from 'ofproto' to 'lib'.
[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
91a11f5b 17AT_SETUP([unixctl ovs-vswitchd list-commands - Python])
0a68ffd2
EJ
18AT_SKIP_IF([test $HAVE_PYTHON = no])
19OVS_VSWITCHD_START
20
91a11f5b 21AT_CHECK([APPCTL list-commands], [0], [stdout])
0a68ffd2
EJ
22AT_CHECK([head -1 stdout], [0], [dnl
23The available commands are:
24])
25mv stdout expout
91a11f5b 26AT_CHECK([PYAPPCTL list-commands], [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])
0a68ffd2
EJ
75AT_SKIP_IF([test $HAVE_PYTHON = no])
76
f4ec6ff4 77AT_CHECK([PYAPPCTL -t bogus doit], [1], [], [stderr])
0a68ffd2 78AT_CHECK_UNQUOTED([tail -1 stderr], [0], [dnl
37d03458 79appctl.py: cannot read pidfile "`pwd`/bogus.pid" (No such file or directory)
0a68ffd2
EJ
80])
81
f4ec6ff4 82AT_CHECK([PYAPPCTL -t /bogus/path.pid doit], [1], [], [stderr])
0a68ffd2
EJ
83AT_CHECK([tail -1 stderr], [0], [dnl
84appctl.py: cannot connect to "/bogus/path.pid" (No such file or directory)
85])
86
87AT_CLEANUP
88
89AT_SETUP([unixctl server - Python])
90AT_SKIP_IF([test $HAVE_PYTHON = no])
53eb8cb8 91on_exit 'kill `cat test-unixctl.py.pid`'
37d03458 92AT_CAPTURE_FILE([`pwd`/test-unixctl.py.log])
0a68ffd2
EJ
93AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file --pidfile --detach])
94
f4ec6ff4 95AT_CHECK([APPCTL -t test-unixctl.py help], [0], [stdout])
0a68ffd2
EJ
96AT_CHECK([cat stdout], [0], [dnl
97The available commands are:
f4ec6ff4 98 block
0a68ffd2
EJ
99 echo [[arg ...]]
100 echo_error [[arg ...]]
101 exit
102 help
8ba37945 103 log [[arg ...]]
0a68ffd2 104 version
f26ddb5b 105 vlog/list
8ba37945 106 vlog/reopen
f26ddb5b 107 vlog/set spec
0a68ffd2
EJ
108])
109mv stdout expout
f4ec6ff4 110AT_CHECK([PYAPPCTL -t test-unixctl.py help], [0], [expout])
0a68ffd2 111
c9a2d670 112AT_CHECK([ovs-vsctl --version | sed 's/ovs-vsctl/test-unixctl.py/' | head -1 > expout])
f4ec6ff4
EJ
113AT_CHECK([APPCTL -t test-unixctl.py version], [0], [expout])
114AT_CHECK([PYAPPCTL -t test-unixctl.py version], [0], [expout])
0a68ffd2 115
f4ec6ff4 116AT_CHECK([APPCTL -t test-unixctl.py echo robot ninja], [0], [stdout])
0a68ffd2
EJ
117AT_CHECK([cat stdout], [0], [dnl
118[[u'robot', u'ninja']]
119])
120mv stdout expout
f4ec6ff4 121AT_CHECK([PYAPPCTL -t test-unixctl.py echo robot ninja], [0], [expout])
0a68ffd2 122
f4ec6ff4 123AT_CHECK([APPCTL -t test-unixctl.py echo_error robot ninja], [2], [], [stderr])
0a68ffd2
EJ
124AT_CHECK([cat stderr], [0], [dnl
125[[u'robot', u'ninja']]
126ovs-appctl: test-unixctl.py: server returned an error
127])
128sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 129AT_CHECK([PYAPPCTL -t test-unixctl.py echo_error robot ninja], [2], [], [experr])
0a68ffd2 130
f4ec6ff4 131AT_CHECK([APPCTL -t test-unixctl.py echo], [2], [], [stderr])
0a68ffd2
EJ
132AT_CHECK([cat stderr], [0], [dnl
133"echo" command requires at least 1 arguments
134ovs-appctl: test-unixctl.py: server returned an error
135])
136sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 137AT_CHECK([PYAPPCTL -t test-unixctl.py echo], [2], [], [experr])
0a68ffd2 138
f4ec6ff4 139AT_CHECK([APPCTL -t test-unixctl.py echo robot ninja pirates], [2], [], [stderr])
0a68ffd2
EJ
140AT_CHECK([cat stderr], [0], [dnl
141"echo" command takes at most 2 arguments
142ovs-appctl: test-unixctl.py: server returned an error
143])
144sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 145AT_CHECK([PYAPPCTL -t test-unixctl.py echo robot ninja pirates], [2], [], [experr])
0a68ffd2 146
f4ec6ff4 147AT_CHECK([APPCTL -t test-unixctl.py bogus], [2], [], [stderr])
0a68ffd2
EJ
148AT_CHECK([cat stderr], [0], [dnl
149"bogus" is not a valid command
150ovs-appctl: test-unixctl.py: server returned an error
151])
152sed 's/ovs-appctl/appctl.py/' stderr > experr
f4ec6ff4 153AT_CHECK([PYAPPCTL -t test-unixctl.py bogus], [2], [], [experr])
0a68ffd2 154
f4ec6ff4 155AT_CHECK([APPCTL -t test-unixctl.py exit])
0a68ffd2
EJ
156AT_CLEANUP
157
158
159AT_SETUP([unixctl server errors - Python])
160AT_SKIP_IF([test $HAVE_PYTHON = no])
37d03458 161AT_CHECK($PYTHON $srcdir/test-unixctl.py --unixctl "`pwd`"/bogus/path, [1], [], [ignore])
0a68ffd2 162AT_CLEANUP