vlog: Take advantage of relaxed "-v" syntax through the tree.
[sliver-openvswitch.git] / tests / vlog.at
1 AT_BANNER([vlog])
2
3 AT_SETUP([vlog - Python])
4 AT_SKIP_IF([test $HAVE_PYTHON = no])
5 AT_CAPTURE_FILE([log_file])
6 AT_CAPTURE_FILE([stderr_log])
7 AT_CHECK([$PYTHON $srcdir/test-vlog.py --log-file log_file \
8 -v dbg module_1:info module_2:warn syslog:off 2>stderr_log])
9
10 AT_CHECK([diff log_file stderr_log])
11
12 AT_CHECK([sed -e 's/.* .* ..:..:..|//' \
13 -e 's/File ".*", line [[0-9]][[0-9]]*,/File <name>, line <number>,/' \
14 stderr_log], [0], [dnl
15 0|module_0|EMER|emergency
16 1|module_0|ERR|error
17 2|module_0|WARN|warning
18 3|module_0|INFO|information
19 4|module_0|DBG|debug
20 5|module_0|EMER|emergency exception
21 Traceback (most recent call last):
22   File <name>, line <number>, in main
23     assert fail
24 AssertionError
25 6|module_0|ERR|error exception
26 Traceback (most recent call last):
27   File <name>, line <number>, in main
28     assert fail
29 AssertionError
30 7|module_0|WARN|warn exception
31 Traceback (most recent call last):
32   File <name>, line <number>, in main
33     assert fail
34 AssertionError
35 8|module_0|INFO|information exception
36 Traceback (most recent call last):
37   File <name>, line <number>, in main
38     assert fail
39 AssertionError
40 9|module_0|DBG|debug exception
41 Traceback (most recent call last):
42   File <name>, line <number>, in main
43     assert fail
44 AssertionError
45 10|module_0|ERR|exception
46 Traceback (most recent call last):
47   File <name>, line <number>, in main
48     assert fail
49 AssertionError
50 11|module_1|EMER|emergency
51 12|module_1|ERR|error
52 13|module_1|WARN|warning
53 14|module_1|INFO|information
54 16|module_1|EMER|emergency exception
55 Traceback (most recent call last):
56   File <name>, line <number>, in main
57     assert fail
58 AssertionError
59 17|module_1|ERR|error exception
60 Traceback (most recent call last):
61   File <name>, line <number>, in main
62     assert fail
63 AssertionError
64 18|module_1|WARN|warn exception
65 Traceback (most recent call last):
66   File <name>, line <number>, in main
67     assert fail
68 AssertionError
69 19|module_1|INFO|information exception
70 Traceback (most recent call last):
71   File <name>, line <number>, in main
72     assert fail
73 AssertionError
74 21|module_1|ERR|exception
75 Traceback (most recent call last):
76   File <name>, line <number>, in main
77     assert fail
78 AssertionError
79 22|module_2|EMER|emergency
80 23|module_2|ERR|error
81 24|module_2|WARN|warning
82 27|module_2|EMER|emergency exception
83 Traceback (most recent call last):
84   File <name>, line <number>, in main
85     assert fail
86 AssertionError
87 28|module_2|ERR|error exception
88 Traceback (most recent call last):
89   File <name>, line <number>, in main
90     assert fail
91 AssertionError
92 29|module_2|WARN|warn exception
93 Traceback (most recent call last):
94   File <name>, line <number>, in main
95     assert fail
96 AssertionError
97 32|module_2|ERR|exception
98 Traceback (most recent call last):
99   File <name>, line <number>, in main
100     assert fail
101 AssertionError
102 ])
103
104 AT_CLEANUP
105
106 AT_SETUP([vlog - vlog/reopen - Python])
107 AT_SKIP_IF([test $HAVE_PYTHON = no])
108 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
109 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
110 OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
111 trap 'kill `cat test-unixctl.py.pid`' 0
112
113 AT_CAPTURE_FILE([log])
114 AT_CAPTURE_FILE([log.old])
115 AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
116
117 AT_CHECK([APPCTL -t test-unixctl.py log message])
118 mv log log.old
119 AT_CHECK([APPCTL -t test-unixctl.py log message2])
120 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
121 AT_CHECK([APPCTL -t test-unixctl.py log message3])
122 AT_CHECK([APPCTL -t test-unixctl.py exit])
123 trap '' 0
124
125 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
126 Entering run loop.
127 message
128 message2
129 ])
130 AT_CHECK([sed 's/.*|//' log], [0], [dnl
131 message3
132 ])
133 AT_CLEANUP
134
135 AT_SETUP([vlog - vlog/reopen without log file - Python])
136 AT_SKIP_IF([test $HAVE_PYTHON = no])
137 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
138 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
139 OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
140 trap 'kill `cat test-unixctl.py.pid`' 0
141
142 AT_CHECK([$PYTHON $srcdir/test-unixctl.py --pidfile --detach])
143
144 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen], [0],
145   [Logging to file not configured
146 ])
147 AT_CLEANUP
148
149 dnl This checks that if vlog/reopen can't reopen the log file,
150 dnl nothing particularly bad (e.g. Python throws an exception and
151 dnl aborts the program) happens.
152 AT_SETUP([vlog - vlog/reopen can't reopen log file - Python])
153 AT_SKIP_IF([test $HAVE_PYTHON = no])
154
155 # Verify that /dev/full is a character device that fails writes.
156 AT_SKIP_IF([test ! -c /dev/full])
157 AT_SKIP_IF([echo > /dev/full])
158
159 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
160 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
161 OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
162 trap 'kill `cat test-unixctl.py.pid`' 0
163
164 AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
165 AT_CHECK([APPCTL -t test-unixctl.py log message])
166 mv log log.old
167 ln -s /dev/full log
168 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
169 AT_CHECK([APPCTL -t test-unixctl.py log message2])
170 rm log
171 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
172 AT_CHECK([APPCTL -t test-unixctl.py log message3])
173 AT_CHECK([APPCTL -t test-unixctl.py exit])
174 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
175 Entering run loop.
176 message
177 ])
178 AT_CHECK([sed 's/.*|//' log], [0], [dnl
179 message3
180 ])
181 AT_CLEANUP
182
183 AT_SETUP([vlog - vlog/set and vlog/list - Python])
184 AT_SKIP_IF([test $HAVE_PYTHON = no])
185 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
186 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
187 OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
188 trap 'kill `cat test-unixctl.py.pid`' 0
189
190 AT_CAPTURE_FILE([log])
191 AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
192
193 AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
194                  console    syslog    file
195                  -------    ------    ------
196 daemon            info       info       info
197 fatal-signal      info       info       info
198 jsonrpc           info       info       info
199 poller            info       info       info
200 reconnect         info       info       info
201 socket_util       info       info       info
202 stream            info       info       info
203 test-unixctl      info       info       info
204 unixctl_server    info       info       info
205 ])
206
207 AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
208 AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
209 AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
210   [no facility, level, or module "nonexistent"
211 ])
212 AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
213                  console    syslog    file
214                  -------    ------    ------
215 daemon            info        err        dbg
216 fatal-signal      info       info        dbg
217 jsonrpc           info       info        dbg
218 poller            info       info        dbg
219 reconnect         info       info        dbg
220 socket_util       info       info        dbg
221 stream            info       info        dbg
222 test-unixctl      info       info        dbg
223 unixctl_server    info       info        dbg
224 ])
225 AT_CLEANUP