示例#1
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.SetLogger(new PLogger());
     PModule.runtime = runtime;
     PHelper.InitializeInterfaces();
     InitializeLinkMap();
     InitializeInterfaceDefMap();
     InitializeMonitorMap(runtime);
     InitializeMonitorObserves();
     runtime.CreateMachine(typeof(_GodMachine), new _GodMachine.Config(typeof(TestDriver)));
 }
示例#2
0
        public void TestCustomLoggerNoVerbosity()
        {
            CustomLogger logger = new CustomLogger();

            PSharpRuntime runtime = PSharpRuntime.Create();

            runtime.SetLogger(logger);

            var tcs = new TaskCompletionSource <bool>();

            runtime.CreateMachine(typeof(M), new Configure(tcs));
            tcs.Task.Wait();

            Assert.Equal("", logger.ToString());

            logger.Dispose();
        }
示例#3
0
        public void TestCustomLogger()
        {
            CustomLogger logger = new CustomLogger();

            Configuration config  = Configuration.Create().WithVerbosityEnabled(2);
            PSharpRuntime runtime = PSharpRuntime.Create(config);

            runtime.SetLogger(logger);

            var tcs = new TaskCompletionSource <bool>();

            runtime.CreateMachine(typeof(M), new Configure(tcs));
            tcs.Task.Wait();

            string expected = @"<CreateLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M()' is created.
<StateLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M()' enters state 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M.Init'.
<ActionLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M()' invoked action 'InitOnEntry' in state 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M.Init'.
<CreateLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+N()' is created.
<StateLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+N()' enters state 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+N.Init'.
<SendLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M()' sent event 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+E' to 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+N()'.
<EnqueueLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+N()' enqueued event 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+E'.
<DequeueLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+N()' dequeued event 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+E'.
<ActionLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+N()' invoked action 'Act' in state 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+N.Init'.
<SendLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+N()' sent event 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+E' to 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M()'.
<EnqueueLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M()' enqueued event 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+E'.
<DequeueLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M()' dequeued event 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+E'.
<ActionLog> Machine 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M()' invoked action 'Act' in state 'Microsoft.PSharp.Core.Tests.Unit.CustomLoggerTest+M.Init'.
";

            string actual = Regex.Replace(logger.ToString(), "[0-9]", "");

            HashSet <string> expectedSet = new HashSet <string>(Regex.Split(expected, "\r\n|\r|\n"));
            HashSet <string> actualSet   = new HashSet <string>(Regex.Split(actual, "\r\n|\r|\n"));

            Assert.True(expectedSet.SetEquals(actualSet));

            logger.Dispose();
        }
示例#4
0
        public void TestNullCustomLoggerFail()
        {
            PSharpRuntime runtime = PSharpRuntime.Create();

            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => runtime.SetLogger(null));

            Assert.Equal("Cannot install a null logger.", ex.Message);
        }