Skip to content

Why does coyote find no bugs in this code? #355

Description

@MaximTkachenko

Hi,
I use this sample to play with coyote:

[Microsoft.Coyote.SystematicTesting.Test]
public static async Task ParallelIncrement()
{
    CheckRewritten();
    
    var incrementer = new Incrementer();
    await incrementer.ExecuteAsync(1000);

    Assert.Equal(1000, incrementer.Number);
}

private static void CheckRewritten()
{
    if (!Microsoft.Coyote.Rewriting.RewritingEngine.IsAssemblyRewritten(typeof(Incrementer).Assembly))
    {
        throw new Exception(string.Format("Error: please rewrite this assembly using coyote rewrite {0}",
            typeof(Incrementer).Assembly.Location));
    }
}

public class Incrementer
{
    public int Number { get; private set; }

    public async Task ExecuteAsync(int iterations)
    {
        var tasks = new Task[iterations];

        for (int i = 0; i < iterations; i++)
        {
            tasks[i] = Task.Run(() => Number++);
        }

        await Task.WhenAll(tasks);
    }
}

And I expect that coyote will find a bug since Incrementer increments Number in parallel using Task.Run. I use this script to run this test:

dotnet build -c Release
coyote rewrite bin\Release\net6.0\CoyoteTests.dll
coyote test bin\Release\net6.0\CoyoteTests.dll -m ParallelIncrement -i 50

Why does coyote find no bugs here? Are there some limitations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions