Example #1
0
   public VccAssembly(IName name, string location, ISourceEditHost hostEnvironment, VccOptions options,
 IEnumerable<IAssemblyReference> assemblyReferences, IEnumerable<IModuleReference> moduleReferences, IEnumerable<VccSourceDocument> programSources)
       : base(name, location, name, assemblyReferences, moduleReferences, new List<IResourceReference>(0).AsReadOnly(), new List<IFileReference>(0).AsReadOnly())
   {
       this.options = options;
         this.hostEnvironment = hostEnvironment;
         this.programSources = programSources;
   }
Example #2
0
 public PluginManager(VccOptions options)
 {
     List<string> dirs;
       if (options.PluginOptions.TryGetValue("dir", out dirs)) {
     foreach (var d in dirs)
       AddPluginDirectory(d);
       }
 }
Example #3
0
   internal VccAssembly(IName name, string location, ISourceEditHost hostEnvironment, VccOptions options,
 IEnumerable<IAssemblyReference> assemblyReferences, IEnumerable<IModuleReference> moduleReferences, IEnumerable<CompilationPart> compilationParts)
       : base(name, location, name, assemblyReferences, moduleReferences, new List<IResourceReference>(0).AsReadOnly(), new List<IFileReference>(0).AsReadOnly())
   {
       this.options = options;
         this.hostEnvironment = hostEnvironment;
         this.compilationParts = compilationParts;
   }
Example #4
0
 public ErrorReporter(VccOptions opts, string name, IToken tok, double startTime, VerificationErrorHandler errorHandler)
 {
     this.name = name;
       this.startTime = startTime;
       this.prevTime = VccCommandLineHost.GetTime();
       this.commandLineOptions = opts;
       this.proverWarnings = new List<string>();
       this.errorHandler = errorHandler;
       this.tok = tok;
 }
Example #5
0
        private static Plugin InitializePlugin(VccOptions commandLineOptions)
        {
            try
              {
            string pluginName = null;
            Plugin selectedPlugin = null;
            VCGenPlugin vcgenPlugin = null;

            if (commandLineOptions.PluginOptions.Count != 0 || commandLineOptions.DisplayCommandLineHelp)
            {
              pluginManager = new PluginManager(commandLineOptions);
              string pluginDir = PathHelper.PluginDir;
              if (pluginDir != null) pluginManager.AddPluginDirectory(pluginDir);
              pluginManager.Discover();
              foreach (var opt in commandLineOptions.PluginOptions.Keys)
              {
            if (opt == "dir") continue;
            if (pluginName == null)
            {
              pluginName = opt;
            }
            else
            {
              Logger.Instance.Error("More than one plugin requested ('{0}' and '{1}').", pluginName, opt);
              return null;
            }
              }

              if (pluginName != null)
              {
            foreach (var plugin in pluginManager.Plugins)
            {
              if (string.Compare(pluginName, plugin.Name(), true) == 0)
              {
                if (selectedPlugin != null)
                {
                  Logger.Instance.Error("More than one plugin matches '{0}'.", pluginName);
                  return null;
                }
                selectedPlugin = plugin;
              }
            }
            if (selectedPlugin == null)
            {
              foreach (var plugin in pluginManager.VCGenPlugins)
              {
                if (string.Compare(pluginName, plugin.Name, true) == 0)
                {
                  if (vcgenPlugin != null)
                  {
                    Logger.Instance.Error("More than one VCGEN plugin matches '{0}'.", pluginName);
                    return null;
                  }
                  vcgenPlugin = plugin;
                }
              }

              if (vcgenPlugin == null)
              {
                Logger.Instance.Error("Plugin '{0}' not found.", pluginName);
                return null;
              }
            }
              }
            }

            if (selectedPlugin == null) selectedPlugin = new VccPlugin(vcgenPlugin); // the default

            selectedPlugin.RegisterStopwatch(swTotal);
            selectedPlugin.RegisterStopwatch(swVisitor);
            selectedPlugin.RegisterStopwatch(swPlugin);
            selectedPlugin.RegisterStopwatch(swPrelude);
            selectedPlugin.MessageHandler.AddHandler(PrintPluginMessage);

            try
            {
              swPlugin.Start();
              selectedPlugin.UseOptions(new VccOptionWrapper(commandLineOptions));
              if (pluginName != null)
            selectedPlugin.UseCommandLineOptions(commandLineOptions.PluginOptions[pluginName]);
            }
            finally
            {
              swPlugin.Stop();
            }

            return selectedPlugin;

              }
              catch (System.Reflection.ReflectionTypeLoadException e)
              {
            foreach (Exception ex in e.LoaderExceptions)
            {
              Logger.Instance.Error(ex.Message);
              Logger.Instance.Error(ex.StackTrace);
            }
              }
              return null;
        }
Example #6
0
 public override void UseOptions(Helper.Options opts)
 {
     options = ((VccOptionWrapper)opts).VccOptions;
 }
Example #7
0
        private void Init(TransHelper.TransEnv env, string filename)
        {
            RegisterStopwatches();
              foreach (var s in env.Stopwatches)
            this.RegisterStopwatch(s);

              Transformers.init(env);
              Transformers.processPipeOptions(env);
              options = ((VccOptionWrapper)env.Options).VccOptions;
              this.BvdModelFileName = options.SaveModelForBvd ? AddOutputDirIfRequested(Path.ChangeExtension(filename, "model")) : null;
        }
Example #8
0
 public CciErrorHandler(VccOptions commandLineOptions)
 {
     this.CommandLineOptions = commandLineOptions;
 }
Example #9
0
 public VerificationErrorHandler(VccOptions commandLineOptions)
 {
     this.commandLineOptions = commandLineOptions;
 }
Example #10
0
 static bool RunTestSuite(FileInfo testFile, VccOptions commandLineOptions)
 {
     using (var reader = new StreamReader(testFile.Open(FileMode.Open, FileAccess.Read)))
     return RunTestSuite(testFile.DirectoryName, testFile.Name, reader, commandLineOptions);
 }
Example #11
0
        private int startOfCurrentLine; //^ invariant 0 <= startOfCurrentLine && startOfCurrentLine <= fragmentIndex;

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Allocates a preprocessor instance that can be queried for a list of source locations that represent the output from the preprocessor. This output
        /// omits preprocessor directives as well as any excluded sections. It also applies line directives by mapping some of the produced source locations
        /// onto the documents mentioned in the line directives. In other words, the produced source locations will not necessarily come from the document
        /// being preprocessed. Preprocessing happens lazily when the result of calling GetIncludedSections is enumerated.
        /// </summary>
        /// <param name="documentToProcess">The source document to preprocess.</param>
        /// <param name="options">An object that specifies any preprocessor symbols that are defined as compiler options by the environment.</param>
        internal Preprocessor(IVccUnpreprocessedSourceDocument documentToProcess, VccOptions options)
        {
            this.documentToProcess = documentToProcess;
              List<IErrorMessage> errors = this.errors = new List<IErrorMessage>();
              this.preprocessorInformation = new PreprocessorInformation(documentToProcess, errors);
              Dictionary<string, string> preprocessorDefinedSymbols = new Dictionary<string,string>();
              foreach (string ppOption in options.PreprocessorOptions) {
            if (!ppOption.StartsWith("/D", StringComparison.Ordinal)) continue;
            int eqIndex = ppOption.IndexOf('=');
            if (eqIndex < 0) eqIndex = ppOption.Length;
            string symName = ppOption.Substring(2, eqIndex-2);
            preprocessorDefinedSymbols[symName] = eqIndex != ppOption.Length ? ppOption.Substring(eqIndex+1) : String.Empty;
              }
              preprocessorDefinedSymbols["true"] = "true";
              preprocessorDefinedSymbols.Remove("false");
              this.preprocessorDefinedSymbols = preprocessorDefinedSymbols;
              this.buffer = new char[8192];
        }
Example #12
0
 public TestRunnerMT(int threadCount, VccOptions commandLineOptions)
 {
     this.threadCount = threadCount;
     this.commandLineOptions = commandLineOptions;
 }
Example #13
0
        static bool RunTestSuite(string directoryName, string suiteName, StreamReader instream, VccOptions commandLineOptions)
        {
            var startTime = DateTime.UtcNow;
              System.Diagnostics.Debug.Listeners.Remove("Default");
              var errorHandler = new CciErrorHandler(commandLineOptions);
              StringBuilder source = null;
              StringBuilder expectedOutput = null;
              StringBuilder actualOutput = null;
            int errors = 0;
              int testCaseCount = 0;
              var WhiteSpaceChars = " \r\n\t".ToCharArray();

              try {
            int line = 1;

            while (!instream.EndOfStream) {
              var l = instream.ReadLine(); // strips Unix or Dos line ending
              line++;

              source = new StringBuilder();
            List<string> compilerParameters;
            if (l.StartsWith("`") || l.StartsWith("//`")) {
            string optionString = l.Substring(l.IndexOf('`') + 1);
            compilerParameters = optionString.Split(WhiteSpaceChars, StringSplitOptions.RemoveEmptyEntries).ToList();
              } else {
            compilerParameters = new List<string>();
            source.Append(l);
            source.Append("\r\n");
              }

              while (!instream.EndOfStream) {
            l = instream.ReadLine();
            line++;
            if (l == "`" || l == "/*`")
              break;
            source.Append(l);
            source.Append("\r\n");
              }

              if (instream.EndOfStream) {
            Logger.Instance.Error("The last test case in the suite has not been provided with expected output");
            errors++;
            break;
              }

              int errLine = line;
              expectedOutput = new StringBuilder();
              while (!instream.EndOfStream) {
            l = instream.ReadLine();
            line++;
            if (l == "`" || l == "`*/")
              break;
            expectedOutput.Append(l);
            expectedOutput.Append("\r\n");
              }

              if (l != "`" && l != "`*/") {
            Logger.Instance.Error("The last test case in the suite has been provided with incomplete expected output");
            errors++;
            break;
              }

              actualOutput = new StringBuilder();
              TextWriter savedOut = Console.Out;
              Console.SetOut(new StringWriter(actualOutput));
              System.Diagnostics.TextWriterTraceListener myWriter = new System.Diagnostics.TextWriterTraceListener(System.Console.Out);
              System.Diagnostics.Debug.Listeners.Add(myWriter);

              ++testCaseCount;
              string suiteNameWithoutExt = Path.GetFileNameWithoutExtension(suiteName);
              string fileNameWithoutExt;

              if (commandLineOptions.OutputDir != null)
              {
              fileNameWithoutExt = commandLineOptions.OutputDir;
              }
              else
              {
              fileNameWithoutExt = directoryName;
              }

              fileNameWithoutExt += Path.DirectorySeparatorChar + suiteNameWithoutExt + vccSplitSuffix + testCaseCount + "_" + System.Diagnostics.Process.GetCurrentProcess().Id;
              currentTestcaseName = Path.GetFileName(string.Format("{0}.{1:00}", suiteNameWithoutExt, testCaseCount));

              try {
            int returnCode = RunTest(errorHandler, suiteNameWithoutExt, fileNameWithoutExt, source.ToString(), commandLineOptions, compilerParameters);
            if (returnCode < 0)
              actualOutput.Append("Non zero return code: " + returnCode);
              } catch (System.Reflection.TargetInvocationException e) {
            actualOutput.Append(e.InnerException);
              } catch (Exception e) {
            actualOutput.Append(e);
              }

              Logger.Instance.ResetReportedErrors();
              Console.SetOut(savedOut);
              System.Diagnostics.Debug.Listeners.Remove(myWriter);
              Regex rx = new Regex(@"[a-zA-Z]:\\.*?\\(.*)" + vccSplitSuffix + @"[0-9_]*.c\(");
              string actualOutputRepl = rx.Replace(actualOutput.ToString(), "testcase(");
              actualOutputRepl = actualOutputRepl.Trim();

              var expected = expectedOutput.ToString().Trim();
              if (!expected.Equals(actualOutputRepl)) {
            ReportError(suiteName, source, expected, actualOutputRepl, errLine, errors++ == 0);
              }

            }
            instream.Close();
            var runtime = DateTime.UtcNow.Subtract(startTime).TotalSeconds;
            if (errors == 0)
              Logger.Instance.Log("{0} passed [{1:0.00}]", suiteName, runtime);
            else {
              Logger.Instance.NewLine();
              Logger.Instance.Error("{0} had {1} failure(s) [{2:0.00}]", suiteName, errors, runtime);
            }
              } catch {
            var expected = expectedOutput == null ? "<none>" : expectedOutput.ToString().Trim();
            ReportError(suiteName, source, expected, actualOutput.ToString(), -1, true);
              }
              return errors == 0;
        }
Example #14
0
        private static Program GetStandardPrelude(VccOptions options)
        {
            string _preludePath = string.IsNullOrEmpty(options.PreludePath) ? PathHelper.PreludePath(StandardPreludePath) : options.PreludePath;
              if (standardPreludeLines == null)
              {
            var lines = File.ReadAllLines(_preludePath, Encoding.UTF8);
            standardPreludeLines = new List<string>(lines);
              }

              Program prelude;
              int _errorCount = Boogie.Parser.Parse(_preludePath, new List<string>(), out prelude);
              if (prelude == null || _errorCount > 0)
              {
            Logger.Instance.Error("There were errors parsing Vcc3Prelude.bpl.");
            return new Program();
              }
              else
              {
            return prelude;
              }
        }
Example #15
0
   //TODO: pass in information about which assemblies belong to which named unit sets
   public VccModule(IName name, string location, ISourceEditHost hostEnvironment, VccOptions options, IAssembly containingAssembly,
 IEnumerable<IAssemblyReference> assemblyReferences, IEnumerable<IModuleReference> moduleReferences, IEnumerable<VccSourceDocument> programSources)
       : base(name, location, containingAssembly, assemblyReferences, moduleReferences)
   {
       this.options = options;
         this.hostEnvironment = hostEnvironment;
         this.programSources = programSources;
   }
Example #16
0
 private static void DumpTimes(VccOptions commandLineOptions)
 {
     if (commandLineOptions.DetailedTimes)
       {
     foreach (var s in currentPlugin.Stopwatches)
     {
       Logger.Instance.Log(s.Display());
     }
       }
 }
Example #17
0
        internal static Program StandardPrelude(VccOptions options)
        {
            // For now Boogie does not support reusing the prelude.

            //if (standardPrelude == null)
            //  standardPrelude = GetStandardPrelude();
            //return standardPrelude;

            try
            {
              swPrelude.Start();
              return GetStandardPrelude(options);
            }
            finally
            {
              swPrelude.Stop();
            }
        }
Example #18
0
        internal static int Felt2Cast2Plugin(string fileName, VccOptions commandLineOptions, HostEnvironment hostEnvironment, VccAssembly assem)
        {
            try
              {

            TransHelper.TransEnv helperenv;
            FSharp.Collections.FSharpList<CAST.Top> res;

            try
            {
              swVisitor.Start();
              helperenv = new TransEnv(hostEnvironment, commandLineOptions);
              var visitor = new Microsoft.Research.Vcc.Visitor(assem.Compilation.ContractProvider, helperenv);

              if (commandLineOptions.VerificationLocation != null)
              {
            var memberAtLoc = FindMemberNameByLocation(commandLineOptions.VerificationLocation, assem);
            if (memberAtLoc != null)
            {
              commandLineOptions.Functions.Add(memberAtLoc);
            }
              }

              try
              {
            if (commandLineOptions.AggressivePruning && (commandLineOptions.Functions.Count > 0 || commandLineOptions.FunctionsWithExactName.Count > 0))
            {
              var pruningRoots = new List<string>();
              pruningRoots.AddRange(commandLineOptions.Functions.ConvertAll(FunctionOrTypeRoot));
              pruningRoots.AddRange(commandLineOptions.FunctionsWithExactName.ConvertAll(FunctionOrTypeRoot));
              visitor.VisitOnly(assem, pruningRoots);
            }
            else
              ((ICodeVisitor)visitor).Visit(assem);
              }
              catch
              {
            if (helperenv.ShouldDumpStack) throw;
            return 0;
              }

              res = visitor.GetResult();
            }
            finally
            {
              swVisitor.Stop();
            }

            if (fileErrorCount > 0) return fileErrorCount;

            try
            {
              swPlugin.Start();
              if (currentPlugin.IsModular())
              {
            var fv = currentPlugin.GetFunctionVerifier(fileName, helperenv, res);
            if (helperenv.ShouldContinue && fileErrorCount == 0)
              VerifyFunctions(commandLineOptions, fileName, assem.Name.ToString(), fv);
              }
              else
              {
            currentPlugin.Verify(fileName, helperenv, res);
              }
            }
            finally
            {
              errorCount += fileErrorCount;
              fileErrorCount = 0;
              swPlugin.Stop();
            }

            return 0;

              }
              catch (ProverDiedException e)
              {
            // we might want to do something else for this one
            Logger.Instance.NewLine();
            Logger.Instance.Error(e.Message);
              }
              catch (UnexpectedProverOutputException e)
              {
            Logger.Instance.NewLine();
            Logger.Instance.Error(e.Message);
              }
              catch (Exception e)
              {
            Logger.Instance.NewLine();
            Logger.Instance.Error(e.Message);
              }

              return -2;
        }
Example #19
0
        private static int RunTest(CciErrorHandler errorHandler, string suiteName, string fileNameWithoutExt,
                               string test, VccOptions commandLineOptions, List<string> compilerParameters)
        {
            VccCommandLineHost.ResetErrorCount();
              string fileNameC = fileNameWithoutExt + ".c";
              string fileNameI = fileNameWithoutExt + ".i";

              StreamWriter tempStreamWriter = new StreamWriter(fileNameC);
              tempStreamWriter.Write(test);
              tempStreamWriter.Close();

              VccOptions options = new VccOptions();
              options.CopyFrom(commandLineOptions);

              if (compilerParameters != null)
            options = OptionParser.ParseCommandLineArguments(VccCommandLineHost.dummyHostEnvironment, compilerParameters, options);

              options.NoPreprocessor = false;
              options.CheckedArithmetic = true;
              options.RunTestSuite = true;
              options.FileNames = new List<string> { fileNameC };

              HostEnvironment hostEnvironment = new HostEnvironment(options.PointerSize);
              hostEnvironment.Errors += errorHandler.HandleErrors;

              bool errorsInPreprocessor;
              var f = CCompilerHelper.Preprocess(options, out errorsInPreprocessor);
              if (errorsInPreprocessor) return -1;
              var st = f.First();
              test = st.ReadToEnd();
              st.Close();
              File.Delete(fileNameC);
              // if (!options.KeepPreprocessorFiles) File.Delete(fileNameI);

              IName name = hostEnvironment.NameTable.GetNameFor(suiteName);
              List<IAssemblyReference> assemblyReferences = new List<IAssemblyReference>();
              List<IModuleReference> moduleReferences = new List<IModuleReference>();
              assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity));
              assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.VccRuntimeAssemblyIdentity));
              VccAssembly/*?*/ assem = null;
              if (hostEnvironment.previousDocument == null || compilerParameters == null ||
              !compilerParameters.Contains("/incremental"))
              {
            List<VccSourceDocument> programSources = new List<VccSourceDocument>(1);
            assem = new VccAssembly(name, "", hostEnvironment, options, assemblyReferences, moduleReferences, programSources);
            var helper = new VccCompilationHelper(assem.Compilation);
            programSources.Add(hostEnvironment.previousDocument = new VccSourceDocument(helper, name, name.ToString(), test));
              }
              VccCommandLineHost.ResetStartTime();
              return VccCommandLineHost.Felt2Cast2Plugin("testcase", options, hostEnvironment, assem);
        }
Example #20
0
 public static int RunTestSuite(VccOptions commandLineOptions)
 {
     return commandLineOptions.FileNames.Count(fileName => !RunTestSuite(fileName, commandLineOptions));
 }
Example #21
0
   //TODO: pass in information about which assemblies belong to which named unit sets
   internal VccModule(IName name, string location, ISourceEditHost hostEnvironment, VccOptions options, IAssembly containingAssembly,
 IEnumerable<IAssemblyReference> assemblyReferences, IEnumerable<IModuleReference> moduleReferences, IEnumerable<CompilationPart> compilationParts)
       : base(name, location, containingAssembly, assemblyReferences, moduleReferences)
   {
       this.options = options;
         this.hostEnvironment = hostEnvironment;
         this.compilationParts = compilationParts;
   }
Example #22
0
        static void RunPlugin(VccOptions commandLineOptions)
        {
            // TODO: process comments

              bool errorsInPreprocessor;

              var processedFiles = CCompilerHelper.Preprocess(commandLineOptions, out errorsInPreprocessor);
              if (errorsInPreprocessor)
              {
              errorCount++;
              return;
              }
              using (var fnEnum = commandLineOptions.FileNames.GetEnumerator())
              using (var ppEnum = processedFiles.GetEnumerator())
            while (fnEnum.MoveNext() && ppEnum.MoveNext())
              RunPlugin(fnEnum.Current, ppEnum.Current, commandLineOptions);

              if (fileErrorCount > 0) errorCount++;
        }
Example #23
0
 private static void RunPlugin(string fileName, StreamReader instream, VccOptions commandLineOptions)
 {
     HostEnvironment hostEnvironment = new HostEnvironment(commandLineOptions.PointerSize);
       hostEnvironment.Errors += new CciErrorHandler(commandLineOptions).HandleErrors;
       IName assemName = hostEnvironment.NameTable.GetNameFor(Path.GetFileNameWithoutExtension(fileName));
       IName docName = hostEnvironment.NameTable.GetNameFor(Path.GetFileName(fileName));
       List<IAssemblyReference> assemblyReferences = new List<IAssemblyReference>();
       List<IModuleReference> moduleReferences = new List<IModuleReference>();
       assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity));
       assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.VccRuntimeAssemblyIdentity));
       List<VccSourceDocument> programSources = new List<VccSourceDocument>(1);
       VccAssembly assem = new VccAssembly(assemName, Path.GetFullPath(fileName), hostEnvironment, commandLineOptions, assemblyReferences, moduleReferences, programSources);
       VccCompilationHelper helper = new VccCompilationHelper(assem.Compilation);
       programSources.Add(new VccSourceDocument(helper, docName, Path.GetFullPath(fileName), instream));
       if (0 != Felt2Cast2Plugin(fileName, commandLineOptions, hostEnvironment, assem))
       {
       fileErrorCount++;
       }
 }
Example #24
0
        private static void VerifyFunctions(VccOptions commandLineOptions, string fileName, string baseName, FunctionVerifier fver)
        {
            double beforeBoogie = GetTime();
              int numErrors = 0;
              double beforeMethods = GetTime();
              bool checkSpecificFunctions = commandLineOptions.ExplicitTargetsGiven;
              List<string> foundFunctionSpecifiers = new List<string>();

              if (commandLineOptions.DumpBoogie)
              {
            fver.DumpInternalsToFile(baseName, true);
              }

              foreach (var func in fver.FunctionsToVerify())
              {

            if (checkSpecificFunctions)
            {
              // check if this function has been requested either specifically or by prefix
              bool checkThisFunction = false;
              if (commandLineOptions.FunctionsWithExactName.Contains(func.Item2))
              {
            checkThisFunction = true;
            foundFunctionSpecifiers.Add(func.Item2);
              }
              if (!checkThisFunction)
              {
            foreach (var fn in commandLineOptions.Functions)
            {
              var normalized = fn.Replace(':', '#');
              if (func.Item2.StartsWith(normalized) &&
                   (normalized.Length == func.Item2.Length || func.Item2[normalized.Length] == '#'))
              {
                checkThisFunction = true;
                foundFunctionSpecifiers.Add(fn);
                break;
              }
            }
              }
              if (!checkThisFunction) continue;
            }
            else if (commandLineOptions.IgnoreIncludes != null)
            {
              bool fileFound = false;
              if (commandLineOptions.IgnoreIncludes == "")
              {
            if (commandLineOptions.FileNames.Any(file => String.Equals(file, func.Item1, StringComparison.OrdinalIgnoreCase)))
            {
              fileFound = true;
            }
              } else if (String.Equals(Path.GetFullPath(commandLineOptions.IgnoreIncludes), func.Item1, StringComparison.OrdinalIgnoreCase))
              {
            fileFound = true;
              }

              if (!fileFound) continue;
            }

            var outcome = fver.Verify(func.Item2);
            //verificationErrorHandler.FlushErrors();

            if (commandLineOptions.DumpBoogie) {
              fver.DumpInternalsToFile(baseName, false);
            }

            if (outcome == VerificationResult.Succeeded || outcome == VerificationResult.Skipped) { } else { numErrors++; }
              }

              if (checkSpecificFunctions)
              {
            List<string> functionSpecifiers = new List<string>();
            functionSpecifiers.AddRange(commandLineOptions.Functions);
            functionSpecifiers.AddRange(commandLineOptions.FunctionsWithExactName);
            // some functions have not been encountered; warn about those
            foreach (var fn in functionSpecifiers)
            {
              if (!foundFunctionSpecifiers.Contains(fn))
              {
            Logger.Instance.Error("'{0}' did not match any function.", fn);
            errorCount++;
              }
            }
              }

              fver.Close();
              double now = GetTime();

              var timerInfo =
            commandLineOptions.TimeStats ?
              new[] {
            Tuple.Create("total", now - startTime),
            Tuple.Create("compiler", beforeBoogie - startTime),
            Tuple.Create("boogie", beforeMethods - beforeBoogie),
            Tuple.Create("verification", now - beforeMethods)
            }
            : null;

            Logger.Instance.LogFileSummary(fileName, numErrors, timerInfo);
        }
Example #25
0
 public VccOptionWrapper(VccOptions options)
 {
     this.options = options;
 }
Example #26
0
        static bool RunTestSuite(string fileName, VccOptions commandLineOptions)
        {
            if (File.Exists(fileName))
              {
            return TestRunner.RunTestSuite(new FileInfo(fileName), commandLineOptions);
              }

              string baseDir;
              string fileSpec;

              if (Directory.Exists(fileName)) {
            baseDir = fileName;
            fileSpec = "*";
              } else {

            baseDir = Path.GetDirectoryName(fileName);
            if (string.IsNullOrEmpty(baseDir)) baseDir = ".";
            fileSpec = Path.GetFileName(fileName);
            if (string.IsNullOrEmpty(fileSpec)) fileSpec = "*";
              }

              int errorCount = 0;
              int threads = NumThreads(commandLineOptions.RunTestSuiteMultiThreaded);
              TestRunnerMT trmt = threads > 1 ? new TestRunnerMT(threads, commandLineOptions) : null;

              foreach (FileInfo fi in new DirectoryInfo(baseDir).GetFiles(fileSpec, SearchOption.TopDirectoryOnly))
              {
            if (fi.Name.StartsWith(".")) continue;
            if (fi.Name.Contains(vccSplitSuffix)) continue;
            if (fi.Extension != ".c" && fi.Extension != "")
              continue;

            if (trmt != null) trmt.Queue(fi);
            else
            {
              if (!TestRunner.RunTestSuite(fi, commandLineOptions))
            errorCount++;
            }
              }

              if (trmt != null)
              {
            if (firstFile)
            {
              firstFile = false;
              if (File.Exists("testsuite.log"))
            File.Delete("testsuite.log");
            }
            errorCount += trmt.Run();
              }

              foreach (DirectoryInfo di in new DirectoryInfo(baseDir).GetDirectories(fileSpec, SearchOption.TopDirectoryOnly))
              {
            if (di.Name.StartsWith(".")) continue;
            RunTestSuite(di.FullName, commandLineOptions);
              }

              if (errorCount != 0)
              {
            Logger.Instance.NewLine();
            Logger.Instance.Error("*** {0} error(s) ***", errorCount);
            Logger.Instance.NewLine();
            return false;
              }

              return true;
        }