Open
Description
Description
When building and running System.Threading.Threads.Tests
with TestReadyToRun=true
, the test run will crash and fail with an error about a missing file.
Reproduction Steps
- Clone the repo and build the
clr
andlibs
subsets. Make sure you specifyTestReadyToRun
, so that some necessary pretest components get built.
git clone https://github.com/dotnet/runtime
cd runtime
./build.sh --subset clr+libs --configuration Release -p:TestReadyToRun=true
- If PR Add ActiveIssue Annotations to Failing TestReadyToRun Tests and Reenable the Executables #96721 has been merged when investigating this issue, then first reenable the test by removing its
ActiveIssue
annotation insrc/libraries/System.Threading.Thread/tests/ThreadTests.cs
:
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer), nameof(PlatformDetection.IsNotMobile), nameof(PlatformDetection.HasHostExecutable))]
[InlineData("STAMain.exe", "GetApartmentStateTest")]
[InlineData("STAMain.exe", "SetApartmentStateTest")]
[InlineData("STAMain.exe", "WaitAllNotSupportedOnSta_Test0")]
[InlineData("STAMain.exe", "WaitAllNotSupportedOnSta_Test1")]
[InlineData("MTAMain.exe", "GetApartmentStateTest")]
[InlineData("MTAMain.exe", "SetApartmentStateTest")]
[InlineData("DefaultApartmentStateMain.exe", "GetApartmentStateTest")]
[InlineData("DefaultApartmentStateMain.exe", "SetApartmentStateTest")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34543", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
// Comment this one out --> [ActiveIssue("https://github.com/dotnet/runtime/issues/96722", typeof(PlatformDetection), nameof(PlatformDetection.IsReadyToRunCompiled))]
public static void ApartmentState_AttributePresent(string appName, string testName)
{
var psi = new ProcessStartInfo();
psi.FileName = DummyClass.HostRunnerTest;
psi.Arguments = $"{appName} {testName}";
using (Process p = Process.Start(psi))
{
p.WaitForExit();
Assert.Equal(PlatformDetection.IsWindows ? 0 : 2, p.ExitCode);
}
}
- Build and run the test
cd src/libraries/System.Threading.Thread/tests
/path/to/runtime/dotnet.sh build -c Release -t:Test -p:TestReadyToRun=true
Expected behavior
All tests pass, except the skipped ones.
Actual behavior
Test fails with the following error, making the whole run fail:
========================= Begin custom configuration settings ==============================
export __TestArchitecture=x64
export __IsXUnitLogCheckerSupported=1
========================== End custom configuration settings ===============================
----- start Tue Jan 9 01:54:11 PM PST 2024 =============== To repro directly: =====================================================
pushd /path/to/runtime/artifacts/bin/System.Threading.Thread.Tests/Release/net9.0/publish
chmod +rwx System.Threading.Thread.Tests ^&^& ./System.Threading.Thread.Tests -notrait category=OuterLoop -notrait category=failing -xml testResults.xml
popd
===========================================================================================================
/path/to/runtime/artifacts/bin/System.Threading.Thread.Tests/Release/net9.0/publish /path/to/runtime/src/libraries/System.Threading.Thread/tests
Running assembly:System.Threading.Thread.Tests, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[SKIP] System.Threading.Threads.Tests.ThreadTests.DefaultPrincipalPolicyTest
[SKIP] System.Threading.Threads.Tests.ThreadTests.ApartmentState_NoAttributePresent_DefaultState_Nano
[SKIP] System.Threading.Threads.Tests.ThreadTests.ApartmentStateTest_ChangeBeforeThreadStarted_Windows_Nano_Server
[FAIL] System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(appName: "STAMain.exe", testName: "GetApartmentStateTest")
System.InvalidOperationException : Cannot start process because a file name has not been provided.
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Threading.Threads.Tests.ThreadTests.ApartmentState_AttributePresent(String appName, String testName) in /path/to/runtime/src/libraries/System.Threading.Thread/tests/ThreadTests.cs:line 178
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
Regression?
No
Known Workarounds
Keep the test disabled so that the other tests in the run can be executed unaffected.