win32-eventlog 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGES +234 -226
- data/MANIFEST +19 -16
- data/README +78 -68
- data/Rakefile +6 -1
- data/doc/tutorial.txt +136 -136
- data/examples/example_notify.rb +23 -23
- data/examples/example_read.rb +83 -83
- data/examples/example_write.rb +64 -64
- data/lib/win32/eventlog.rb +1146 -1157
- data/lib/win32/mc.rb +120 -118
- data/lib/win32/windows/constants.rb +56 -0
- data/lib/win32/windows/functions.rb +51 -0
- data/lib/win32/windows/helper.rb +13 -0
- data/lib/win32/windows/structs.rb +30 -0
- data/misc/install_msg.rb +46 -46
- data/misc/rubymsg.mc +35 -35
- data/test/foo.mc +24 -24
- data/test/test_eventlog.rb +310 -319
- data/test/test_mc.rb +64 -67
- data/win32-eventlog.gemspec +30 -29
- metadata +90 -90
data/misc/rubymsg.mc
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
MessageId=0x1
|
2
|
-
SymbolicName=CATEGORY_ERROR
|
3
|
-
Language=English
|
4
|
-
Error
|
5
|
-
.
|
6
|
-
|
7
|
-
MessageId=0x2
|
8
|
-
SymbolicName=CATEGORY_WARNING
|
9
|
-
Language=English
|
10
|
-
Warning
|
11
|
-
.
|
12
|
-
|
13
|
-
MessageId=0x3
|
14
|
-
SymbolicName=CATEGORY_OUTPUT
|
15
|
-
Language=English
|
16
|
-
Output
|
17
|
-
.
|
18
|
-
|
19
|
-
MessageId=0x4
|
20
|
-
SymbolicName=RUBY_ERROR
|
21
|
-
Language=English
|
22
|
-
Ruby error: %1
|
23
|
-
.
|
24
|
-
|
25
|
-
MessageId=0x5
|
26
|
-
SymbolicName=RUBY_WARNING
|
27
|
-
Language=English
|
28
|
-
Ruby warning: %1
|
29
|
-
.
|
30
|
-
|
31
|
-
MessageId=0x6
|
32
|
-
SymbolicName=RUBY_OUTPUT
|
33
|
-
Language=English
|
34
|
-
Ruby output: %1
|
35
|
-
.
|
1
|
+
MessageId=0x1
|
2
|
+
SymbolicName=CATEGORY_ERROR
|
3
|
+
Language=English
|
4
|
+
Error
|
5
|
+
.
|
6
|
+
|
7
|
+
MessageId=0x2
|
8
|
+
SymbolicName=CATEGORY_WARNING
|
9
|
+
Language=English
|
10
|
+
Warning
|
11
|
+
.
|
12
|
+
|
13
|
+
MessageId=0x3
|
14
|
+
SymbolicName=CATEGORY_OUTPUT
|
15
|
+
Language=English
|
16
|
+
Output
|
17
|
+
.
|
18
|
+
|
19
|
+
MessageId=0x4
|
20
|
+
SymbolicName=RUBY_ERROR
|
21
|
+
Language=English
|
22
|
+
Ruby error: %1
|
23
|
+
.
|
24
|
+
|
25
|
+
MessageId=0x5
|
26
|
+
SymbolicName=RUBY_WARNING
|
27
|
+
Language=English
|
28
|
+
Ruby warning: %1
|
29
|
+
.
|
30
|
+
|
31
|
+
MessageId=0x6
|
32
|
+
SymbolicName=RUBY_OUTPUT
|
33
|
+
Language=English
|
34
|
+
Ruby output: %1
|
35
|
+
.
|
data/test/foo.mc
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
MessageId=0x1
|
2
|
-
SymbolicName=CATEGORY_HELLO
|
3
|
-
Language=English
|
4
|
-
Foohello
|
5
|
-
.
|
6
|
-
|
7
|
-
MessageId=0x2
|
8
|
-
SymbolicName=CATEGORY_WORLD
|
9
|
-
Language=English
|
10
|
-
Fooworld
|
11
|
-
.
|
12
|
-
|
13
|
-
MessageId=0x3
|
14
|
-
SymbolicName=FOO_ERROR
|
15
|
-
Language=English
|
16
|
-
Foo error: %1
|
17
|
-
.
|
18
|
-
|
19
|
-
MessageId=0x4
|
20
|
-
SymbolicName=FOO_WARN
|
21
|
-
Language=English
|
22
|
-
Foo warning: %1
|
23
|
-
.
|
24
|
-
|
1
|
+
MessageId=0x1
|
2
|
+
SymbolicName=CATEGORY_HELLO
|
3
|
+
Language=English
|
4
|
+
Foohello
|
5
|
+
.
|
6
|
+
|
7
|
+
MessageId=0x2
|
8
|
+
SymbolicName=CATEGORY_WORLD
|
9
|
+
Language=English
|
10
|
+
Fooworld
|
11
|
+
.
|
12
|
+
|
13
|
+
MessageId=0x3
|
14
|
+
SymbolicName=FOO_ERROR
|
15
|
+
Language=English
|
16
|
+
Foo error: %1
|
17
|
+
.
|
18
|
+
|
19
|
+
MessageId=0x4
|
20
|
+
SymbolicName=FOO_WARN
|
21
|
+
Language=English
|
22
|
+
Foo warning: %1
|
23
|
+
.
|
24
|
+
|
data/test/test_eventlog.rb
CHANGED
@@ -1,319 +1,310 @@
|
|
1
|
-
##############################################################################
|
2
|
-
# test_eventlog.rb
|
3
|
-
#
|
4
|
-
# Test case for the win32-eventlog package. You should run this test case
|
5
|
-
# via the 'rake test' Rakefile task. This test will take a minute or two
|
6
|
-
# to complete.
|
7
|
-
#############################################################################
|
8
|
-
require '
|
9
|
-
|
10
|
-
|
11
|
-
require '
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
assert_nothing_raised{ @log.read{ break } }
|
164
|
-
end
|
165
|
-
|
166
|
-
test "instance method read accepts
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
assert_nothing_raised{ @log.read
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
end
|
178
|
-
|
179
|
-
test
|
180
|
-
|
181
|
-
|
182
|
-
assert_nothing_raised{
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
test "
|
234
|
-
|
235
|
-
end
|
236
|
-
|
237
|
-
test "
|
238
|
-
assert_respond_to(@log, :
|
239
|
-
assert_nothing_raised{ @log.
|
240
|
-
end
|
241
|
-
|
242
|
-
test "
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
test "
|
258
|
-
assert_respond_to(@log, :
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
#
|
264
|
-
#
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
#
|
272
|
-
#
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
assert_not_nil(EventLog::
|
294
|
-
assert_not_nil(EventLog::
|
295
|
-
assert_not_nil(EventLog::
|
296
|
-
assert_not_nil(EventLog::
|
297
|
-
end
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
@logfile = nil
|
312
|
-
@records = nil
|
313
|
-
@last = nil
|
314
|
-
end
|
315
|
-
|
316
|
-
def self.shutdown
|
317
|
-
@@hostname = nil
|
318
|
-
end
|
319
|
-
end
|
1
|
+
##############################################################################
|
2
|
+
# test_eventlog.rb
|
3
|
+
#
|
4
|
+
# Test case for the win32-eventlog package. You should run this test case
|
5
|
+
# via the 'rake test' Rakefile task. This test will take a minute or two
|
6
|
+
# to complete.
|
7
|
+
#############################################################################
|
8
|
+
require 'test-unit'
|
9
|
+
require 'win32/eventlog'
|
10
|
+
require 'socket'
|
11
|
+
require 'tmpdir'
|
12
|
+
include Win32
|
13
|
+
|
14
|
+
class TC_Win32_EventLog < Test::Unit::TestCase
|
15
|
+
def self.startup
|
16
|
+
@@hostname = Socket.gethostname
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@log = EventLog.new('Application')
|
21
|
+
@logfile = 'temp.evt'
|
22
|
+
@bakfile = File.join(Dir.tmpdir, 'test_event_log.bak')
|
23
|
+
@records = []
|
24
|
+
@last = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
test "version constant is set to expected value" do
|
28
|
+
assert_equal('0.6.0', EventLog::VERSION)
|
29
|
+
end
|
30
|
+
|
31
|
+
test "constructor basic functionality" do
|
32
|
+
assert_respond_to(EventLog, :new)
|
33
|
+
assert_nothing_raised{ EventLog.new }
|
34
|
+
end
|
35
|
+
|
36
|
+
test "constructor accepts a block" do
|
37
|
+
assert_nothing_raised{ EventLog.new{ |log| } }
|
38
|
+
end
|
39
|
+
|
40
|
+
test "constructor accepts a log type" do
|
41
|
+
assert_nothing_raised{ EventLog.new('System') }
|
42
|
+
end
|
43
|
+
|
44
|
+
test "constructor accepts a host name" do
|
45
|
+
assert_nothing_raised{ EventLog.new('System', @@hostname) }
|
46
|
+
end
|
47
|
+
|
48
|
+
#test "open is a singleton alias for new" do
|
49
|
+
# assert_alias_method(EventLog, :new, :open)
|
50
|
+
#end
|
51
|
+
|
52
|
+
test "constructor accepts a maximum of three arguments" do
|
53
|
+
assert_raises(ArgumentError){ EventLog.new('System', @@hostname, 'foo', 'bar') }
|
54
|
+
end
|
55
|
+
|
56
|
+
test "arguments to constructor must be strings" do
|
57
|
+
assert_raises(TypeError){ EventLog.open(1) }
|
58
|
+
assert_raises(TypeError){ EventLog.open('System', 1) }
|
59
|
+
end
|
60
|
+
|
61
|
+
test "source accessor method basic functionality" do
|
62
|
+
@log = EventLog.new('Application', @@hostname)
|
63
|
+
assert_respond_to(@log, :source)
|
64
|
+
assert_equal('Application', @log.source)
|
65
|
+
end
|
66
|
+
|
67
|
+
test "server accessor method basic functionality" do
|
68
|
+
@log = EventLog.new('Application', @@hostname)
|
69
|
+
assert_respond_to(@log, :server)
|
70
|
+
assert_equal(@@hostname, @log.server)
|
71
|
+
end
|
72
|
+
|
73
|
+
test "backup basic functionality" do
|
74
|
+
assert_respond_to(@log, :backup)
|
75
|
+
assert_nothing_raised{ @log.backup(@bakfile) }
|
76
|
+
end
|
77
|
+
|
78
|
+
test "backup works as expected" do
|
79
|
+
assert_nothing_raised{ @log.backup(@bakfile) }
|
80
|
+
assert(File.exists?(@bakfile))
|
81
|
+
end
|
82
|
+
|
83
|
+
test "backup method fails if backup file already exists" do
|
84
|
+
assert_nothing_raised{ @log.backup(@bakfile) }
|
85
|
+
assert_raise(SystemCallError){ @log.backup(@bakfile) }
|
86
|
+
end
|
87
|
+
|
88
|
+
test "open_backup basic functionality" do
|
89
|
+
assert_respond_to(EventLog, :open_backup)
|
90
|
+
end
|
91
|
+
|
92
|
+
test "open_backup works as expected" do
|
93
|
+
EventLog.new('Application', @@hostname){ |log| log.backup(@bakfile) }
|
94
|
+
assert_nothing_raised{ @log = EventLog.open_backup(@bakfile) }
|
95
|
+
assert_kind_of(EventLog, @log)
|
96
|
+
end
|
97
|
+
|
98
|
+
test "it is possible to read and close the backup log file" do
|
99
|
+
EventLog.new('Application', @@hostname){ |log| log.backup(@bakfile) }
|
100
|
+
@log = EventLog.open_backup(@bakfile)
|
101
|
+
assert_nothing_raised{ @log.read{ break } }
|
102
|
+
assert_nothing_raised{ @log.close }
|
103
|
+
end
|
104
|
+
|
105
|
+
# Ensure that an Array is returned in non-block form and that none of the
|
106
|
+
# descriptions are nil.
|
107
|
+
#
|
108
|
+
# The test for descriptions was added as a result of ruby-talk:116528.
|
109
|
+
# Thanks go to Joey Gibson for the spot. The test for unique record
|
110
|
+
# numbers was added to ensure no dups.
|
111
|
+
#
|
112
|
+
test "singleton read method works as expected" do
|
113
|
+
assert_nothing_raised{ @array = EventLog.read }
|
114
|
+
assert_kind_of(Array, @array)
|
115
|
+
|
116
|
+
record_numbers = []
|
117
|
+
@array.each{ |log|
|
118
|
+
assert_not_nil(log.description)
|
119
|
+
assert_equal(false, record_numbers.include?(log.record_number))
|
120
|
+
record_numbers << log.record_number
|
121
|
+
}
|
122
|
+
end
|
123
|
+
|
124
|
+
# I've added explicit breaks because an event log could be rather large.
|
125
|
+
#
|
126
|
+
test "singleton read method does not require any arguments" do
|
127
|
+
assert_nothing_raised{ EventLog.read{ break } }
|
128
|
+
end
|
129
|
+
|
130
|
+
test "singleton read method accepts a log type" do
|
131
|
+
assert_nothing_raised{ EventLog.read("Application"){ break } }
|
132
|
+
end
|
133
|
+
|
134
|
+
test "singleton read method accepts a server argument" do
|
135
|
+
assert_nothing_raised{ EventLog.read("Application", nil){ break } }
|
136
|
+
end
|
137
|
+
|
138
|
+
test "singleton read method accepts a flags argument" do
|
139
|
+
assert_nothing_raised{ EventLog.read("Application", nil, nil){ break } }
|
140
|
+
end
|
141
|
+
|
142
|
+
test "singleton read method accepts an offset argument" do
|
143
|
+
assert_nothing_raised{ EventLog.read("Application", nil, nil, 10){ break } }
|
144
|
+
end
|
145
|
+
|
146
|
+
test "singleton read method accepts a maximum of four arguments" do
|
147
|
+
assert_raises(ArgumentError){
|
148
|
+
EventLog.read("Application", nil, nil, nil, nil){}
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
152
|
+
test "instance method read basic functionality" do
|
153
|
+
assert_respond_to(@log, :read)
|
154
|
+
assert_nothing_raised{ @log.read{ break } }
|
155
|
+
end
|
156
|
+
|
157
|
+
test "instance method read accepts flags" do
|
158
|
+
flags = EventLog::FORWARDS_READ | EventLog::SEQUENTIAL_READ
|
159
|
+
assert_nothing_raised{ @log.read(flags){ break } }
|
160
|
+
end
|
161
|
+
|
162
|
+
test "instance method read accepts an offset" do
|
163
|
+
assert_nothing_raised{ @log.read(nil, 500){ break } }
|
164
|
+
end
|
165
|
+
|
166
|
+
test "instance method read accepts a maximum of two arguments" do
|
167
|
+
assert_raises(ArgumentError){ @log.read(nil, 500, 'foo') }
|
168
|
+
end
|
169
|
+
|
170
|
+
test "seek_read flag plus forwards_read flag works as expected" do
|
171
|
+
flags = EventLog::SEEK_READ | EventLog::FORWARDS_READ
|
172
|
+
assert_nothing_raised{ @last = @log.read[-10].record_number }
|
173
|
+
assert_nothing_raised{
|
174
|
+
@records = EventLog.read(nil, nil, flags, @last)
|
175
|
+
}
|
176
|
+
assert_equal(10, @records.length)
|
177
|
+
end
|
178
|
+
|
179
|
+
# This test could fail, since a record number + 10 may not actually exist.
|
180
|
+
test "seek_read flag plus backwards_read flag works as expected" do
|
181
|
+
flags = EventLog::SEEK_READ | EventLog::BACKWARDS_READ
|
182
|
+
assert_nothing_raised{ @last = @log.oldest_record_number + 10 }
|
183
|
+
assert_nothing_raised{ @records = EventLog.read(nil, nil, flags, @last) }
|
184
|
+
assert_equal(11, @records.length)
|
185
|
+
end
|
186
|
+
|
187
|
+
test "the eventlog struct returned by read is frozen" do
|
188
|
+
EventLog.read{ |log| @entry = log; break }
|
189
|
+
assert_true(@entry.frozen?)
|
190
|
+
end
|
191
|
+
|
192
|
+
test "server method basic functionality" do
|
193
|
+
assert_respond_to(@log, :server)
|
194
|
+
assert_nothing_raised{ @log.server }
|
195
|
+
assert_nil(@log.server)
|
196
|
+
end
|
197
|
+
|
198
|
+
test "server method is readonly" do
|
199
|
+
assert_raises(NoMethodError){ @log.server = 'foo' }
|
200
|
+
end
|
201
|
+
|
202
|
+
test "source method basic functionality" do
|
203
|
+
assert_respond_to(@log, :source)
|
204
|
+
assert_nothing_raised{ @log.source }
|
205
|
+
assert_kind_of(String, @log.source)
|
206
|
+
end
|
207
|
+
|
208
|
+
test "source method is readonly" do
|
209
|
+
assert_raises(NoMethodError){ @log.source = 'foo' }
|
210
|
+
end
|
211
|
+
|
212
|
+
test "file method basic functionality" do
|
213
|
+
assert_respond_to(@log, :file)
|
214
|
+
assert_nothing_raised{ @log.file }
|
215
|
+
assert_nil(@log.file)
|
216
|
+
end
|
217
|
+
|
218
|
+
test "file method is readonly" do
|
219
|
+
assert_raises(NoMethodError){ @log.file = 'foo' }
|
220
|
+
end
|
221
|
+
|
222
|
+
# Since I don't want to actually clear anyone's event log, I can't really
|
223
|
+
# verify that it works.
|
224
|
+
test "clear method basic functionality" do
|
225
|
+
assert_respond_to(@log, :clear)
|
226
|
+
end
|
227
|
+
|
228
|
+
test "full method basic functionality" do
|
229
|
+
assert_respond_to(@log, :full?)
|
230
|
+
assert_nothing_raised{ @log.full? }
|
231
|
+
end
|
232
|
+
|
233
|
+
test "full method returns a boolean" do
|
234
|
+
assert_boolean(@log.full?)
|
235
|
+
end
|
236
|
+
|
237
|
+
test "close method basic functionality" do
|
238
|
+
assert_respond_to(@log, :close)
|
239
|
+
assert_nothing_raised{ @log.close }
|
240
|
+
end
|
241
|
+
|
242
|
+
test "oldest_record_number basic functionality" do
|
243
|
+
assert_respond_to(@log, :oldest_record_number)
|
244
|
+
assert_nothing_raised{ @log.oldest_record_number }
|
245
|
+
assert_kind_of(Fixnum, @log.oldest_record_number)
|
246
|
+
end
|
247
|
+
|
248
|
+
test "total_records basic functionality" do
|
249
|
+
assert_respond_to(@log, :total_records)
|
250
|
+
assert_nothing_raised{ @log.total_records }
|
251
|
+
assert_kind_of(Fixnum, @log.total_records)
|
252
|
+
end
|
253
|
+
|
254
|
+
# We can't test that this method actually executes properly since it goes
|
255
|
+
# into an endless loop.
|
256
|
+
#
|
257
|
+
test "tail basic functionality" do
|
258
|
+
assert_respond_to(@log, :tail)
|
259
|
+
assert_raises(ArgumentError){ @log.tail }
|
260
|
+
end
|
261
|
+
|
262
|
+
# We can't test that this method actually executes properly since it goes
|
263
|
+
# into an endless loop.
|
264
|
+
#
|
265
|
+
test "notify_change basic functionality" do
|
266
|
+
assert_respond_to(@log, :notify_change)
|
267
|
+
assert_raises(ArgumentError){ @log.notify_change }
|
268
|
+
end
|
269
|
+
|
270
|
+
# I can't really do more in depth testing for this method since there
|
271
|
+
# isn't an event source I can reliably and safely write to.
|
272
|
+
#
|
273
|
+
test "report_event basic functionality" do
|
274
|
+
assert_respond_to(@log, :report_event)
|
275
|
+
assert_raises(ArgumentError){ @log.report_event }
|
276
|
+
end
|
277
|
+
|
278
|
+
test "write is an alias for report_event" do
|
279
|
+
assert_respond_to(@log, :write)
|
280
|
+
assert_alias_method(@log, :write, :report_event)
|
281
|
+
end
|
282
|
+
|
283
|
+
test "read event constants" do
|
284
|
+
assert_not_nil(EventLog::FORWARDS_READ)
|
285
|
+
assert_not_nil(EventLog::BACKWARDS_READ)
|
286
|
+
assert_not_nil(EventLog::SEEK_READ)
|
287
|
+
assert_not_nil(EventLog::SEQUENTIAL_READ)
|
288
|
+
end
|
289
|
+
|
290
|
+
test "event type constants" do
|
291
|
+
assert_not_nil(EventLog::SUCCESS)
|
292
|
+
assert_not_nil(EventLog::ERROR_TYPE)
|
293
|
+
assert_not_nil(EventLog::WARN_TYPE)
|
294
|
+
assert_not_nil(EventLog::INFO_TYPE)
|
295
|
+
assert_not_nil(EventLog::AUDIT_SUCCESS)
|
296
|
+
assert_not_nil(EventLog::AUDIT_FAILURE)
|
297
|
+
end
|
298
|
+
|
299
|
+
def teardown
|
300
|
+
@log.close rescue nil
|
301
|
+
File.delete(@bakfile) if File.exists?(@bakfile)
|
302
|
+
@logfile = nil
|
303
|
+
@records = nil
|
304
|
+
@last = nil
|
305
|
+
end
|
306
|
+
|
307
|
+
def self.shutdown
|
308
|
+
@@hostname = nil
|
309
|
+
end
|
310
|
+
end
|