示例#1
0
        public void GlobalConstantWithWeakerAxiom()
        {
            p = LoadProgramFrom("programs/GlobalConstantWithWeakerAxiom.bpl");
            e = GetExecutor(p);
            e.BreakPointReached += delegate(object executor, Executor.BreakPointEventArgs data)
            {
                Assert.IsTrue(data.Name == "entry");
                var constant = p.TopLevelDeclarations.OfType <Constant>().Where(c => c.Name == "a").First();
                Assert.IsTrue(constant is Constant);
                Assert.IsTrue(e.CurrentState.IsInScopeVariable(constant));
                Assert.IsTrue(e.IsSymbolic(constant));

                // Check for the expected constraint
                bool found = false;
                foreach (Expr constraint in e.CurrentState.Constraints.ConstraintExprs)
                {
                    var asNeq = ExprUtil.AsNotEq(constraint);
                    if (asNeq != null)
                    {
                        var asSymVar = ExprUtil.AsSymbolicVariable(asNeq.Args[0]);
                        Assert.IsNotNull(asSymVar);
                        Assert.IsTrue(asSymVar.Origin.IsVariable && asSymVar.Origin.AsVariable == constant);
                        Assert.IsTrue(asNeq.Args[1] is LiteralExpr && (asNeq.Args[1] as LiteralExpr).asBvConst.Value.ToInt == 7);
                        found = true;
                    }
                }
                Assert.IsTrue(found, "Did not find expected Neq constraint");
            };
            e.Run(GetMain(p));
        }
示例#2
0
        public static IdentifierExpr CheckIsSymbolicIdentifier(Expr e, ExecutionState state)
        {
            var asSym = ExprUtil.AsSymbolicVariable(e);

            Assert.IsNotNull(asSym);

            // FIXME: Find a convenient way to test this
            // Check the state is aware of it too
            // Assert.IsTrue(state.Symbolics.Where(s => s.Expr == identiferForSymbolic).Count() > 0);

            return(asSym.Expr);
        }