Skip to content

Conversation

@carlossanlop
Copy link
Contributor

@carlossanlop carlossanlop commented Jul 27, 2023

Fixes #88224

I ran this in an elevated console and it failed with the reported error:

===========================================================================================================
    Discovering: System.Diagnostics.EventLog.Tests (method display = ClassAndMethod, method display options = None)
    Discovered:  System.Diagnostics.EventLog.Tests (found 123 of 125 test cases)
    Starting:    System.Diagnostics.EventLog.Tests (parallel test collections = on, max threads = 16)
      System.Diagnostics.Tests.EventLogMessagesTests.CanReadAndWriteMessages [FAIL]
        Assert.Equal() Failure
                                         � (pos 42)
        Expected: ···1b-86c3-93c25c528d55
        Actual:   ···1b-86c3-93c25c528d55\0
                                         � (pos 42)
        Stack Trace:
          C:\Users\calope\source\repos\runtime\src\libraries\System.Diagnostics.EventLog\tests\EventLogMessagesTests.cs(80,0): at System.Diagnostics.
  Tests.EventLogMessagesTests.CanReadAndWriteMessages()
             at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
          C:\Users\calope\source\repos\runtime\src\coreclr\System.Private.CoreLib\src\System\Reflection\MethodBaseInvoker.CoreCLR.cs(36,0): at System
  .Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
          C:\Users\calope\source\repos\runtime\src\libraries\System.Private.CoreLib\src\System\Reflection\MethodBaseInvoker.cs(57,0): at System.Refle
  ction.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

It seems the problem is that the buffer may end up with multiple null terminators, so I adjusted the code to make sure we remove them all.

@carlossanlop carlossanlop added NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) NO-REVIEW Experimental/testing PR, do NOT review it area-System.Diagnostics.EventLog labels Jul 27, 2023
@carlossanlop carlossanlop self-assigned this Jul 27, 2023
@ghost
Copy link

ghost commented Jul 27, 2023

Tagging subscribers to this area: @dotnet/area-system-diagnostics-eventlog
See info in area-owners.md if you want to be subscribed.

Issue Details

We have many EventLog tests that are executed if the process is elevated but we never run them with RemoteExecutor. I am investigating if this could help them pass.

I ran this in an elevated console and it failed with an error stating that it still had a null terminator, even though we removed it:

===========================================================================================================
    Discovering: System.Diagnostics.EventLog.Tests (method display = ClassAndMethod, method display options = None)
    Discovered:  System.Diagnostics.EventLog.Tests (found 123 of 125 test cases)
    Starting:    System.Diagnostics.EventLog.Tests (parallel test collections = on, max threads = 16)
      System.Diagnostics.Tests.EventLogMessagesTests.CanReadAndWriteMessages [FAIL]
        Assert.Equal() Failure
                                         � (pos 42)
        Expected: ···1b-86c3-93c25c528d55
        Actual:   ···1b-86c3-93c25c528d55\0
                                         � (pos 42)
        Stack Trace:
          C:\Users\calope\source\repos\runtime\src\libraries\System.Diagnostics.EventLog\tests\EventLogMessagesTests.cs(80,0): at System.Diagnostics.
  Tests.EventLogMessagesTests.CanReadAndWriteMessages()
             at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
          C:\Users\calope\source\repos\runtime\src\coreclr\System.Private.CoreLib\src\System\Reflection\MethodBaseInvoker.CoreCLR.cs(36,0): at System
  .Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
          C:\Users\calope\source\repos\runtime\src\libraries\System.Private.CoreLib\src\System\Reflection\MethodBaseInvoker.cs(57,0): at System.Refle
  ction.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

It seems the problem is that the buffer may end up with multiple null terminators, so I removed them.

The test now passes locally in an elevated console in Win11 arm64. Now I need to see the CI results.

Author: carlossanlop
Assignees: carlossanlop
Labels:

NO-MERGE, NO-REVIEW, area-System.Diagnostics.EventLog

Milestone: -

@carlossanlop carlossanlop changed the title [Draft] Fix EventLog test CanReadAndWriteMessages and elevate with RemoteExecutor Fix EventLog test CanReadAndWriteMessages and elevate with RemoteExecutor Jul 27, 2023
@carlossanlop carlossanlop removed NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) NO-REVIEW Experimental/testing PR, do NOT review it labels Jul 27, 2023
@carlossanlop carlossanlop marked this pull request as ready for review July 27, 2023 23:13
@carlossanlop carlossanlop changed the title Fix EventLog test CanReadAndWriteMessages and elevate with RemoteExecutor Fix EventLog test CanReadAndWriteMessages Jul 28, 2023
@carlossanlop carlossanlop merged commit fa9ad22 into dotnet:main Jul 31, 2023
@carlossanlop carlossanlop deleted the FixEventLogCanReadAndWriteMessages branch July 31, 2023 16:24
@ghost ghost locked as resolved and limited conversation to collaborators Aug 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failure System.Diagnostics.Tests.EventLogMessagesTests.CanReadAndWriteMessages

2 participants