protected void AssertFailedWithException(Configuration configuration, Action <PSharpRuntime> test, Type exceptionType, bool replay) { Assert.True(exceptionType.IsSubclassOf(typeof(Exception)), "Please configure the test correctly. " + $"Type '{exceptionType}' is not an exception type."); TestOutputLogger logger = new TestOutputLogger(this.TestOutput); try { var bfEngine = BugFindingEngine.Create(configuration, test); bfEngine.SetLogger(logger); bfEngine.Run(); CheckErrors(bfEngine, exceptionType); if (replay && !configuration.EnableCycleDetection) { var rEngine = ReplayEngine.Create(configuration, test, bfEngine.ReproducableTrace); rEngine.SetLogger(logger); rEngine.Run(); Assert.True(rEngine.InternalError.Length == 0, rEngine.InternalError); CheckErrors(rEngine, exceptionType); } } catch (Exception ex) { Assert.False(true, ex.Message + "\n" + ex.StackTrace); } finally { logger.Dispose(); } }
protected void AssertFailed(Configuration configuration, Action <PSharpRuntime> test, int numExpectedErrors, Func <HashSet <string>, bool> expectedOutputFunc, bool replay) { TestOutputLogger logger = new TestOutputLogger(this.TestOutput); try { var bfEngine = BugFindingEngine.Create(configuration, test); bfEngine.SetLogger(logger); bfEngine.Run(); CheckErrors(bfEngine, numExpectedErrors, expectedOutputFunc); if (replay && !configuration.EnableCycleDetection) { var rEngine = ReplayEngine.Create(configuration, test, bfEngine.ReproducableTrace); rEngine.SetLogger(logger); rEngine.Run(); Assert.True(rEngine.InternalError.Length == 0, rEngine.InternalError); CheckErrors(rEngine, numExpectedErrors, expectedOutputFunc); } } catch (Exception ex) { Assert.False(true, ex.Message + "\n" + ex.StackTrace); } finally { logger.Dispose(); } }
protected void AssertSucceeded(Configuration configuration, Action <PSharpRuntime> test) { TestOutputLogger logger = new TestOutputLogger(this.TestOutput); try { var engine = BugFindingEngine.Create(configuration, test); engine.SetLogger(logger); engine.Run(); var numErrors = engine.TestReport.NumOfFoundBugs; Assert.True(numErrors == 0, GetBugReport(engine)); } catch (Exception ex) { Assert.False(true, ex.Message + "\n" + ex.StackTrace); } finally { logger.Dispose(); } }