Граф коммитов

260 Коммитов

Автор SHA1 Сообщение Дата
Chris Lovett 73476e73bb Merged PR 2844: fix some doc bugs
fix some doc bugs.

Related work items: #2818, #3630, #4374, #4779
2020-07-31 01:49:27 +00:00
Chris Lovett 50aa6ea2e7 Merged PR 2814: add windows yaml build pipeline
add windows yaml build pipeline

Related work items: #4824
2020-07-29 00:17:47 +00:00
Pantazis Deligiannis 8b4ab19dbd Merged PR 2802: do not rewrite a pdb file if it does not exist
A pdb file is not always available in assemblies that we are trying to rewrite. Make sure we check that.

Related work items: #4908
2020-07-28 19:57:27 +00:00
Pantazis Deligiannis fe2b526df4 Merged PR 2788: remove the type cache in task rewriting as the result is mutable
Caching the constructed types cannot be generalized, especially for generics. Many types we need to reconstruct under the specific context. This is most likely because the result is not immutable. Instead, we rely on method caching to optimize. We can revisit this in the future.

Related work items: #4891
2020-07-23 22:53:10 +00:00
Pantazis Deligiannis 1fe995a56d Merged PR 2785: make sure rewriting passes run in sequence
Related work items: #4890
2020-07-23 20:07:08 +00:00
Pantazis Deligiannis 890a1fea5e Merged PR 2778: maintain the offset in task transformed instructions 2020-07-23 01:41:27 +00:00
Pantazis Deligiannis 933efd8cec Merged PR 2776: increased version to 1.0.15 2020-07-22 23:34:20 +00:00
Pantazis Deligiannis 5e267914f3 Merged PR 2777: more fixes in WhenAll and WhenAny testing logic
Related work items: #4877
2020-07-22 23:17:23 +00:00
Pantazis Deligiannis 1511c57507 Merged PR 2774: make sure that WhenAll/Any execute asynchronously
The previous implementation was blocking, not asynchronous, so we fix that, as well as exception logic in these APIs. Also adding new tests and fixing previous ones.

Related work items: #4873, #4876
2020-07-22 21:56:22 +00:00
Pantazis Deligiannis a172a9b79b Merged PR 2765: avoid resolving types and methods that we do not rewrite
This is also an optimization as we can exit quickly method rewriting, if we are not going to change its declaring type.
2020-07-22 02:11:15 +00:00
Pantazis Deligiannis dd20e30d5d Merged PR 2763: added list of disallowed assemblies for rewriting
We should not be rewriting some assemblies. Added the basic ones, which are coyote assemblies plus .NET runtime ones.
2020-07-21 19:52:22 +00:00
Pantazis Deligiannis 479ea0f6b4 Merged PR 2762: fix bug in task rewriting
We should not be trying to resolve a method that we are not going to rewrite.
2020-07-21 19:11:36 +00:00
Pantazis Deligiannis 7469774caf Merged PR 2761: fix bug in interface method rewriting
The `MonitorTransform` was not guarding properly for abstract/interface methods. Fixed and added a unit test.
2020-07-21 18:31:21 +00:00
Pantazis Deligiannis bd55929789 Merged PR 2760: remove the need for explicit dependency paths in binary rewriting
We don't need dependency paths, and they are cumbersome to write, lowering usability. We instead mirror the output directory before we do the rewriting (in the case that we are not overwriting).

Related work items: #4495
2020-07-21 17:42:06 +00:00
Pantazis Deligiannis 471c8bf351 Merged PR 2755: updated version to 1.0.14 2020-07-21 02:03:17 +00:00
Pantazis Deligiannis 60cb88a479 Merged PR 2754: fixed a bug in the task testing runtime 2020-07-21 01:44:26 +00:00
Pantazis Deligiannis 58a6b47ed7 Merged PR 2743: expose missing task api 2020-07-20 15:20:23 +00:00
Pantazis Deligiannis 7be548aff1 Merged PR 2732: updated version to 1.0.13 2020-07-17 03:16:18 +00:00
Pantazis Deligiannis 06c76f8841 Merged PR 2719: fixing stack overflow in the task runtime
The following pattern blows up our stack:

```C#
[Test]
public static async Task Test()
{
  while (true)
  {
    await Task.Delay(1);
  }
}
```

This PR fixes this and does some major simplifications in the corresponding logic. Also new tests, and adding tests for rewriting. Also some cleanup (not all relevant for this fix, but I was on it already...).

Related work items: #4796
2020-07-16 23:59:09 +00:00
timbo edea7a7cbe
update documentation for clarity (#40) 2020-07-16 11:44:08 -07:00
Chris Lovett 1447b09490 Merged PR 2679: Switch to ControlledMonitor for intercepting Monitor.* methods
Switch to ControlledMonitor for intercepting Monitor.* methods.

Related work items: #4658
2020-07-14 19:27:11 +00:00
Pantazis Deligiannis 32f3481f15 Merged PR 2677: support task.wait and task.result in binary rewriting
Related work items: #4608, #4686, #4695
2020-07-14 03:59:26 +00:00
Chris Lovett e9a8a22771 Merged PR 2644: add a visitor pattern for code rewriting transforms.
add a visitor pattern for code rewriting transforms.

Related work items: #4442, #4496, #4644
2020-07-09 00:57:41 +00:00
Pantazis Deligiannis 4505028803 Merged PR 2643: enable TCS tests for binary rewriting
Related work items: #4441
2020-07-08 16:05:37 +00:00
Pantazis Deligiannis 43a05e0c46 Merged PR 2633: fix finding test entry point 2020-07-07 22:41:32 +00:00
Chris Lovett 3839740729 Merged PR 2618: Add separate table containing git commit history with the actual commit date...
Add separate table containing git commit history with the actual commit date for each commit.  This table can be used to properly sort the [performance graphs](https://login.microsoftonline.com/microsoft.onmicrosoft.com/oauth2/v2.0/authorize?client_id=c44b4083-3bb0-49c1-b47d-974e53cbdf3c&response_type=code%20id_token&scope=https%3A%2F%2Fmanagement.core.windows.net%2F%2Fuser_impersonation%20openid%20email%20profile&state=OpenIdConnect.AuthenticationProperties%3DCGq94VPZcXSIZrnkKQxWUy9y8oLD9Vf9sEYi7XIub-ZJkcbsFuW3-FqeMyPXnOzjw2MPmbjZfbn_kQR1DiMMQ6x81cD6IsP5JeiGdzqz9JjXefb0TVcEHCjBsz-bD_pf1UpedvO26P0wZyUqb-bbMteFK3RInjCSCJMJfXyccRjkr6awFrmYuNtpT6fl1uRXk0kjZ-BNOx0tHgyEoCBPYpT-WPoAD6G3GwMUVfELUVtluFFZjJUvATNrW4C2-ywQkHDT7blw0lpIqlvbIwL93ym_Tnffjmi07EJDN8awC8uIxnYRP98SXSjNYGQJDgMJAHZk8HigdhEG7Iov2WfUCFWkJPQHNoG1SkMgED3a3943CTbsEThH5EzmJhS6aPjGk7hEtKuLl2uFD5rP9dt27lyxrrby0uLG_Cb9pIfM6EGyzOci9gCRRAH8HCUdac2dvpm5hmoC8QOUUMQ2oJ0pZTvsDuaP532TnPOO22t2FlGTxsOYkyOQ_2A80uEvNGdMqOtkmFjQHntdLsM7k299nQ&response_mode=form_post&nonce=637296686168527124.MDJlZGY2YzctYjkyYS00M2Q5LTgwNGItOGY1MWRiMzljYmM0MTJkOWViMzktOGZjZS00YzhkLWFlNTAtOTY0OGIxYzU3ODM4&redirect_uri=https%3A%2F%2Fms.portal.azure.com%2Fsignin%2Findex%2F&site_id=501430&client-request-id=ef8ae7ce-27d8-40d1-9924-dfbc4dfba697&x-client-SKU=ID_NET45&x-client-ver=5.3.0.0) to show things in commit order (since you can't sort by commit id obviously).
2020-07-06 23:19:36 +00:00
Pantazis Deligiannis 54849eb388 Merged PR 2211: initial prototype for task binary rewriting
**How to run:**
```
..\coyote\bin\netcoreapp3.1\coyote.exe rewrite .\bin\netcoreapp3.1\example.coyote.json
```
Basically the `rewrite` tool option uses `PATH` to declare a JSON configuration file. Add `-d` to get some useful debugging info.

Then just do regular `coyote test` on the rewritten binary.

**JSON:**
```json
{
  "AssembliesPath": "../../bin/netcoreapp3.1",
  "OutputPath": "../../bin/netcoreapp3.1/RewrittenBinaries",
  "Assemblies": [
    "Example.dll"
  ],
  "Dependencies": [
    "Microsoft.Coyote.dll",
    "Microsoft.Coyote.Test.dll",
    "Library.dll",
    "Example.runtimeconfig.json"
  ]
}
```
If `OutputPath` is the same as `AssembliesPath`, then the original assemblies get overwritten.

**Discussion:**

The main components are an `AssemblyRewriter` that takes a JSON configuration file and uses that info to rewrite a set of assemblies (and their dependencies) and put them in some location (or overwrite original ones). That happens via "coyote rewrite". Once that is done, someone can just run "coyote test" and it should work as if someone wrote controlled tasks manually (ofc we need to push corner cases now, some APIs still I need to do, and support for build in mocks like TCS). We also have CI now, our existing run-test.ps1 script first rewrites the xUnit test project, that is only native tasks, and then it runs it (works only for .NET Core 3.1 via xUnit right now for some reason).

The cool thing is that we do not use a custom `Coyote.Task` type anymore. The reason we needed a custom task type was purely to make the manual approach usable. A custom type gives us an awaitable object (because we cannot take control of `GetAwaiter` from native Task, when someone calls await on it), as well as allows you to have it as return type of an async method (for the state machine to be generated). Instead now we focus instrumentation on two aspects: (1) every generated async state machine is replaced with a custom `AsyncStateMachineBuilder` (this is similar to what we had before, but this time we can just replace it automatically as the state machine is already there in the IL , we don't need a custom type to do that for us), and (2) replace some Task methods with custom ones (e.g. `Task.Run` with `ControlledTask.Run`, `Delay`, `Yield`, and importantly `Task.GetAwaiter` with `ControlledTask.GetAwaiter`, to get a callback on an await point). You can think of `ControlledTask` as an "extension" method, not a custom type method (its a purely static class) so its much easier to replace (we don't need to replace `Task` with `Coyote.Task` in every single IL instruction ... as `ControlledTask` APIs just return native tasks, they are just a way to get hooks).

**Known issues:**

- Figure out how to make xUnit recognize rewritten assemblies with .NET Framework (.NET Core works fine).

Related work items: #3911, #4378
2020-07-06 22:48:04 +00:00
Chris Lovett 06e744bf93 Merged PR 2598: Add a test that shows that all possible interleavings in a simple example are actually explored.
Add a test that shows that all possible interleavings in a simple example are actually explored.  Also fix RunAsync so it honors the requested # iterations when running in production tests.
2020-07-06 19:32:49 +00:00
Pantazis Deligiannis 2c6d0d65ca Merged PR 2561: updated version to 1.0.12 2020-07-01 19:47:30 +00:00
Chris Lovett ecc223befd Merged PR 2437: update benchmark dotnet version 0.12.1
update benchmark dotnet version
2020-07-01 19:31:20 +00:00
Pantazis Deligiannis 4c5c5626b0 Merged PR 2560: added missing semaphore APIs
Added support for timeout and cancellation APIs on semaphore.

Note: these are only for the production version, we do not support timeouts/cancellation APIs in systematic testing yet (this is not specific to semaphores, but in general). That are separate low-priority work items #729 and #717.
2020-07-01 02:57:50 +00:00
Pantazis Deligiannis 371bfe5c65 Merged PR 2572: fixed two bugs in the testing scheduler
There were two bugs in the scheduler:

- We checked for external uncontrolled concurrency by checking that the current operation is always the operation calling the check, but that was too aggressive, and can genuinely not be the case because of some internal concurrency in the runtime (e.g. we spawn a task continuation inside the TaskController to perform a `ScheduleNext`, which is racy but benign since the scheduler is thread safe). As long as the operation is not null (which means an uncontrolled task is calling) then we are fine. Fixing this removes the uncontrolled task exception in the CoffeMachineTask sample.

However, fixing the above bug, made a new bug manifest (that was causing the scheduler to hang due to a premature completion of an operation before it was supposed to get completed):

- There was a rare internal race condition that could cause the `ScheduleNextOperation` to return without waiting because the current operation was not having `IsHandlerRunning` set as true yet (that flag would be set later on). I fixed this by simplifying the logic and removing lots of complexity. We dont need a special `IsHandlerRunning` flag anymore, we just use the Operation status making things simpler. Now, returning without waiting in `ScheduleNextOperation` happens only if the operation has completed or canceled, which was the expected behavior anyway.
2020-07-01 02:40:53 +00:00
Pantazis Deligiannis a2cdcbb2c8 Merged PR 2472: updated dotnet sdk
Latest VS is using.
2020-06-22 22:26:01 +00:00
Pantazis Deligiannis 859fd1551b Merged PR 2392: optimize exploration with task delays using scheduler yields
Capability to specify to the scheduler that the program wants to yield the execution of the currently executing operation. This allows strategies to implement different techniques to deal with this. In this PR we implement de-prioritization with PCT. This is very useful for dealing with infinite (polling) task loops and (periodic) timers, but this PR only changes `Task.Yield`, we will deal with timers in a later PR.

In customer code, this reduced the exploration steps to reach cold state in a liveness monitor (and thus the end of a infinite test) from 10-20k down to 1k steps.

Related work items: #4218
2020-06-22 22:09:43 +00:00
Chris Lovett d38418d44a Merged PR 2370: replace Guid opGroupId with EventGroup
Also adds an AwaitableEventGroup with a TaskCompletionSource so these long running operations can also be completed.

Related work items: #4144
2020-06-17 21:15:24 +00:00
Pantazis Deligiannis 08c0b59ff2 Merged PR 2409: minor edit in about doc
We defer any attributions regarding P# (MSR + Imperial College London) to the P# page to keep the about page simpler.
2020-06-15 17:26:36 +00:00
Pantazis Deligiannis af970016fa Merged PR 2391: simplify operations by removing interface
Removing old logic with internal interface which is not required, makes the logic more complex (as it requires some ugly casting) and worse perf due to having to go via the interface. The base class is all we need really.
2020-06-12 20:49:54 +00:00
Pantazis Deligiannis 3fefb1844b Merged PR 2390: fixed a bug in mocked task completion source
Also simplifying the mock logic, and adding a unit test to not regress again.
2020-06-12 20:36:46 +00:00
Chris Lovett 9c3ca5330f Merged PR 2379: remove ActorTestKit
remove ActorTestKit and temporarily remove tests that were using it.  Those tests are being re-written to use Operation instead.
2020-06-12 04:32:04 +00:00
Chris Lovett 761f11511c Merged PR 2356: fix problem with XUnit tests that return Microsoft.Coyote.Tasks.Task
Turns out XUnit does **not** work properly with Microsoft.Coyote.Tasks.Task.  It hides unhandled exceptions, so a bunch of failing tests were not reporting those failures.
2020-06-11 21:52:26 +00:00
Pantazis Deligiannis 4b48d78697 Merged PR 2358: make run-tests script logger optional
We don't always need to dump `trx` files, I found that it was dumping tons and tons of them on my laptop from repeated runs, so I made it optional.

You can now pass a `-logger FORMAT` option to the script, where `FORMAT` is a supported format like `trx`, like this:
```
.\Scripts\run-tests.ps1 -logger trx
```

And this will dump files like this:
```
Results File: ...\coyote\Tests\Production.Tests\TestResults\pdeligia_2020-06-10_07_14_18.trx
```

If we ever need this in CI, we can enable it as an option. But I noticed that this does not really do much, besides dumping the results on disk. Perhaps DevOps has to be given the `TestResults` directory?
2020-06-11 02:58:45 +00:00
Chris Lovett 5f530ce9f6 Merged PR 2311: refactor CreateActorIdFromNameTests and CreateActorTests to share code
Unify production and systematic CreateActorIdFromNameTests and CreateActorTests
Add Configuration.WithProductionMonitorEnabled
Fix a flakey test by adding a timeout.
2020-06-11 02:47:13 +00:00
Chris Lovett 16ab35d5ab Merged PR 2320: Promote OperationGroupingTests to be "Actor" level tests
In getting familiar with OperationGrouping I did some cleanup work on the tests.
Promote OperationGroupingTests to be "Actor" level tests instead of being StateMachine tests.  Also made them shared code for SystematicTest so we get more test coverage also, and fixed issues in BaseTest to make this work.  Also fixed long standing problem with BaseTest swallowing important error messages that where happening in actors on other threads that XUnit was not reporting.
2020-06-10 23:40:38 +00:00
Chris Lovett a5ef1b6869 Merged PR 2281: Start refactoring Actor unit tests to get some code sharing between Production and SystematicTesting
This is a first attempt at sharing code between Production and SystematicTesting for Actor unit tests.  (We already have 100% sharing for Task based tests).  This one is focused just on CustomActorRuntimeLogTests.  The trick was to make WaitAsync work across both production and systematic tests.

Related work items: #762
2020-06-10 19:31:52 +00:00
Pantazis Deligiannis ae7e345db6 Merged PR 2330: increase version to 1.0.11 2020-06-06 02:42:15 +00:00
Chris Lovett 8306128061 Merged PR 2331: fix custom logging when using the TestingEngine
Fix logging when using TestEngine directory so the logger provided to the test engine contains the actual test output.

Related work items: #4066
2020-06-06 02:21:36 +00:00
Chris Lovett 4878e3a64c Merged PR 2326: fix dispose on CoyoteRuntime and ControlledRuntime
Fix dispose on CoyoteRuntime so it resets the Current task and fix dispose on ControlledRuntime so it resets IsExecutionControlled. Add test to make sure it works.

This allows mixing of production tests in with systematic tests in the same test run which is important onramp for customers adopting Microsoft.Coyote.Task where they want to be able to run new Coyote tests and their old traditional unit tests in the same test run.

Related work items: #4065
2020-06-06 00:45:19 +00:00
Pantazis Deligiannis 3ec75ed3e3 Merged PR 2316: dead code elimination
Keep reducing those lines in the operation scheduler :)
2020-06-04 18:58:42 +00:00
Pantazis Deligiannis 558903be23 Merged PR 2304: update some tests 2020-06-03 22:17:15 +00:00
Pantazis Deligiannis ae4d0abec3 Merged PR 2258: make bookkeeping of current op more robust
This PR simplifies the logic of bookkeeping the currently executing operation in `OperationScheduler` and make it more robust.

We remove reliance on a dictionary of task ids to operations, which not only simplifies the logic, but also makes it more robust because we cannot rely on task ids. This is because the .NET runtime does not guarantee that task ids will be unique. From the official [docs](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.id?view=netcore-3.1):

> Task IDs are assigned on-demand and do not necessarily represent the order in which task instances are created. Note that although collisions are very rare, task identifiers are not guaranteed to be unique.
2020-06-03 22:08:18 +00:00