From f7beb82f98b2a53037ee5cdb73938b5c95c9d759 Mon Sep 17 00:00:00 2001 From: Pantazis Deligiannis Date: Thu, 16 Aug 2018 12:41:46 +0100 Subject: [PATCH] fixes in nuspec and removed dependency in P# tester for .NET core (#344) --- Scripts/NuGet/PSharp.nuspec | 32 +++++++++++-------- .../Tester/Interfaces/ITestingProcess.cs | 9 +++++- .../Interfaces/ITestingProcessScheduler.cs | 2 ++ .../Tester/Interfaces/KnownTypesProvider.cs | 2 ++ .../Scheduling/TestingProcessScheduler.cs | 25 ++++++++++++--- Tools/Testing/Tester/Tester.csproj | 3 -- .../Testing/Tester/Testing/TestingProcess.cs | 2 ++ 7 files changed, 54 insertions(+), 21 deletions(-) diff --git a/Scripts/NuGet/PSharp.nuspec b/Scripts/NuGet/PSharp.nuspec index 34ba55b8d..f54ffeed4 100644 --- a/Scripts/NuGet/PSharp.nuspec +++ b/Scripts/NuGet/PSharp.nuspec @@ -13,25 +13,31 @@ asynchrony testing .NET programming actors state-machines + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - + + diff --git a/Tools/Testing/Tester/Interfaces/ITestingProcess.cs b/Tools/Testing/Tester/Interfaces/ITestingProcess.cs index d4c4c4272..989a6fa41 100644 --- a/Tools/Testing/Tester/Interfaces/ITestingProcess.cs +++ b/Tools/Testing/Tester/Interfaces/ITestingProcess.cs @@ -12,8 +12,9 @@ // //----------------------------------------------------------------------- +#if NET46 || NET45 using System.ServiceModel; - +#endif using Microsoft.PSharp.TestingServices.Coverage; namespace Microsoft.PSharp.TestingServices @@ -21,21 +22,27 @@ namespace Microsoft.PSharp.TestingServices /// /// Interface for a remote P# testing process. /// +#if NET46 || NET45 [ServiceContract(Namespace = "Microsoft.PSharp")] [ServiceKnownType("GetKnownTypes", typeof(KnownTypesProvider))] +#endif internal interface ITestingProcess { /// /// Returns the test report. /// /// TestReport +#if NET46 || NET45 [OperationContract] +#endif TestReport GetTestReport(); /// /// Stops testing. /// +#if NET46 || NET45 [OperationContract] +#endif void Stop(); } } diff --git a/Tools/Testing/Tester/Interfaces/ITestingProcessScheduler.cs b/Tools/Testing/Tester/Interfaces/ITestingProcessScheduler.cs index dd72c1544..eb0981a84 100644 --- a/Tools/Testing/Tester/Interfaces/ITestingProcessScheduler.cs +++ b/Tools/Testing/Tester/Interfaces/ITestingProcessScheduler.cs @@ -12,6 +12,7 @@ // //----------------------------------------------------------------------- +#if NET46 || NET45 using System.ServiceModel; namespace Microsoft.PSharp.TestingServices @@ -41,3 +42,4 @@ internal interface ITestingProcessScheduler void SetTestReport(TestReport testReport, uint processId); } } +#endif diff --git a/Tools/Testing/Tester/Interfaces/KnownTypesProvider.cs b/Tools/Testing/Tester/Interfaces/KnownTypesProvider.cs index a261e6661..c16ce8715 100644 --- a/Tools/Testing/Tester/Interfaces/KnownTypesProvider.cs +++ b/Tools/Testing/Tester/Interfaces/KnownTypesProvider.cs @@ -12,6 +12,7 @@ // //----------------------------------------------------------------------- +#if NET46 || NET45 using System; using System.Collections.Generic; using System.Reflection; @@ -40,3 +41,4 @@ public static IEnumerable GetKnownTypes(ICustomAttributeProvider provider) } } } +#endif diff --git a/Tools/Testing/Tester/Scheduling/TestingProcessScheduler.cs b/Tools/Testing/Tester/Scheduling/TestingProcessScheduler.cs index 6cfeef3ea..313d77c3a 100644 --- a/Tools/Testing/Tester/Scheduling/TestingProcessScheduler.cs +++ b/Tools/Testing/Tester/Scheduling/TestingProcessScheduler.cs @@ -16,8 +16,10 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; +#if NET46 || NET45 using System.ServiceModel; using System.ServiceModel.Description; +#endif using Microsoft.PSharp.IO; using Microsoft.PSharp.Utilities; @@ -30,7 +32,10 @@ namespace Microsoft.PSharp.TestingServices #if NET46 || NET45 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] #endif - internal sealed class TestingProcessScheduler : ITestingProcessScheduler + internal sealed class TestingProcessScheduler +#if NET46 || NET45 + : ITestingProcessScheduler +#endif { /// /// Configuration. @@ -42,12 +47,12 @@ internal sealed class TestingProcessScheduler : ITestingProcessScheduler /// The notification listening service. /// private ServiceHost NotificationService; -#endif /// /// Map from testing process ids to testing processes. /// private Dictionary TestingProcesses; +#endif /// /// Map from testing process ids to testing process channels. @@ -75,11 +80,13 @@ internal sealed class TestingProcessScheduler : ITestingProcessScheduler /// private object SchedulerLock; +#if NET46 || NET45 /// /// The process id of the process that /// discovered a bug, else null. /// private uint? BugFoundByProcess; +#endif /// /// Set if ctrl-c or ctrl-break occurred. @@ -99,15 +106,17 @@ internal sealed class TestingProcessScheduler : ITestingProcessScheduler /// Configuration private TestingProcessScheduler(Configuration configuration) { +#if NET46 || NET45 this.TestingProcesses = new Dictionary(); +#endif this.TestingProcessChannels = new Dictionary(); this.TestReports = new ConcurrentDictionary(); this.GlobalTestReport = new TestReport(configuration); this.Profiler = new Profiler(); this.SchedulerLock = new object(); +#if NET46 || NET45 this.BugFoundByProcess = null; -#if NET46 || NET45 // Code coverage should be run out-of-process; otherwise VSPerfMon won't shutdown correctly // because an instrumented process (this one) is still running. this.runOutOfProcess = configuration.ParallelBugFindingTasks > 1 || configuration.ReportCodeCoverage; @@ -124,6 +133,7 @@ private TestingProcessScheduler(Configuration configuration) this.Configuration = configuration; } +#if NET46 || NET45 /// /// Notifies the testing process scheduler /// that a bug was found. @@ -179,6 +189,7 @@ void ITestingProcessScheduler.SetTestReport(TestReport testReport, uint processI this.MergeTestReport(testReport, processId); } } +#endif /// /// Creates a new P# testing process scheduler. @@ -379,7 +390,6 @@ private ITestingProcess CreateTestingProcessChannel(uint processId) return ChannelFactory.CreateChannel(binding, endpoint); } -#endif /// /// Stops the testing process. @@ -398,6 +408,7 @@ private void StopTestingProcess(uint processId) IO.Debug.WriteLine(ex.ToString()); } } +#endif /// /// Gets the test report from the specified testing process. @@ -408,9 +419,12 @@ private TestReport GetTestReport(uint processId) { TestReport testReport = null; +#if NET46 || NET45 try { +#endif testReport = this.TestingProcessChannels[processId].GetTestReport(); +#if NET46 || NET45 } catch (CommunicationException ex) { @@ -418,6 +432,7 @@ private TestReport GetTestReport(uint processId) $"'{processId}'. Task has already terminated."); IO.Debug.WriteLine(ex.ToString()); } +#endif return testReport; } @@ -448,6 +463,7 @@ private void MergeTestReport(TestReport testReport, uint processId) private void EmitTestReport() { var testReports = new List(this.TestReports.Values); +#if NET46 || NET45 foreach (var process in this.TestingProcesses) { if (!this.TestReports.ContainsKey(process.Key)) @@ -455,6 +471,7 @@ private void EmitTestReport() Output.WriteLine($"... Task {process.Key} failed due to an internal error."); } } +#endif if (this.TestReports.Count == 0) { diff --git a/Tools/Testing/Tester/Tester.csproj b/Tools/Testing/Tester/Tester.csproj index 045f4ab71..a080e19b3 100644 --- a/Tools/Testing/Tester/Tester.csproj +++ b/Tools/Testing/Tester/Tester.csproj @@ -17,9 +17,6 @@ - - - diff --git a/Tools/Testing/Tester/Testing/TestingProcess.cs b/Tools/Testing/Tester/Testing/TestingProcess.cs index ee1fe05ca..1ec723f89 100644 --- a/Tools/Testing/Tester/Testing/TestingProcess.cs +++ b/Tools/Testing/Tester/Testing/TestingProcess.cs @@ -16,8 +16,10 @@ using System.Diagnostics; using System.IO; using System.Linq; +#if NET46 || NET45 using System.ServiceModel; using System.ServiceModel.Description; +#endif using System.Timers; using Microsoft.PSharp.IO;