Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip the test when dotnet.exe is locked #66196

Merged
merged 4 commits into from
Apr 27, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,14 @@ public void TestUserCredentialsPropertiesOnWindows()
p.StartInfo.UserName = username;
p.StartInfo.PasswordInClearText = password;

hasStarted = p.Start();
try
{
hasStarted = p.Start();
}
catch (Win32Exception ex) when (ex.NativeErrorCode == ERROR_SHARING_VIOLATION)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this covers "The process cannot access the file because it is being used by another process.", Does it cover "Access is denied." as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jozkee good catch! I've extended the current logic that was granting access to the executable file to also provide access to the working directory. I hope it fixes the issue. PTAL

{
throw new SkipTestException($"{p.StartInfo.FileName} has been locked by some other process");
}

if (Interop.OpenProcessToken(p.SafeHandle, 0x8u, out handle))
{
Expand Down Expand Up @@ -1210,6 +1217,7 @@ public static TheoryData<bool> UseShellExecute
private const int ERROR_SUCCESS = 0x0;
private const int ERROR_FILE_NOT_FOUND = 0x2;
private const int ERROR_BAD_EXE_FORMAT = 0xC1;
private const int ERROR_SHARING_VIOLATION = 0x20;

[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34685", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
Expand Down