Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var baseDiskPath   = @"C:\Temp\";
            var baseCosmosPath = "https://cosmos15.osdinfra.net/cosmos/dsa.email.segmentation/local/users/MeritDirect/Product/";

            foreach (var streamPath in GetStreamsRecurse(baseCosmosPath, new Regex(@"\.txt$")))
            //foreach (var streamPath in GetStreamsRecurse(baseCosmosPath, new Regex(@"OneStore_Order_VID_2019.*\.txt$")))
            {
                //var relativeStreamPath = streamPath.Replace(baseCosmosPath, string.Empty);
                //var fullCosmosPath = Path.Combine(baseCosmosPath, relativeStreamPath);
                var uri = new Uri(streamPath);
                var relativeStreamPath = uri.Segments[uri.Segments.Length - 1];

                /*
                 * var fullDiskPath = Path.Combine(baseDiskPath, relativeStreamPath);
                 *
                 * var directory = Path.GetDirectoryName(fullDiskPath);
                 * if (!Directory.Exists(directory))
                 * {
                 *   Directory.CreateDirectory(directory);
                 * }
                 */
                VC.Download(streamPath, baseDiskPath + relativeStreamPath, true, DownloadMode.OverWrite);
            }
        }
Ejemplo n.º 2
0
    public static int Main()
    {
        VC vc = new VC();
        vc.x = 5;

        return test(vc);
    }
Ejemplo n.º 3
0
 public Order1 SaveOrderCon1(Order1 ord)
 {
     try
     {
         Global obj_g = new Global();
         if (ord.FDName == "" || ord.FDName == null || ord.FDName == "ORDR")
         {
             ord.FDName = "ORDR";
             if (ord.series == "" || ord.series == null)
             {
                 VC objVC = gbc_con.Db_vc.Where(p => p.FDNAME == "ORDR").Take(1).SingleOrDefault();
                 if (objVC == null)
                 {
                     ord.series = "O2";
                 }
                 else
                 {
                     ord.series = objVC.SER;
                 }
             }
         }
         return(obj_g.SaveOrder1(ord));
     }
     catch (Exception ex)
     {
         Order1 ord1 = new Order1();
         ord1.pcode = ex.Message + " Inner Exception Message " + ex.InnerException.InnerException.ToString().Split('\n')[0].ToString();
         return(ord1);
     }
 }
Ejemplo n.º 4
0
        public static void DeleteCosmosDirectoryFiles(string directoryName, bool recursive = false)
        {
            if (string.IsNullOrEmpty(directoryName))
            {
                return;
            }

            directoryName = directoryName.TrimEnd(new char[] { '/' });

            List <StreamInfo> streamInfos = null;

            try
            {
                streamInfos = VC.GetDirectoryInfo(directoryName, false);
            }
            catch (VcClientException)
            {
                // the directory doens't exist
            }

            if (streamInfos != null)
            {
                foreach (StreamInfo streamInfo in streamInfos)
                {
                    if (streamInfo.IsDirectory && recursive)
                    {
                        DeleteCosmosDirectoryFiles(streamInfo.StreamName, recursive);
                    }
                    else if (!streamInfo.IsDirectory)
                    {
                        DeleteCosmosFile(streamInfo);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public async Task RemoveAndAddDefaultVC(IGuild guild)
        {
            foreach (IVoiceChannel VC in await guild.GetVoiceChannelsAsync())
            {
                await VC.DeleteAsync();
            }

            int    numberOfUsers            = guild.GetUsersAsync().Result.Count;
            double defaultVoiceChannelCount = Math.Max(Math.Round(numberOfUsers / 10.0), 2.0);

            for (; defaultVoiceChannelCount > 0; defaultVoiceChannelCount--)
            {
                await guild.CreateVoiceChannelAsync("Lobby");
            }

            await guild.CreateVoiceChannelAsync("Watchin");

            IVoiceChannel afkChan = await guild.CreateVoiceChannelAsync("AFK");

            void ChangeAFKChan(GuildProperties properties) => properties.AfkChannel = new Optional <IVoiceChannel>(afkChan);

            Action <GuildProperties> modifyAFK = new Action <GuildProperties>(ChangeAFKChan);

            await guild.ModifyAsync(modifyAFK);

            foreach (IVoiceChannel VC in guild.GetVoiceChannelsAsync().Result)
            {
                await UpdateVC(VC);
            }
        }
        private static IEnumerable <string> GetStreamsRecurse(string baseDirectory, Regex regex, int recurseDir)
        {
            List <StreamInfo> streams = null;

            int      maxRetryAttempts     = 5;
            TimeSpan pauseBetweenFailures = TimeSpan.FromSeconds(2);

            RetryHelper.RetryOnException(maxRetryAttempts, pauseBetweenFailures, () =>
            {
                streams = VC.GetDirectoryInfo(baseDirectory, false);
            });
            foreach (var streamInfo in streams)
            {
                var uri = new Uri(streamInfo.StreamName);
                if (recurseDir == 1 && streamInfo.IsDirectory)
                {
                    foreach (var subStream in GetStreamsRecurse(streamInfo.StreamName, regex, recurseDir))
                    {
                        yield return(subStream);
                    }
                }
                else if (!streamInfo.IsDirectory && regex.IsMatch(uri.Segments[uri.Segments.Length - 1]))
                {
                    yield return(streamInfo.StreamName);
                }
            }
        }
Ejemplo n.º 7
0
        public static Dependencies Analyze(Program prog, Dependencies deps, Implementation impl)
        {
            string origProcName = impl.FindStringAttribute(RefineConsts.checkDepAttribute);
            //get the procedure's guard constants
            var inputGuardConsts = prog.TopLevelDeclarations.OfType <Constant>()
                                   .Where(x => Utils.AttributeUtils.GetAttributeVals(x.Attributes, RefineConsts.readSetGuradAttribute).Exists(p => (p as string) == origProcName))
                                   .ToList();
            var outputGuardConsts = prog.TopLevelDeclarations.OfType <Constant>()
                                    .Where(x => Utils.AttributeUtils.GetAttributeVals(x.Attributes, RefineConsts.modSetGuradAttribute).Exists(p => (p as string) == origProcName))
                                    .ToList();

            //---- generate VC starts ---------
            //following unsatcoreFromFailures.cs/PerformRootcauseWorks or EqualityFixes.cs/PerformRootCause in Rootcause project
            //typecheck the instrumented program
            prog.Resolve();
            prog.Typecheck();

            //Generate VC
            VC.InitializeVCGen(prog);
            VCExpr programVC = VC.GenerateVC(prog, impl);

            //---- generate VC ends ---------

            //Analyze using UNSAT cores for each output
            //Dependencies deps = new Dependencies();
            Console.WriteLine("RefinedDependency[{0}] = [", origProcName);
            outputGuardConsts.Iter(x => AnalyzeDependencyWithUnsatCore(programVC, x, deps, origProcName, inputGuardConsts, outputGuardConsts));
            Console.WriteLine("]");
            VC.FinalizeVCGen(prog);

            return(deps);
        }
Ejemplo n.º 8
0
        public static Stream ReadStream(string streamPath)
        {
            var certificate = CertificateGenerator.GetCertificateByThumbprint();

            VC.Setup(null, certificate);
            return(VC.ReadStream(streamPath, true));
        }
Ejemplo n.º 9
0
 public HttpResponseMessage SaveOrderCon(Order ord)
 {
     try
     {
         Global obj_g = new Global();
         if (ord.FDName == "" || ord.FDName == null || ord.FDName == "ORDR")
         {
             ord.FDName = "ORDR";
             if (ord.series == "" || ord.series == null)
             {
                 VC objVC = gbc_con.Db_vc.Where(p => p.FDNAME == "ORDR").Take(1).SingleOrDefault();
                 if (objVC == null)
                 {
                     ord.series = "O2";
                 }
                 else
                 {
                     ord.series = objVC.SER;
                 }
             }
         }
         return(Request.CreateResponse(HttpStatusCode.OK, obj_g.SaveOrder(ord)));
     }
     catch (Exception ex)
     {
         Order ord1 = new Order();
         ord1.pcode = ex.Message + " Inner Exception Message " + ex.InnerException.InnerException.ToString().Split('\n')[0].ToString();
         return(Request.CreateResponse(HttpStatusCode.OK, ord1));
     }
 }
Ejemplo n.º 10
0
 public bool HitInRadius(Point aMp)
 {
     if (VC.Distance(aMp, Pos.AsPoint) > 20)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 11
0
    public static int Main()
    {
        VC vc = new VC();

        vc.x = 5;

        return(test(vc));
    }
Ejemplo n.º 12
0
        // Function VcClient.VC.StreamExists(string streamName) just can check the existance of file not directory.
        public static bool CheckStreamExists(string streamPath)
        {
            var certificate = CertificateGenerator.GetCertificateByThumbprint();

            VC.Setup(null, certificate);

            // Function VC.StreamExists will return false if the input is path of a directory.
            return(VC.StreamExists(streamPath));
        }
Ejemplo n.º 13
0
 public void IncrementEpochAndVC()
 {
     Epoch = VC.Tick(Mid);
     Assert(VC.GetComponent(Mid) == Epoch, "Epoch and VC inconsistent!");
     if (EnableLogging)
     {
         Logger.WriteLine($"<VCLog> Updated {VC.ToString()} for {Mid} [Increment]");
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Upload a file to the VC using the method overload which will preserve line boundaries on large files.
        /// </summary>
        /// <param name="source">Path to the local file.</param>
        /// <param name="dest">Desired stream location.</param>
        /// <param name="expiryDays">Expiry in days (if null, will use default of 30 days).</param>
        public static void UploadFile(string source, string dest, int?expiryDays = null)
        {
            var certificate = CertificateGenerator.GetCertificateByThumbprint();

            VC.Setup(null, certificate);
            var fi = new FileInfo(source);

            VC.Upload(source, dest, 0, fi.Length, false, TimeSpan.FromDays(expiryDays ?? 30), false);
        }
Ejemplo n.º 15
0
        // We can use VcClient.VC.DirectoryExists(string directoryName) to check the existance of directory.
        public static bool CheckDirectoryExists(string directoryPath)
        {
            var certificate = CertificateGenerator.GetCertificateByThumbprint();

            VC.Setup(null, certificate);

            // Function VC.DirectoryExists will return true if the input is path of a directory.
            // The input parameter name is directoryName, same as StreamInfo.StreamName . It is just the path.
            return(VC.DirectoryExists(directoryPath));
        }
Ejemplo n.º 16
0
 public void JoinEpochAndVC(VectorClock other)
 {
     VC.Max(other);
     Epoch = this.VC.GetComponent(this.Mid);
     Assert(VC.GetComponent(Mid) == Epoch, "Epoch and VC inconsistent!");
     if (EnableLogging)
     {
         Logger.WriteLine($"<VCLog> Updated {VC.ToString()} for {Mid} [Join {other.ToString()}]");
     }
 }
Ejemplo n.º 17
0
 public void JoinThenIncrement(VectorClock other)
 {
     JoinEpochAndVC(other);
     IncrementEpochAndVC();
     Assert(VC.GetComponent(Mid) == Epoch, "Epoch and VC inconsistent!");
     if (EnableLogging)
     {
         Logger.WriteLine($"<VCLog> Updated {VC.ToString()} for {Mid}");
     }
 }
Ejemplo n.º 18
0
        } //end Main

        /*
         * private static IEnumerable<string> GetStreamsRecurse(string baseDirectory, Regex regex)
         * {
         *  foreach (var streamInfo in VC.GetDirectoryInfo(baseDirectory, true))
         *  {
         *      if (streamInfo.IsDirectory)
         *      {
         *          foreach (var subStream in GetStreamsRecurse(streamInfo.StreamName, regex))
         *          {
         *              yield return subStream;
         *          }
         *      }
         *      else if (regex.IsMatch(streamInfo.StreamName))
         *      {
         *          yield return streamInfo.StreamName;
         *      }
         *  }
         * }
         */
        private static IEnumerable <string> GetDirectories(string baseDirectory)
        {
            foreach (var streamInfo in VC.GetDirectoryInfo(baseDirectory, true))
            {
                if (streamInfo.IsDirectory)
                {
                    yield return(streamInfo.StreamName);
                }
            }
        }
Ejemplo n.º 19
0
    public static int test(VC vc)
    {
        if (vc.x == 5)
        {
            Console.WriteLine("PASS");
            return(100);
        }

        Console.WriteLine("FAIL");
        return(0);
    }
Ejemplo n.º 20
0
            public bool Changed(DateTime since, DateTime now)
            {
                if (timestamp > since)
                {
                    return(true);
                }

                timestamp = VC.GetStreamInfo("https://cosmos08.osdinfra.net/cosmos/Knowledge/" + path, false).PublishedUpdateTime;

                return(timestamp > since);
            }
Ejemplo n.º 21
0
    public static int test(VC vc)
    {
        if (vc.x == 5)
        {
            Console.WriteLine("PASS");
            return 100;
        }

        Console.WriteLine("FAIL");
        return 0;
    }
Ejemplo n.º 22
0
 public static bool DirectoryExists(string directoryPath)
 {
     try
     {
         VC.GetDirectoryInfo(directoryPath, false);
         return(true);
     }
     catch (VcClientException)
     {
         return(false);
     }
 }
Ejemplo n.º 23
0
        public TableItem ParseFilePath(int index, string inpath)
        {
            string    VC_path = "https://cosmos08.osdinfra.net/cosmos/bingads.algo.incubation";
            TableItem res_table;

            if (inpath.IndexOf(".ss") == inpath.Length - 3)
            {
                Stream stream = Factory.VCClientStreamFactory.OpenReadOnlyStream(VC_path + inpath);
                SStreamPlusColumnGroup.IStreamMetadataReader streamMetadataReader = Factory.CreateStreamMetadataReader();
                streamMetadataReader.Open(stream, VC_path + inpath);
                StructuredStream.StructuredStreamSchema sstreamSchema = streamMetadataReader.Metadata.Schema;
                List <string> table_name = new List <string>();
                List <string> col_name   = new List <string>();
                List <string> col_type   = new List <string>();

                table_name.Add("( SSTREAM @inpath" + index.ToString() + " )");
                List <ColumnInfo> col_list = sstreamSchema.ScopeSchema.Columns.ToList();
                for (int i = 0; i <= col_list.Count - 1; i++)
                {
                    col_name.Add(col_list[i].Name.ToString());
                    col_type.Add(col_list[i].Type.ToString().ToLower());
                }
                res_table = new TableItem(table_name, col_name, col_type);
            }
            else
            {
                //VcWrapper vc = new VcWrapper();
                //VcWrapper VC = new VcWrapper();
                Stream stream2 = VC.ReadStream(VC_path + inpath, 0, 1000, true);
                using (StreamReader reader = new StreamReader(stream2))
                {
                    int           currentRow = 0;
                    List <string> table_name = new List <string>();
                    List <string> col_name   = new List <string>();
                    List <string> col_type   = new List <string>();
                    table_name.Add("@inpath" + index.ToString());
                    while (!reader.EndOfStream && currentRow < 2)
                    {
                        currentRow++;
                        string   line  = reader.ReadLine();
                        string[] parts = line.Split(new string[] { "\t" }, StringSplitOptions.None);
                        for (int i = 0; i <= parts.Length - 1; i++)
                        {
                            col_name.Add("column_" + i.ToString());
                            col_type.Add(DataTypeIdentifier.IdentifyToDataType(parts[i]).ToLower());
                        }
                    }
                    res_table = new TableItem(table_name, col_name, col_type);
                }
            }
            return(res_table);
        }
Ejemplo n.º 24
0
        static void SetupAadCredentials(string vc)
        {
            // If you need to use Cosmos TEST clusters such as https://cosmostaurus.osdinfra.net/, please have a look at AadDogFoodHelper.cs.
            string MY_DOCUMENTS = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); //Save token in app path
                                                                                                                               //string MY_DOCUMENTS = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            string TOKEN_CACHE_PATH = System.IO.Path.Combine(MY_DOCUMENTS, "my.tokencache");
            var    tokenCache       = GetTokenCache(TOKEN_CACHE_PATH);
            var    cred             = AadCredentialHelper.GetCredentialFromPrompt(tokenCache);

            //VC.SetupAadCredentials(null, null, cred);
            //VC.SetupAadCredentials("https://cosmos15.osdinfra.net/cosmos/dsa.email.segmentation", null, cred);
            VC.SetupAadCredentials(vc, null, cred);
        }
Ejemplo n.º 25
0
 public MachineState(ulong id, ILogger logger, bool enableLogging)
 {
     this.VC            = new VectorClock(0);
     this.Mid           = (long)id;
     this.Logger        = logger;
     this.EnableLogging = enableLogging;
     this.IncrementEpochAndVC();  // initialize
     Assert(VC.GetComponent(Mid) == Epoch, "Epoch and VC inconsistent!");
     if (EnableLogging)
     {
         Logger.WriteLine($"<VCLog> Created {VC.ToString()} for {Mid}");
     }
 }
Ejemplo n.º 26
0
        protected string WriteVC(VC value)
        {
            switch (_container.DeviceViewportSpecificationMode)
            {
            case DeviceViewportSpecificationMode.Mode.MM:
            case DeviceViewportSpecificationMode.Mode.PHYDEVCOORD:
                return(WriteInt(value.ValueInt));

            case DeviceViewportSpecificationMode.Mode.FRACTION:
            default:
                return(WriteReal(value.ValueReal));
            }
        }
Ejemplo n.º 27
0
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Constructor.  Initialize a checker with the program and log file.
        /// Optionally, use prover context provided by parameter "ctx". 
        /// </summary>
        public Checker(VC.ConditionGeneration vcgen, Program prog, string/*?*/ logFilePath, bool appendLogFile, int timeout, ProverContext ctx = null)
        {
            Contract.Requires(vcgen != null);
              Contract.Requires(prog != null);
              this.timeout = timeout;
              this.Program = prog;

              ProverOptions options = cce.NonNull(CommandLineOptions.Clo.TheProverFactory).BlankProverOptions();

              if (logFilePath != null) {
            options.LogFilename = logFilePath;
            if (appendLogFile)
              options.AppendLogFile = appendLogFile;
              }

              if (timeout > 0) {
            options.TimeLimit = timeout * 1000;
              }

              options.Parse(CommandLineOptions.Clo.ProverOptions);

              ContextCacheKey key = new ContextCacheKey(prog);
              ProverInterface prover;

              if (vcgen.CheckerCommonState == null) {
            vcgen.CheckerCommonState = new Dictionary<ContextCacheKey, ProverContext>();
              }
              IDictionary<ContextCacheKey, ProverContext>/*!>!*/ cachedContexts = (IDictionary<ContextCacheKey, ProverContext/*!*/>)vcgen.CheckerCommonState;

              if (ctx == null && cachedContexts.TryGetValue(key, out ctx))
              {
            ctx = (ProverContext)cce.NonNull(ctx).Clone();
            prover = (ProverInterface)
              CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx);
              } else {
            if (ctx == null) ctx = (ProverContext)CommandLineOptions.Clo.TheProverFactory.NewProverContext(options);

            Setup(prog, ctx);

            // we first generate the prover and then store a clone of the
            // context in the cache, so that the prover can setup stuff in
            // the context to be cached
            prover = (ProverInterface)
              CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx);
            cachedContexts.Add(key, cce.NonNull((ProverContext)ctx.Clone()));
              }

              this.thmProver = prover;
              this.gen = prover.VCExprGen;
        }
Ejemplo n.º 28
0
        private void WriteVc(VC data)
        {
            switch (_cgm.DeviceViewportSpecificationMode)
            {
            case DeviceViewportSpecificationMode.Mode.MM:
            case DeviceViewportSpecificationMode.Mode.PHYDEVCOORD:
                WriteInt(data.ValueInt);
                break;

            default:
                WriteReal(data.ValueReal);
                break;
            }
        }
Ejemplo n.º 29
0
    public RequestMessage visaCheckoutAuthRequest()
    {
        RequestMessage request = new RequestMessage();

        request.getVisaCheckoutDataService     = new GETVisaCheckoutDataService();
        request.getVisaCheckoutDataService.run = "true";
        request.merchantReferenceCode          = "visacheckoutemssail09";
        request.paymentSolution = "visacheckout";
        VC vc = new VC();

        vc.orderID = "1541325474577083201";
        request.vc = vc;

        return(request);
    }
Ejemplo n.º 30
0
        public static List <JToken> GetStreamInfos(string directoryPath)
        {
            var certificate = CertificateGenerator.GetCertificateByThumbprint();

            VC.Setup(null, certificate);

            List <JToken>     streamInfoJTokens = new List <JToken>();
            List <StreamInfo> streamInfos       = VC.GetDirectoryInfo(directoryPath, true);

            foreach (var streamInfo in streamInfos)
            {
                streamInfoJTokens.Add(JToken.Parse(JsonConvert.SerializeObject(streamInfo)));
            }
            return(streamInfoJTokens);
        }
Ejemplo n.º 31
0
        public void Service(bool forceUpdate = false)
        {
            if (lastValueSeqNum != ValueSeqNum || forceUpdate)
            {
                SetValue(ValueSeqNumPropertyKey, lastValueSeqNum = ValueSeqNum);
                SetValue(VCPropertyKey, VC);
                SetValue(VCasSMLStringPropertyKey, VCasSMLString = VC.ToStringSML());
            }

            if (lastMetaDataSeqNum != MetaDataSeqNum || forceUpdate)
            {
                SetValue(MetaDataSeqNumPropertyKey, lastMetaDataSeqNum = MetaDataSeqNum);
                SetValue(MetaDataPropertyKey, MetaData);
            }
        }
Ejemplo n.º 32
0
 public void OnLoad()
 {
     Loading           = true;
     LoadIndex         = -1;
     FinalText         = "";
     FinalChoices      = new List <Choice>();
     FinalEventChoices = new List <EventChoice>();
     foreach (TextBlock TB in Blocks)
     {
         if (TB.Active())
         {
             FinalText += TB.Content;
         }
     }
     foreach (Choice C in Choices)
     {
         if (C.Active())
         {
             FinalChoices.Add(C);
         }
     }
     foreach (EventChoice EC in EventChoices)
     {
         if (EC.Active())
         {
             FinalEventChoices.Add(EC);
         }
     }
     foreach (VariableChange VC in Changes)
     {
         VC.Process();
     }
     CurrentDelay = GetDelay() * 0.25f;
     CommandCheck();
     IndexCheck();
     foreach (UnitEffect UE in Effects)
     {
         UE.Effect();
     }
     foreach (NextUnitOverride NUO in Overrides)
     {
         if (NUO.Active())
         {
             NextUnit = NUO.GetUnit();
             break;
         }
     }
 }
Ejemplo n.º 33
0
 static IEnumerable <string> GetStreamsRecurse(string baseDirectory, Regex regex)
 {
     foreach (var streamInfo in VC.GetDirectoryInfo(baseDirectory, true))
     {
         if (streamInfo.IsDirectory)
         {
             foreach (var subStream in GetStreamsRecurse(streamInfo.StreamName, regex))
             {
                 yield return(subStream);
             }
         }
         else if (regex.IsMatch(streamInfo.StreamName))
         {
             yield return(streamInfo.StreamName);
         }
     }
 }
Ejemplo n.º 34
0
    private static void ReportOutcome(VC.VCGen.Outcome outcome, ErrorReporterDelegate er, string implName, IToken implTok, string requestId, TextWriter tw, int timeLimit, List<Counterexample> errors)
    {
      ErrorInformation errorInfo = null;

      switch (outcome)
      {
        case VCGen.Outcome.ReachedBound:
          tw.WriteLine(string.Format("Stratified Inlining: Reached recursion bound of {0}", CommandLineOptions.Clo.RecursionBound));
          break;
        case VCGen.Outcome.Errors:
        case VCGen.Outcome.TimedOut:
          if (implName != null && implTok != null)
          {
            if (outcome == ConditionGeneration.Outcome.TimedOut || (errors != null && errors.Any(e => e.IsAuxiliaryCexForDiagnosingTimeouts)))
            {
              errorInfo = errorInformationFactory.CreateErrorInformation(implTok, string.Format("Verification of '{1}' timed out after {0} seconds", timeLimit, implName), requestId);
            }

            //  Report timed out assertions as auxiliary info.
            if (errors != null)
            {
              var cmpr = new CounterexampleComparer();
              var timedOutAssertions = errors.Where(e => e.IsAuxiliaryCexForDiagnosingTimeouts).Distinct(cmpr).ToList();
              timedOutAssertions.Sort(cmpr);
              if (0 < timedOutAssertions.Count)
              {
                errorInfo.Msg += string.Format(" with {0} check(s) that timed out individually", timedOutAssertions.Count);
              }
              foreach (Counterexample error in timedOutAssertions)
              {
                var callError = error as CallCounterexample;
                var returnError = error as ReturnCounterexample;
                var assertError = error as AssertCounterexample;
                IToken tok = null;
                string msg = null;
                if (callError != null)
                {
                  tok = callError.FailingCall.tok;
                  msg = callError.FailingCall.ErrorData as string ?? "A precondition for this call might not hold.";
                }
                else if (returnError != null)
                {
                  tok = returnError.FailingReturn.tok;
                  msg = "A postcondition might not hold on this return path.";
                }
                else
                {
                  tok = assertError.FailingAssert.tok;
                  if (assertError.FailingAssert is LoopInitAssertCmd)
                  {
                    msg = "This loop invariant might not hold on entry.";
                  }
                  else if (assertError.FailingAssert is LoopInvMaintainedAssertCmd)
                  {
                    msg = "This loop invariant might not be maintained by the loop.";
                  }
                  else
                  {
                    msg = assertError.FailingAssert.ErrorData as string;
                    if (!CommandLineOptions.Clo.ForceBplErrors && assertError.FailingAssert.ErrorMessage != null)
                    {
                      msg = assertError.FailingAssert.ErrorMessage;
                    }
                    if (msg == null)
                    {
                      msg = "This assertion might not hold.";
                    }
                  }
                }
                errorInfo.AddAuxInfo(tok, msg, "Unverified check due to timeout");
              }
            }
          }
          break;
        case VCGen.Outcome.OutOfMemory:
          if (implName != null && implTok != null)
          {
            errorInfo = errorInformationFactory.CreateErrorInformation(implTok, "Verification out of memory (" + implName + ")", requestId);
          }
          break;
        case VCGen.Outcome.Inconclusive:
          if (implName != null && implTok != null)
          {
            errorInfo = errorInformationFactory.CreateErrorInformation(implTok, "Verification inconclusive (" + implName + ")", requestId);
          }
          break;
      }

      if (errorInfo != null)
      {
        errorInfo.ImplementationName = implName;
        if (er != null)
        {
          lock (er)
          {
            er(errorInfo);
          }
        }
        else
        {
          printer.WriteErrorInformation(errorInfo, tw);
        }
      }
    }
Ejemplo n.º 35
0
 public void PrintSummary(VC.ConditionGeneration.Outcome outcome, string addInfo = null)
 {
     if (!this.outcomeReported) {
     this.outcomeReported = true;
     this.errorHandler.ReportOutcomeMethodSummary(this.name, this.tok, outcome, addInfo, this.startTime, this.proverWarnings);
       }
 }
Ejemplo n.º 36
0
 public abstract VC.ConditionGeneration.Outcome VerifyImpl(TransHelper.TransEnv env, VC.VCGen vcgen, Implementation impl, Program prog, VerifierCallback reporter);
Ejemplo n.º 37
0
        private static void UpdateStatistics(PipelineStatistics stats, VC.VCGen.Outcome outcome, List<Counterexample> errors, bool wasCached)
        {
            Contract.Requires(stats != null);

              switch (outcome)
              {
            default:
              Contract.Assert(false);  // unexpected outcome
              throw new cce.UnreachableException();
            case VCGen.Outcome.ReachedBound:
              Interlocked.Increment(ref stats.VerifiedCount);
              if (wasCached) { Interlocked.Increment(ref stats.CachedVerifiedCount); }
              break;
            case VCGen.Outcome.Correct:
              Interlocked.Increment(ref stats.VerifiedCount);
              if (wasCached) { Interlocked.Increment(ref stats.CachedVerifiedCount); }
              break;
            case VCGen.Outcome.TimedOut:
              Interlocked.Increment(ref stats.TimeoutCount);
              if (wasCached) { Interlocked.Increment(ref stats.CachedTimeoutCount); }
              break;
            case VCGen.Outcome.OutOfMemory:
              Interlocked.Increment(ref stats.OutOfMemoryCount);
              if (wasCached) { Interlocked.Increment(ref stats.CachedOutOfMemoryCount); }
              break;
            case VCGen.Outcome.Inconclusive:
              Interlocked.Increment(ref stats.InconclusiveCount);
              if (wasCached) { Interlocked.Increment(ref stats.CachedInconclusiveCount); }
              break;
            case VCGen.Outcome.Errors:
              if (CommandLineOptions.Clo.vcVariety == CommandLineOptions.VCVariety.Doomed)
              {
            Interlocked.Increment(ref stats.ErrorCount);
            if (wasCached) { Interlocked.Increment(ref stats.CachedErrorCount); }
              }
              else
              {
            Interlocked.Add(ref stats.ErrorCount, errors.Count);
            if (wasCached) { Interlocked.Add(ref stats.CachedErrorCount, errors.Count); }
              }
              break;
              }
        }
Ejemplo n.º 38
0
        private static void ReportOutcome(VC.VCGen.Outcome outcome, ErrorReporterDelegate er, string implName, IToken implTok, string requestId, TextWriter tw, int timeLimit, List<Counterexample> errors)
        {
            ErrorInformation errorInfo = null;

              switch (outcome)
              {
            case VCGen.Outcome.ReachedBound:
              tw.WriteLine(string.Format("Stratified Inlining: Reached recursion bound of {0}", CommandLineOptions.Clo.RecursionBound));
              break;
            case VCGen.Outcome.TimedOut:
              if (implName != null && implTok != null)
              {
            errorInfo = errorInformationFactory.CreateErrorInformation(implTok, string.Format("Verification timed out after {0} seconds ({1})", timeLimit, implName), requestId);

            //  Report timed out assertions as auxiliary info.
            if (errors != null)
            {
              var cmpr = new CounterexampleComparer();
              var timedOutAssertions = errors.Where(e => e.IsAuxiliaryCexForDiagnosingTimeouts).Distinct(cmpr).ToList();
              timedOutAssertions.Sort(cmpr);
              int idx = 1;
              foreach (Counterexample error in timedOutAssertions)
              {
                var callError = error as CallCounterexample;
                var returnError = error as ReturnCounterexample;
                var assertError = error as AssertCounterexample;
                IToken tok = null;
                if (callError != null)
                {
                  tok = callError.FailingCall.tok;
                }
                else if (returnError != null)
                {
                  tok = returnError.FailingReturn.tok;
                }
                else
                {
                  tok = assertError.FailingAssert.tok;
                }
                errorInfo.AddAuxInfo(tok, string.Format("unverified assertion due to timeout ({0} of {1})", idx++, timedOutAssertions.Count));
              }
            }
              }
              break;
            case VCGen.Outcome.OutOfMemory:
              if (implName != null && implTok != null)
              {
            errorInfo = errorInformationFactory.CreateErrorInformation(implTok, "Verification out of memory (" + implName + ")", requestId);
              }
              break;
            case VCGen.Outcome.Inconclusive:
              if (implName != null && implTok != null)
              {
            errorInfo = errorInformationFactory.CreateErrorInformation(implTok, "Verification inconclusive (" + implName + ")", requestId);
              }
              break;
              }

              if (errorInfo != null)
              {
            errorInfo.ImplementationName = implName;
            if (er != null)
            {
              lock (er)
              {
            er(errorInfo);
              }
            }
              }
        }
Ejemplo n.º 39
0
        private static void ProcessOutcome(VC.VCGen.Outcome outcome, List<Counterexample> errors, string timeIndication,
            PipelineStatistics stats, TextWriter tw, int timeLimit, ErrorReporterDelegate er = null, string implName = null, IToken implTok = null, string requestId = null, bool wasCached = false)
        {
            Contract.Requires(stats != null);

              UpdateStatistics(stats, outcome, errors, wasCached);

              printer.Inform(timeIndication + OutcomeIndication(outcome, errors), tw);

              ReportOutcome(outcome, er, implName, implTok, requestId, tw, timeLimit, errors);
        }
Ejemplo n.º 40
0
        private static void ProcessErrors(List<Counterexample> errors, VC.VCGen.Outcome outcome, TextWriter tw, ErrorReporterDelegate er, Implementation impl = null)
        {
            var implName = impl != null ? impl.Name : null;

              if (errors != null)
              {
            errors.Sort(new CounterexampleComparer());
            foreach (Counterexample error in errors)
            {
              if (error.IsAuxiliaryCexForDiagnosingTimeouts)
              {
            continue;
              }
              var errorInfo = CreateErrorInformation(error, outcome);
              errorInfo.ImplementationName = implName;

              if (CommandLineOptions.Clo.XmlSink != null)
              {
            WriteErrorInformationToXmlSink(errorInfo, error.Trace);
              }

              if (CommandLineOptions.Clo.EnhancedErrorMessages == 1)
              {
            foreach (string info in error.relatedInformation)
            {
              Contract.Assert(info != null);
              errorInfo.Out.WriteLine("       " + info);
            }
              }
              if (CommandLineOptions.Clo.ErrorTrace > 0)
              {
            errorInfo.Out.WriteLine("Execution trace:");
            error.Print(4, errorInfo.Out, b => { errorInfo.AddAuxInfo(b.tok, b.Label, "Execution trace"); });
              }
              if (CommandLineOptions.Clo.ModelViewFile != null)
              {
            error.PrintModel(errorInfo.Model);
              }

              printer.WriteErrorInformation(errorInfo, tw);

              if (er != null)
              {
            lock (er)
            {
              er(errorInfo);
            }
              }
            }
              }
        }
Ejemplo n.º 41
0
 private static string OutcomeIndication(VC.VCGen.Outcome outcome, List<Counterexample> errors)
 {
     string traceOutput = "";
       switch (outcome)
       {
     default:
       Contract.Assert(false);  // unexpected outcome
       throw new cce.UnreachableException();
     case VCGen.Outcome.ReachedBound:
       traceOutput = "verified";
       break;
     case VCGen.Outcome.Correct:
       traceOutput = (CommandLineOptions.Clo.vcVariety == CommandLineOptions.VCVariety.Doomed ? "credible" : "verified");
       break;
     case VCGen.Outcome.TimedOut:
       traceOutput = "timed out";
       break;
     case VCGen.Outcome.OutOfMemory:
       traceOutput = "out of memory";
       break;
     case VCGen.Outcome.Inconclusive:
       traceOutput = "inconclusive";
       break;
     case VCGen.Outcome.Errors:
       Contract.Assert(errors != null);
       traceOutput = (CommandLineOptions.Clo.vcVariety == CommandLineOptions.VCVariety.Doomed ? "doomed" : string.Format("error{0}", errors.Count == 1 ? "" : "s"));
       break;
       }
       return traceOutput;
 }
Ejemplo n.º 42
0
        private static ErrorInformation CreateErrorInformation(Counterexample error, VC.VCGen.Outcome outcome)
        {
            // BP1xxx: Parsing errors
              // BP2xxx: Name resolution errors
              // BP3xxx: Typechecking errors
              // BP4xxx: Abstract interpretation errors (Is there such a thing?)
              // BP5xxx: Verification errors

              ErrorInformation errorInfo;
              var cause = "Error";
              if (outcome == VCGen.Outcome.TimedOut)
              {
            cause = "Timed out on";
              }
              else if (outcome == VCGen.Outcome.OutOfMemory)
              {
            cause = "Out of memory on";
              }

              var callError = error as CallCounterexample;
              var returnError = error as ReturnCounterexample;
              var assertError = error as AssertCounterexample;
              if (callError != null)
              {
            errorInfo = errorInformationFactory.CreateErrorInformation(callError.FailingCall.tok, callError.FailingCall.ErrorData as string ?? "A precondition for this call might not hold.", callError.RequestId, callError.OriginalRequestId, cause);
            errorInfo.BoogieErrorCode = "BP5002";
            errorInfo.Kind = ErrorKind.Precondition;
            errorInfo.AddAuxInfo(callError.FailingRequires.tok, callError.FailingRequires.ErrorData as string ?? "This is the precondition that might not hold.", "Related location");

            if (!CommandLineOptions.Clo.ForceBplErrors && callError.FailingRequires.ErrorMessage != null)
            {
              errorInfo = errorInformationFactory.CreateErrorInformation(null, callError.FailingRequires.ErrorMessage, callError.RequestId, callError.OriginalRequestId, cause);
            }
              }
              else if (returnError != null)
              {
            errorInfo = errorInformationFactory.CreateErrorInformation(returnError.FailingReturn.tok, "A postcondition might not hold on this return path.", returnError.RequestId, returnError.OriginalRequestId, cause);
            errorInfo.BoogieErrorCode = "BP5003";
            errorInfo.Kind = ErrorKind.Postcondition;
            errorInfo.AddAuxInfo(returnError.FailingEnsures.tok, returnError.FailingEnsures.ErrorData as string ?? "This is the postcondition that might not hold.", "Related location");

            if (!CommandLineOptions.Clo.ForceBplErrors && returnError.FailingEnsures.ErrorMessage != null)
            {
              errorInfo = errorInformationFactory.CreateErrorInformation(null, returnError.FailingEnsures.ErrorMessage, returnError.RequestId, returnError.OriginalRequestId, cause);
            }
              }
              else // error is AssertCounterexample
              {
            if (assertError.FailingAssert is LoopInitAssertCmd)
            {
              errorInfo = errorInformationFactory.CreateErrorInformation(assertError.FailingAssert.tok, "This loop invariant might not hold on entry.", assertError.RequestId, assertError.OriginalRequestId, cause);
              errorInfo.BoogieErrorCode = "BP5004";
              errorInfo.Kind = ErrorKind.InvariantEntry;
            }
            else if (assertError.FailingAssert is LoopInvMaintainedAssertCmd)
            {
              errorInfo = errorInformationFactory.CreateErrorInformation(assertError.FailingAssert.tok, "This loop invariant might not be maintained by the loop.", assertError.RequestId, assertError.OriginalRequestId, cause);
              errorInfo.BoogieErrorCode = "BP5005";
              errorInfo.Kind = ErrorKind.InvariantMaintainance;
            }
            else
            {
              var msg = assertError.FailingAssert.ErrorData as string;
              var tok = assertError.FailingAssert.tok;
              if (!CommandLineOptions.Clo.ForceBplErrors && assertError.FailingAssert.ErrorMessage != null)
              {
            msg = assertError.FailingAssert.ErrorMessage;
            tok = null;
            if (cause == "Error")
            {
              cause = null;
            }
              }
              string bec = null;
              if (msg == null)
              {
            msg = "This assertion might not hold.";
            bec = "BP5001";
              }

              errorInfo = errorInformationFactory.CreateErrorInformation(tok, msg, assertError.RequestId, assertError.OriginalRequestId, cause);
              errorInfo.BoogieErrorCode = bec;
              errorInfo.Kind = ErrorKind.Assertion;
            }
              }

              return errorInfo;
        }
Ejemplo n.º 43
0
        private static void ReportOutcome(VC.VCGen.Outcome outcome, ErrorReporterDelegate er, string implName, IToken implTok, string requestId, TextWriter tw, int timeLimit)
        {
            ErrorInformation errorInfo = null;

              switch (outcome)
              {
            case VCGen.Outcome.ReachedBound:
              tw.WriteLine(string.Format("Stratified Inlining: Reached recursion bound of {0}", CommandLineOptions.Clo.RecursionBound));
              break;
            case VCGen.Outcome.TimedOut:
              if (implName != null && implTok != null)
              {
            errorInfo = errorInformationFactory.CreateErrorInformation(implTok, string.Format("Verification timed out after {0} seconds ({1})", timeLimit, implName), requestId);
              }
              break;
            case VCGen.Outcome.OutOfMemory:
              if (implName != null && implTok != null)
              {
            errorInfo = errorInformationFactory.CreateErrorInformation(implTok, "Verification out of memory (" + implName + ")", requestId);
              }
              break;
            case VCGen.Outcome.Inconclusive:
              if (implName != null && implTok != null)
              {
            errorInfo = errorInformationFactory.CreateErrorInformation(implTok, "Verification inconclusive (" + implName + ")", requestId);
              }
              break;
              }

              if (errorInfo != null)
              {
            errorInfo.ImplementationName = implName;
            if (er != null)
            {
              lock (er)
              {
            er(errorInfo);
              }
            }
              }
        }
Ejemplo n.º 44
0
        public void ReportOutcomeMethodSummary(string methodName, IToken tok, VC.ConditionGeneration.Outcome outcome, string addInfo, double startTime, IEnumerable<string> proverWarnings)
        {
            if (outcome != VC.ConditionGeneration.Outcome.Correct) VccCommandLineHost.IncreaseErrorCount();
              Logger.Instance.LogMethodSummary(methodName, tok.ToLocation(), (Outcome)(int)outcome, addInfo, GetTime() - startTime);

              if (!commandLineOptions.RunTestSuite) {
            foreach (var proverWarning in proverWarnings) {
              Logger.Instance.Warning("Prover warning: {0}", proverWarning);
            }
              }
        }