Exemplo n.º 1
0
        void Respond(string[] command)
        {
            try {
                if (command.Length == 0)
                {
                    throw new ServerException("Empty command");
                }

                var verb = command[0];
                if (verb == "verify")
                {
                    ServerUtils.checkArgs(command, 0);
                    var payload = ReadPayload();
                    VerificationTask.ReadTask(payload).Run();
                }
                else if (verb == "quit")
                {
                    ServerUtils.checkArgs(command, 0);
                    Exit();
                }
                else
                {
                    throw new ServerException("Unknown verb '{0}'", verb);
                }

                Interaction.EOM(Interaction.SUCCESS, "Verification completed successfully!");
            } catch (ServerException ex) {
                Interaction.EOM(Interaction.FAILURE, ex);
            } catch (Exception ex) {
                Interaction.EOM(Interaction.FAILURE, ex, "[FATAL]");
                running = false;
            }
        }
Exemplo n.º 2
0
        internal static void SelfTest()
        {
            var task = new VerificationTask(new string[] { }, "<none>", "method selftest() { assert true; }", false);

            try {
                task.Run();
                Interaction.EOM(Interaction.SUCCESS, (string)null);
            } catch (Exception ex) {
                Interaction.EOM(Interaction.FAILURE, ex);
            }
        }
Exemplo n.º 3
0
        VerificationTask ReadVerificationTask(bool inputIsPlaintext)
        {
            var payload = ReadPayload(inputIsPlaintext);

            if (inputIsPlaintext)
            {
                return(new VerificationTask(new string[0], "transcript", payload, false));
            }
            else
            {
                return(VerificationTask.ReadTask(payload));
            }
        }
Exemplo n.º 4
0
 internal static void SelfTest() {
   var task = new VerificationTask() {
     filename = "<none>",
     sourceIsFile = false,
     args = new string[] { },
     source = "method selftest() { assert true; }"
   };
   try {
     task.Run();
     Interaction.EOM(Interaction.SUCCESS, (string)null);
   } catch (Exception ex) {
     Interaction.EOM(Interaction.FAILURE, ex);
   }
 }
Exemplo n.º 5
0
        internal static void SelfTest()
        {
            var task = new VerificationTask()
            {
                filename     = "<none>",
                sourceIsFile = false,
                args         = new string[] { },
                source       = "method selftest() { assert true; }"
            };

            try {
                task.Run();
                Interaction.EOM(Interaction.SUCCESS, (string)null);
            } catch (Exception ex) {
                Interaction.EOM(Interaction.FAILURE, ex);
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Server server = new Server();

            var hasArg = args.Length > 0;
            var arg    = hasArg ? args[0] : null;

            if (hasArg && args[0] == "selftest")
            {
                VerificationTask.SelfTest();
            }
            else if (hasArg && File.Exists(arg))
            {
                Console.WriteLine("# Reading from {0}", Path.GetFileName(arg));
                Console.SetIn(new StreamReader(arg, Encoding.UTF8));
                server.Loop();
            }
            else
            {
                server.Loop();
            }
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Server server = new Server();

            // read the optional flag (only one flag is allowed)
            bool plaintext = false;
            bool selftest  = false;
            bool decode    = false;
            bool encode    = false;
            var  n         = 0; // number of consumed args
            var  arg       = n < args.Length ? args[n] : null;

            if (arg == "-plaintext")
            {
                plaintext = true;
                n++;
            }
            else if (arg == "-selftest")
            {
                selftest = true;
                n++;
            }
            else if (arg == "-decode")
            {
                decode = true;
                n++;
            }
            else if (arg == "-encode")
            {
                encode = true;
                n++;
            }

            if (selftest)
            {
                VerificationTask.SelfTest();
                return;
            }

            if (n < args.Length)
            {
                var inputFilename = args[n];
                if (File.Exists(inputFilename))
                {
                    Console.WriteLine("# Reading from {0}", Path.GetFileName(inputFilename));
                    Console.SetIn(new StreamReader(inputFilename, Encoding.UTF8));
                }
                else
                {
                    Console.WriteLine("Error: file '{0}' does not exist", inputFilename);
                }
            }

            if (decode)
            {
                server.Decode();
            }
            else if (encode)
            {
                server.Encode();
            }
            else
            {
                server.Loop(plaintext);
            }
        }
Exemplo n.º 8
0
        void Respond(string[] command)
        {
            try {
                if (command.Length == 0)
                {
                    throw new ServerException("Empty command");
                }

                var verb = command[0];
                if (verb == "verify")
                {
                    ServerUtils.checkArgs(command, 0);
                    var payload = ReadPayload();
                    VerificationTask.ReadTask(payload).Run();
                }
                else if (verb == "counterExample")
                {
                    ServerUtils.checkArgs(command, 0);
                    var payload = ReadPayload();
                    VerificationTask.ReadTask(payload).CounterExample();
                }
                else if (verb == "dotgraph")
                {
                    ServerUtils.checkArgs(command, 0);
                    var payload = ReadPayload();
                    VerificationTask.ReadTask(payload).DotGraph();
                }
                else if (verb == "symbols")
                {
                    ServerUtils.checkArgs(command, 0);
                    var payload = ReadPayload();
                    VerificationTask.ReadTask(payload).Symbols();
                }
                else if (verb == "version")
                {
                    ServerUtils.checkArgs(command, 0);
                    ReadPayload();
                    VersionCheck.CurrentVersion();
                }
                else if (verb == "unmarshal")
                {
                    ServerUtils.checkArgs(command, 0);
                    var payload = ReadPayload();
                    VerificationTask.ReadTask(payload).Unmarshal();
                }
                else if (verb == "quit")
                {
                    ServerUtils.checkArgs(command, 0);
                    Exit();
                }
                else
                {
                    throw new ServerException("Unknown verb '{0}'", verb);
                }

                Interaction.EOM(Interaction.SUCCESS, "Verification completed successfully!");
            } catch (ServerException ex) {
                Interaction.EOM(Interaction.FAILURE, ex);
            } catch (Exception ex) {
                Interaction.EOM(Interaction.FAILURE, ex, "[FATAL]");
                running = false;
            }
        }