public void Can_find_safety_bug()
        {
            // Arrange
            var configuration = Configuration.Create().WithNumberOfIterations(200).
                                WithMaxSchedulingSteps(300).
                                WithParallelBugFindingTasks(5).
                                WithRandomSchedulingSeed();
            var engine = new CompositeBugFindingEngine(configuration, runtimeHost =>
            {
                var processExecutorMock = new Mock <IProcessExecutor>();
                var container           = runtimeHost.Container;
                container.RegisterType <IProcessExecutor>(new InjectionFactory((_1, _2, _3) => processExecutorMock.Object)).
                RegisterType <ServerReceiver, ServerReceiverWithSafetyBug>();

                var ctx      = runtimeHost.New <DistributedStorageContext>();
                var messages = new MessageCollection();

                container.Resolve <MainMonitorsController>().NewMonitors(ctx, messages);
                container.Resolve <MainServersController>().NewServer(ctx, messages);
                container.Resolve <MainStorageNodesController>().NewStorageNodes(ctx, messages);
                container.Resolve <MainClientsController>().NewClient(ctx, messages);
            });


            // Act
            engine.RunAndEmitTraces();


            // Assert
            Assert.GreaterOrEqual(engine.TestReport.NumOfFoundBugs, 1);
            Assert.That(engine.ReportFully(), Does.Match(@"(<ErrorLog> Detected an assertion failure)"));
        }
Esempio n. 2
0
        public void ReportFully_should_return_readable_trace_contents()
        {
            // Arrange
            var configuration = Configuration.Create().WithNumberOfIterations(200).
                                WithMaxSchedulingSteps(200).
                                WithParallelBugFindingTasks(5).
                                WithRandomSchedulingSeed();
            var testArtifact = configuration.CreateTestArtifact(MethodBase.GetCurrentMethod(), new DateTime(2017, 10, 10));
            var engine       = new CompositeBugFindingEngine(configuration, runtimeHost =>
            {
                var m1 = runtimeHost.New(MachineInterface.Sender <M1.ISender>().Bundler <M1.IBundler>().Receiver <M1.BugReceiver>());
                m1.Configure(new Notify());
            });

            engine.RunAndEmitTraces(testArtifact);


            // Act
            var result = engine.ReportFully();


            // Assert
            Assert.That(result, Does.Match($@"<StrategyLog> { testArtifact.TraceNameBase }_\d+_\d+\.txt"));
            Assert.That(result, Does.Match("<ErrorLog> Bug Found!!!!"));
        }
Esempio n. 3
0
        public void ReportFully_should_return_empty_if_not_emitting_trace()
        {
            // Arrange
            var configuration = Configuration.Create().WithNumberOfIterations(200).
                                WithMaxSchedulingSteps(200).
                                WithParallelBugFindingTasks(5).
                                WithRandomSchedulingSeed();
            var testArtifact = configuration.CreateTestArtifact(MethodBase.GetCurrentMethod(), new DateTime(2017, 10, 10));
            var engine       = new CompositeBugFindingEngine(configuration, runtimeHost =>
            {
                var m1 = runtimeHost.New(MachineInterface.Sender <M1.ISender>().Bundler <M1.IBundler>().Receiver <M1.BugReceiver>());
                m1.Configure(new Notify());
            });

            engine.Run();


            // Act
            var result = engine.ReportFully();


            // Assert
            Assert.IsEmpty(result);
        }