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