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