[Win32utils-devel] Tweak to win32-eventlog

Daniel Berger djberg96 at gmail.com
Sat Dec 16 23:48:24 EST 2006


Wayne Vucenic wrote:
> Hi Dan,
> 
> It was great seeing you again at RubyConf Denver!

Likewise.

> I gave the win32-eventlog 0.4.2 gem a try on my XP SP 2 system with
> Ruby 1.8.5 (.NET 2.0 runtime installed), and I get two test failures:
> 
> C:\ruby\lib\ruby\gems\1.8\gems\win32-eventlog-0.4.2\test>ruby -v
> ruby 1.8.5 (2006-08-25) [i386-mswin32]
> 
> C:\ruby\lib\ruby\gems\1.8\gems\win32-eventlog-0.4.2\test>ruby tc_eventlog.rb
> 
> Relax - this will take a few moments
> 
> Loaded suite tc_eventlog
> Started
> ...................FF.....
> Finished in 57.969 seconds.
> 
>   1) Failure:
> test_seek_read(TC_EventLog) [tc_eventlog.rb:116]:
> <11> expected but was
> <0>.
> 
>   2) Failure:
> test_seek_read_backwards(TC_EventLog) [tc_eventlog.rb:123]:
> <10> expected but was
> <0>.
> 
> 26 tests, 5180 assertions, 2 failures, 0 errors
> 
> I tried debugging this a little. In the above 2 cases, after the
> ReadEventLog call, GetLastError returns 87 ("The parameter is
> incorrect").
> 
> I played around with calls that failed and calls that succeeded, and
> finally got these two test cases:
> 
> This one works:
>       flags = EventLog::SEQUENTIAL_READ | EventLog::FORWARDS_READ
>       @records = EventLog.read(nil, nil, flags)
> 
> And this one fails:
>       flags = EventLog::SEEK_READ | EventLog::FORWARDS_READ
>       @records = EventLog.read(nil, nil, flags)
> 
> In the actual call to ReadEventLog in eventlog.rb line 460, the only
> difference is the value of flags, which is 5 when it works, and 6 when
> it fails.  I checked the Win32 documentation, and everything seems to
> be fine, and it looks like both calls should succeed.
> 
> I'm perfectly willing to help debug this, if anyone can suggest what I
> should try next.  I guess one next step would be to try making this
> same call from C or C++, but I didn't try that yet.
> 
> I also tried on Win2K SP4, Ruby 1.8.2, and that works fine.
> 
> Thanks,
> 
> Wayne

These tests pass on my system.  These tests are not especially robust. 
If the event log happens to have 10 or fewer event records, they will 
fail, so I'm guessing that's what happened here.  I suppose I should 
check the length first, or just issue a failure message that warns about 
  the possible reasons for a failure.

Regards,

Dan


More information about the win32utils-devel mailing list