Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Fix some named mutex tests #8625

Merged
merged 1 commit into from
May 20, 2016
Merged

Fix some named mutex tests #8625

merged 1 commit into from
May 20, 2016

Conversation

kouvel
Copy link
Member

@kouvel kouvel commented May 17, 2016

Related to dotnet/coreclr#5030
Related to dotnet/coreclr#3422

@kouvel kouvel changed the title Fix some named mutex tests [WIP] Fix some named mutex tests May 17, 2016
@kouvel
Copy link
Member Author

kouvel commented May 17, 2016

@sergiy-k @stephentoub

Flagged as [WIP] until the dependency change goes into coreclr

AbandonedMutexException ame = Assert.Throws<AbandonedMutexException>(() => WaitHandle.WaitAny(new[] { m }, FailedWaitTimeout));
Assert.Equal(0, ame.MutexIndex);
Assert.Equal(m, ame.Mutex);
}
Copy link
Member

Choose a reason for hiding this comment

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

You might consider refactoring this a bit, e.g. (pseudo-code)

public static IEnumerable<object[]> AbandonExisting_MemberData()
{
    for (int waitType = 0; waitType < 2; waitType++) // 0 == Wait, 1 == WaitAny
    {
        yield return new object[] { null, waitType};
        yield return new object[] { Guid.NewGuid().ToString("N"), waitType };
    }
}

[Theory]
[MemberData(nameof(AbandonExisting_MemberData))]
public void AbandonExisting(string name, int waitType)
{
    using (Mutex m = new Mutex(false, name))
    {
        Task.Factory.StartNew(() => Assert.True(m.WaitOne(FailedWaitTimeout),
            CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default).Wait();
        switch (waitType)
        {
            case 0:
                Assert.Throws<AbandonedMutexException>(() => m.WaitOne(FailedWaitTimeout));
                break;
            case 1:
                AbandonedMutexException ame = Assert.Throws<AbandonedMutexException>(() => WaitHandle.WaitAny(new[] { m }, FailedWaitTimeout));
                Assert.Equal(0, ame.MutexIndex);
                Assert.Equal(m, ame.Mutex);
                break;
        }
    }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@stephentoub
Copy link
Member

Thanks for updating these (and for the Mutex implementation!)

One comment, otherwise LGTM.

We should also look at adding a cross-process test of the naming, similar in concept to https://github.com/dotnet/corefx/blob/master/src/System.Threading/tests/SemaphoreTests.cs#L281-L317 . That could be done as a separate PR if you wanted, though it might be useful here as well to help validate the CoreCLR change.

@kouvel
Copy link
Member Author

kouvel commented May 18, 2016

I'm doing all of the cross-process testing in the PAL tests, and leaving the CoreFX tests to just do basic API-level testing (to cover the layer from the .NET API to the PAL Windows API). I'll take a closer look at the test you pointed to, and will see if I can add something similar.

kouvel added a commit to kouvel/corefx that referenced this pull request May 18, 2016
The tests removed would fail soon after dotnet/coreclr#5030 is merged.

Related to dotnet/coreclr#5030
Related to dotnet#8625
Related to dotnet/coreclr#3422
@kouvel kouvel changed the title [WIP] Fix some named mutex tests Fix some named mutex tests May 18, 2016
@kouvel
Copy link
Member Author

kouvel commented May 19, 2016

Looked at the test, I have tests like that in PAL tests already

@kouvel kouvel force-pushed the NamedMutexFx branch 2 times, most recently from b25405a to e68b52c Compare May 20, 2016 20:30
@kouvel
Copy link
Member Author

kouvel commented May 20, 2016

@dotnet-bot test this please

3 similar comments
@kouvel
Copy link
Member Author

kouvel commented May 20, 2016

@dotnet-bot test this please

@kouvel
Copy link
Member Author

kouvel commented May 20, 2016

@dotnet-bot test this please

@kouvel
Copy link
Member Author

kouvel commented May 20, 2016

@dotnet-bot test this please

Related to dotnet/coreclr#5030
Related to dotnet/coreclr#3422
@kouvel kouvel merged commit 4f782d4 into dotnet:master May 20, 2016
@kouvel kouvel deleted the NamedMutexFx branch May 20, 2016 21:59
@kouvel kouvel restored the NamedMutexFx branch May 21, 2016 02:05
@kouvel kouvel deleted the NamedMutexFx branch May 23, 2016 16:39
kouvel added a commit to kouvel/corefx that referenced this pull request May 23, 2016
This reverts commit 697bd95.

Equivalent to PR dotnet#8625
@karelz karelz added this to the 1.0.0-rtm milestone Dec 3, 2016
@karelz karelz added this to the 1.0.0-rtm milestone Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
The tests removed would fail soon after dotnet/coreclrdotnet/corefx#5030 is merged.

Related to dotnet/coreclrdotnet/corefx#5030
Related to dotnet/corefx#8625
Related to dotnet/coreclrdotnet/corefx#3422


Commit migrated from dotnet/corefx@4c4924d
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
This reverts commit dotnet/corefx@697bd95.

Equivalent to PR dotnet/corefx#8625


Commit migrated from dotnet/corefx@d39cc2f
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants