dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.67k stars 4.58k forks source link

[mono] Tests failed on windows: System.Threading.Threads.Tests.ThreadTests #34543

Open MaximLipnin opened 4 years ago

MaximLipnin commented 4 years ago

System.Threading.Threads.Tests.ThreadTests tests are disabled in Mono's CoreFX.issues_windows.rsp file and after enabling some of them still fail locally:

The output:

System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(appName: "STAMain.exe", testName: "GetApartmentStateTest") [FAIL]
Assert.Equal() Failure
Expected: 0
Actual:   2
Stack Trace:
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(181,0): at System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(String appName, String testName)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
Assert.Equal() Failure
System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(appName: "STAMain.exe", testName: "WaitAllNotSupportedOnSta_Test0") [FAIL]
Expected: 0
Actual:   2
Stack Trace:
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(181,0): at System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(String appName, String testName)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(appName: "STAMain.exe", testName: "WaitAllNotSupportedOnSta_Test1") [FAIL]
Assert.Equal() Failure
Expected: 0
Actual:   2
Stack Trace:
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(181,0): at System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(String appName, String testName)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(appName: "MTAMain.exe", testName: "GetApartmentStateTest") [FAIL]
Assert.Equal() Failure
Expected: 0
Actual:   2
Stack Trace:
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(181,0): at System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(String appName, String testName)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(appName: "DefaultApartmentStateMain.exe", testName: "GetApartmentStateTest") [FAIL]
Assert.Equal() Failure
Expected: 0
Actual:   2
Stack Trace:
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(181,0): at System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(String appName, String testName)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
=================================================
System.Threading.Threads.Tests.ThreadTests.GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows(getApartmentState: Func`2 { Method = System.Threading.ApartmentState <ApartmentStateTest_MemberData>b__3_0(System.Threading.Thread), Target = <>c { } }, setApartmentState: Func`3 { Method = Int32 <ApartmentStateTest_MemberData>b__3_1(System.Threading.Thread, System.Threading.ApartmentState), Target = <>c { } }, setType: 0) [FAIL]
System.AggregateException : One or more errors occurred. (Assert.Equal() Failure
Expected: MTA
Actual:   Unknown)
---- Assert.Equal() Failure
Expected: MTA
Actual:   Unknown
Stack Trace:
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(52,0): at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__1()
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(57,0): at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__2()
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(108,0): at System.Threading.Tests.ThreadTestHelpers.RunTestInBackgroundThread(Action test)
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(239,0): at System.Threading.Threads.Tests.ThreadTests.GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows(Func`2 getApartmentState, Func`3 setApartmentState, Int32 setType)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    ----- Inner Stack Trace -----
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(245,0): at System.Threading.Threads.Tests.ThreadTests.<>c__DisplayClass9_0.<GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows>b__0()
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(36,0): at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__0()
System.AggregateException : One or more errors occurred. (Assert.Equal() Failure
System.Threading.Threads.Tests.ThreadTests.GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows(getApartmentState: Func`2 { Method = System.Threading.ApartmentState <ApartmentStateTest_MemberData>b__3_2(System.Threading.Thread), Target = <>c { } }, setApartmentState: Func`3 { Method = Int32 <ApartmentStateTest_MemberData>b__3_3(System.Threading.Thread, System.Threading.ApartmentState), Target = <>c { } }, setType: 1) [FAIL]
Expected: MTA
Actual:   Unknown)
---- Assert.Equal() Failure
Expected: MTA
Actual:   Unknown
Stack Trace:
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(52,0): at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__1()
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(57,0): at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__2()
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(108,0): at System.Threading.Tests.ThreadTestHelpers.RunTestInBackgroundThread(Action test)
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(239,0): at System.Threading.Threads.Tests.ThreadTests.GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows(Func`2 getApartmentState, Func`3 setApartmentState, Int32 setType)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    ----- Inner Stack Trace -----
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(245,0): at System.Threading.Threads.Tests.ThreadTests.<>c__DisplayClass9_0.<GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows>b__0()
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(36,0): at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__0()
System.Threading.Threads.Tests.ThreadTests.GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows(getApartmentState: Func`2 { Method = System.Threading.ApartmentState <ApartmentStateTest_MemberData>b__3_4(System.Threading.Thread), Target = <>c { } }, setApartmentState: Func`3 { Method = Int32 <ApartmentStateTest_MemberData>b__3_5(System.Threading.Thread, System.Threading.ApartmentState), Target = <>c { } }, setType: 2) [FAIL]
System.AggregateException : One or more errors occurred. (Assert.Equal() Failure
Expected: MTA
Actual:   Unknown)
---- Assert.Equal() Failure
Expected: MTA
Actual:   Unknown
Stack Trace:
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(52,0): at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__1()
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(57,0): at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__2()
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(108,0): at System.Threading.Tests.ThreadTestHelpers.RunTestInBackgroundThread(Action test)
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(239,0): at System.Threading.Threads.Tests.ThreadTests.GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows(Func`2 getApartmentState, Func`3 setApartmentState, Int32 setType)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    ----- Inner Stack Trace -----
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(245,0): at System.Threading.Threads.Tests.ThreadTests.<>c__DisplayClass9_0.<GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows>b__0()
    _\src\libraries\Common\tests\System\Threading\ThreadTestHelpers.cs(36,0): at System.Threading.Tests.ThreadTestHelpers.<>c__DisplayClass4_0.<CreateGuardedThread>b__0()
=================================================
System.Threading.Threads.Tests.ThreadTests.ApartmentStateTest_ChangeBeforeThreadStarted_Windows(getApartmentState: Func`2 { Method = System.Threading.ApartmentState <ApartmentStateTest_MemberData>b__3_0(System.Threading.Thread), Target = <>c { } }, setApartmentState: Func`3 { Method = Int32 <ApartmentStateTest_MemberData>b__3_1(System.Threading.Thread, System.Threading.ApartmentState), Target = <>c { } }, setType: 0) [FAIL]
Assert.Equal() Failure
Expected: STA
Actual:   Unknown
Stack Trace:
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(267,0): at System.Threading.Threads.Tests.ThreadTests.ApartmentStateTest_ChangeBeforeThreadStarted_Windows(Func`2 getApartmentState, Func`3 setApartmentState, Int32 setType)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
Assert.Equal() Failure
System.Threading.Threads.Tests.ThreadTests.ApartmentStateTest_ChangeBeforeThreadStarted_Windows(getApartmentState: Func`2 { Method = System.Threading.ApartmentState <ApartmentStateTest_MemberData>b__3_2(System.Threading.Thread), Target = <>c { } }, setApartmentState: Func`3 { Method = Int32 <ApartmentStateTest_MemberData>b__3_3(System.Threading.Thread, System.Threading.ApartmentState), Target = <>c { } }, setType: 1) [FAIL]
Expected: 0
Actual:   2
Stack Trace:
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(266,0): at System.Threading.Threads.Tests.ThreadTests.ApartmentStateTest_ChangeBeforeThreadStarted_Windows(Func`2 getApartmentState, Func`3 setApartmentState, Int32 setType)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
System.Threading.Threads.Tests.ThreadTests.ApartmentStateTest_ChangeBeforeThreadStarted_Windows(getApartmentState: Func`2 { Method = System.Threading.ApartmentState <ApartmentStateTest_MemberData>b__3_4(System.Threading.Thread), Target = <>c { } }, setApartmentState: Func`3 { Method = Int32 <ApartmentStateTest_MemberData>b__3_5(System.Threading.Thread, System.Threading.ApartmentState), Target = <>c { } }, setType: 2) [FAIL]
Assert.Equal() Failure
Expected: 0
Actual:   2
Stack Trace:
    _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs(266,0): at System.Threading.Threads.Tests.ThreadTests.ApartmentStateTest_ChangeBeforeThreadStarted_Windows(Func`2 getApartmentState, Func`3 setApartmentState, Int32 setType)
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(359,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
=================================================
Unhandled Exception:
Xunit.Sdk.EqualException: Assert.Equal() Failure
Expected: WindowsPrincipal { ... }
Actual:   WindowsPrincipal { ... }
    at Xunit.Assert.Equal[IPrincipal](IPrincipal expected, IPrincipal actual, IEqualityComparer`1 comparer) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\EqualityAsserts.cs:line 41
    at Xunit.Assert.Equal[IPrincipal](IPrincipal expected, IPrincipal actual) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\EqualityAsserts.cs:line 24
    at System.Threading.Threads.Tests.ThreadTests.<WindowsPrincipalPolicyTest_Windows_NewThreads>g__CheckPrincipal|39_1(Object principal) in _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs:line 1148
    at System.Threading.Thread.StartCallback() in _\src\mono\netcore\System.Private.CoreLib\src\System\Threading\Thread.Mono.cs:line 287
[ERROR] FATAL UNHANDLED EXCEPTION: Xunit.Sdk.EqualException: Assert.Equal() Failure
Expected: WindowsPrincipal { ... }
Actual:   WindowsPrincipal { ... }
    at Xunit.Assert.Equal[IPrincipal](IPrincipal expected, IPrincipal actual, IEqualityComparer`1 comparer) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\EqualityAsserts.cs:line 41
    at Xunit.Assert.Equal[IPrincipal](IPrincipal expected, IPrincipal actual) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\EqualityAsserts.cs:line 24
    at System.Threading.Threads.Tests.ThreadTests.<WindowsPrincipalPolicyTest_Windows_NewThreads>g__CheckPrincipal|39_1(Object principal) in _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs:line 1148
    at System.Threading.Thread.StartCallback() in _\src\mono\netcore\System.Private.CoreLib\src\System\Threading\Thread.Mono.cs:line 287
=================================================
Unhandled Exception:
Xunit.Sdk.EqualException: Assert.Equal() Failure
Expected: WindowsPrincipal { ... }
Actual:   WindowsPrincipal { ... }
    at Xunit.Assert.Equal[IPrincipal](IPrincipal expected, IPrincipal actual, IEqualityComparer`1 comparer) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\EqualityAsserts.cs:line 41
    at Xunit.Assert.Equal[IPrincipal](IPrincipal expected, IPrincipal actual) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\EqualityAsserts.cs:line 24
    at System.Threading.Threads.Tests.ThreadTests.<NoPrincipalToWindowsPrincipalPolicyTest_Windows_NewThreads>g__CheckPrincipal|41_1(Object principal) in _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs:line 1197
    at System.Threading.Thread.StartCallback() in _\src\mono\netcore\System.Private.CoreLib\src\System\Threading\Thread.Mono.cs:line 287
[ERROR] FATAL UNHANDLED EXCEPTION: Xunit.Sdk.EqualException: Assert.Equal() Failure
Expected: WindowsPrincipal { ... }
Actual:   WindowsPrincipal { ... }
    at Xunit.Assert.Equal[IPrincipal](IPrincipal expected, IPrincipal actual, IEqualityComparer`1 comparer) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\EqualityAsserts.cs:line 41
    at Xunit.Assert.Equal[IPrincipal](IPrincipal expected, IPrincipal actual) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\EqualityAsserts.cs:line 24
    at System.Threading.Threads.Tests.ThreadTests.<NoPrincipalToWindowsPrincipalPolicyTest_Windows_NewThreads>g__CheckPrincipal|41_1(Object principal) in _\src\libraries\System.Threading.Thread\tests\ThreadTests.cs:line 1197
    at System.Threading.Thread.StartCallback() in _\src\mono\netcore\System.Private.CoreLib\src\System\Threading\Thread.Mono.cs:line 287

These tests will be marked with ActiveIssue in #32592.

danmoseley commented 4 years ago

The apartmentstate ones just need disabling against PlatformDetection.SupportsCom or something like that.

The Principal ones seem like they should work. This was fixed recently in ed9fed1f41ddbd12df12e372059147ee72ae73ce but it was in the shared part of corelib. Would need investigation.

SamMonoRT commented 3 years ago

Moving to 7.0.0

SamMonoRT commented 1 year ago

Closing old issues opened when enabling libraries test on the dotnet\runtime repo. CI is currently green with some excluded tests. Please re-open if you feel test is excluded for any reason.

jkotas commented 1 year ago

The tests are still disabled against this issue: https://github.com/dotnet/runtime/blob/2427b67722a40fed059241de920b17d9fe8c82b3/src/libraries/System.Threading.Thread/tests/ThreadTests.cs#L170 . We should not have ActiveIssue annotations pointing to closed issues.

SamMonoRT commented 1 year ago

Moving to 9.0.0