]> git.proxmox.com Git - mirror_ovs.git/blame - tests/unixctl-py.at
odp-execute: Add missing break statement for CLONE action.
[mirror_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])
0f9bd013 5m4_define([PYAPPCTL_PYN], [$1 $srcdir/appctl.py --timeout 20])
f4ec6ff4 6
0f9bd013
RB
7m4_define([UNIXCTL_EXIT_PYN],
8 [AT_SETUP([unixctl ovs-vswitchd exit - $1])
9 AT_SKIP_IF([test $2 = no])
10 AT_KEYWORDS([python unixctl])
11 OVS_VSWITCHD_START
0a68ffd2 12
0f9bd013
RB
13 AT_CHECK([PYAPPCTL_PYN([$3]) -t ovs-vswitchd exit], [0], [])
14 OVS_WAIT_WHILE([test -s ovs-vswitchd.pid])
0a68ffd2 15
0f9bd013
RB
16 AT_CHECK([PYAPPCTL_PYN([$3]) -t ovsdb-server exit], [0], [])
17 OVS_WAIT_WHILE([test -s ovsdb-server.pid])
18 AT_CLEANUP])
0a68ffd2 19
0f9bd013
RB
20UNIXCTL_EXIT_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
21UNIXCTL_EXIT_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
0a68ffd2 22
0f9bd013
RB
23m4_define([UNIXCTL_LIST_COMMANDS_PYN],
24 [AT_SETUP([unixctl ovs-vswitchd list-commands - $1])
25 AT_SKIP_IF([test $2 = no])
26 OVS_VSWITCHD_START
27
28 AT_CHECK([APPCTL list-commands], [0], [stdout])
29 AT_CHECK([head -1 stdout], [0], [dnl
0a68ffd2
EJ
30The available commands are:
31])
0f9bd013
RB
32 mv stdout expout
33 AT_CHECK([PYAPPCTL_PYN([$3]) list-commands], [0], [expout])
0a68ffd2 34
0f9bd013
RB
35 OVS_VSWITCHD_STOP
36 AT_CLEANUP])
0a68ffd2 37
0f9bd013
RB
38UNIXCTL_LIST_COMMANDS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
39UNIXCTL_LIST_COMMANDS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
0a68ffd2 40
0f9bd013
RB
41m4_define([UNIXCTL_ARGS_PYN],
42 [AT_SETUP([unixctl ovs-vswitchd arguments - $1])
43 AT_SKIP_IF([test $2 = no])
44 OVS_VSWITCHD_START
0a68ffd2 45
0f9bd013
RB
46 AT_CHECK([APPCTL bond/hash], [2], [], [stderr])
47 AT_CHECK([head -1 stderr], [0], [dnl
0a68ffd2
EJ
48"bond/hash" command requires at least 1 arguments
49])
0f9bd013
RB
50 sed 's/ovs-appctl/appctl.py/' stderr > experr
51 AT_CHECK([PYAPPCTL_PYN([$3]) bond/hash], [2], [], [experr])
0a68ffd2 52
0f9bd013
RB
53 AT_CHECK([APPCTL bond/hash mac], [2], [], [stderr])
54 AT_CHECK([head -1 stderr], [0], [dnl
0a68ffd2
EJ
55invalid mac
56])
0f9bd013
RB
57 sed 's/ovs-appctl/appctl.py/' stderr > experr
58 AT_CHECK([PYAPPCTL_PYN([$3]) bond/hash mac], [2], [], [experr])
0a68ffd2 59
0f9bd013
RB
60 AT_CHECK([APPCTL bond/hash mac vlan], [2], [], [stderr])
61 AT_CHECK([head -1 stderr], [0], [dnl
0a68ffd2
EJ
62invalid vlan
63])
0f9bd013
RB
64 sed 's/ovs-appctl/appctl.py/' stderr > experr
65 AT_CHECK([PYAPPCTL_PYN([$3]) bond/hash mac vlan], [2], [], [experr])
0a68ffd2 66
0f9bd013
RB
67 AT_CHECK([APPCTL bond/hash mac vlan basis], [2], [], [stderr])
68 AT_CHECK([head -1 stderr], [0], [dnl
0a68ffd2
EJ
69invalid vlan
70])
0f9bd013
RB
71 sed 's/ovs-appctl/appctl.py/' stderr > experr
72 AT_CHECK([PYAPPCTL_PYN([$3]) bond/hash vlan basis], [2], [], [experr])
0a68ffd2 73
0f9bd013
RB
74 AT_CHECK([APPCTL bond/hash mac vlan basis extra], [2], [], [stderr])
75 AT_CHECK([head -1 stderr], [0], [dnl
0a68ffd2
EJ
76"bond/hash" command takes at most 3 arguments
77])
0f9bd013
RB
78 sed 's/ovs-appctl/appctl.py/' stderr > experr
79 AT_CHECK([PYAPPCTL_PYN([$3]) bond/hash mac vlan basis extra], [2], [], [experr])
80
81 OVS_VSWITCHD_STOP
82 AT_CLEANUP])
0a68ffd2 83
0f9bd013
RB
84UNIXCTL_ARGS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
85UNIXCTL_ARGS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
0a68ffd2 86
0f9bd013
RB
87m4_define([UNIXCTL_BAD_TARGET_PYN],
88 [AT_SETUP([unixctl bad target - $1])
89 AT_SKIP_IF([test $2 = no])
0a68ffd2 90
0f9bd013
RB
91 AT_CHECK([PYAPPCTL_PYN([$3]) -t bogus doit], [1], [], [stderr])
92 AT_CHECK_UNQUOTED([tail -1 stderr], [0], [dnl
37d03458 93appctl.py: cannot read pidfile "`pwd`/bogus.pid" (No such file or directory)
0a68ffd2 94])
07170206
PB
95 if test "$IS_WIN32" = "no"; then
96 AT_CHECK([PYAPPCTL_PYN([$3]) -t /bogus/path.pid doit], [1], [], [stderr])
97 AT_CHECK([tail -1 stderr], [0], [dnl
0a68ffd2
EJ
98appctl.py: cannot connect to "/bogus/path.pid" (No such file or directory)
99])
07170206
PB
100 else
101 AT_CHECK([PYAPPCTL_PYN([$3]) -t c:/bogus/path.pid doit], [1], [], [stderr])
102 AT_CHECK([tail -1 stderr], [0], [dnl
103appctl.py: cannot connect to "c:/bogus/path.pid" (No such file or directory)
104])
105 fi
0a68ffd2 106
0f9bd013 107 AT_CLEANUP])
0a68ffd2 108
0f9bd013
RB
109UNIXCTL_BAD_TARGET_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
110UNIXCTL_BAD_TARGET_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
0a68ffd2 111
0f9bd013
RB
112m4_define([UNIXCTL_SERVER_PYN],
113 [AT_SETUP([unixctl server - $1])
114 AT_SKIP_IF([test $2 = no])
115 on_exit 'kill `cat test-unixctl.py.pid`'
116 AT_CAPTURE_FILE([`pwd`/test-unixctl.py.log])
117 AT_CHECK([$3 $srcdir/test-unixctl.py --log-file --pidfile --detach])
118
119 AT_CHECK([APPCTL -t test-unixctl.py help], [0], [stdout])
120 AT_CHECK([cat stdout], [0], [dnl
0a68ffd2 121The available commands are:
f4ec6ff4 122 block
0a68ffd2
EJ
123 echo [[arg ...]]
124 echo_error [[arg ...]]
125 exit
126 help
8ba37945 127 log [[arg ...]]
0a68ffd2 128 version
06380128 129 vlog/close
f26ddb5b 130 vlog/list
8ba37945 131 vlog/reopen
f26ddb5b 132 vlog/set spec
0a68ffd2 133])
0f9bd013
RB
134 mv stdout expout
135 AT_CHECK([PYAPPCTL_PYN([$3]) -t test-unixctl.py help], [0], [expout])
0a68ffd2 136
0f9bd013
RB
137 AT_CHECK([ovs-vsctl --version | sed 's/ovs-vsctl/test-unixctl.py/' | head -1 > expout])
138 AT_CHECK([APPCTL -t test-unixctl.py version], [0], [expout])
139 AT_CHECK([PYAPPCTL_PYN([$3]) -t test-unixctl.py version], [0], [expout])
0a68ffd2 140
0f9bd013
RB
141 AT_CHECK([APPCTL -t test-unixctl.py echo robot ninja], [0], [stdout])
142 AT_CHECK([cat stdout | sed -e "s/u'/'/g"], [0], [dnl
64eb96a9 143[['robot', 'ninja']]
0a68ffd2 144])
0f9bd013
RB
145 mv stdout expout
146 AT_CHECK([PYAPPCTL_PYN([$3]) -t test-unixctl.py echo robot ninja], [0], [expout])
0a68ffd2 147
0f9bd013
RB
148 AT_CHECK([APPCTL -t test-unixctl.py echo_error robot ninja], [2], [], [stderr])
149 AT_CHECK([cat stderr | sed -e "s/u'/'/g"], [0], [dnl
64eb96a9 150[['robot', 'ninja']]
0a68ffd2
EJ
151ovs-appctl: test-unixctl.py: server returned an error
152])
0f9bd013
RB
153 sed 's/ovs-appctl/appctl.py/' stderr > experr
154 AT_CHECK([PYAPPCTL_PYN([$3]) -t test-unixctl.py echo_error robot ninja], [2], [], [experr])
0a68ffd2 155
0f9bd013
RB
156 AT_CHECK([APPCTL -t test-unixctl.py echo], [2], [], [stderr])
157 AT_CHECK([cat stderr], [0], [dnl
0a68ffd2
EJ
158"echo" command requires at least 1 arguments
159ovs-appctl: test-unixctl.py: server returned an error
160])
0f9bd013
RB
161 sed 's/ovs-appctl/appctl.py/' stderr > experr
162 AT_CHECK([PYAPPCTL_PYN([$3]) -t test-unixctl.py echo], [2], [], [experr])
0a68ffd2 163
0f9bd013
RB
164 AT_CHECK([APPCTL -t test-unixctl.py echo robot ninja pirates], [2], [], [stderr])
165 AT_CHECK([cat stderr], [0], [dnl
0a68ffd2
EJ
166"echo" command takes at most 2 arguments
167ovs-appctl: test-unixctl.py: server returned an error
168])
0f9bd013
RB
169 sed 's/ovs-appctl/appctl.py/' stderr > experr
170 AT_CHECK([PYAPPCTL_PYN([$3]) -t test-unixctl.py echo robot ninja pirates], [2], [], [experr])
0a68ffd2 171
0f9bd013
RB
172 AT_CHECK([APPCTL -t test-unixctl.py bogus], [2], [], [stderr])
173 AT_CHECK([cat stderr], [0], [dnl
0a68ffd2
EJ
174"bogus" is not a valid command
175ovs-appctl: test-unixctl.py: server returned an error
176])
0f9bd013
RB
177 sed 's/ovs-appctl/appctl.py/' stderr > experr
178 AT_CHECK([PYAPPCTL_PYN([$3]) -t test-unixctl.py bogus], [2], [], [experr])
179
180 AT_CHECK([APPCTL -t test-unixctl.py exit])
181 AT_CLEANUP])
0a68ffd2 182
0f9bd013
RB
183UNIXCTL_SERVER_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
184UNIXCTL_SERVER_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
0a68ffd2 185
0f9bd013
RB
186m4_define([UNIXCTL_SERVER_ERRORS_PYN],
187 [AT_SETUP([unixctl server errors - $1])
188 AT_SKIP_IF([test $2 = no])
189 AT_CHECK($3 $srcdir/test-unixctl.py --unixctl "`pwd`"/bogus/path, [1], [], [ignore])
190 AT_CLEANUP])
0a68ffd2 191
0f9bd013
RB
192UNIXCTL_SERVER_ERRORS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
193UNIXCTL_SERVER_ERRORS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])