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