Пример #1
0
int main() {
  for(int j=0;j < 3; j++) {
    VC vc = vc_createValidityChecker();
    vc_setFlags(vc,'n');
    vc_setFlags(vc,'d');
    vc_setFlags(vc,'p');
    vc_setFlags(vc,'x');
    
    Type bv8 = vc_bvType(vc, 8);
    Expr a =  vc_bvCreateMemoryArray(vc, "a");
    Expr index_3 = vc_bvConstExprFromLL(vc, 32, 3);

    Expr a_of_0 = vc_readExpr(vc, a, index_3);
    int i;
    for (i = 2; i >= 0; i--)
      a_of_0 = vc_bvConcatExpr(vc,
			       a_of_0,
			       vc_readExpr(vc, a,
					   vc_bvConstExprFromInt(vc, 32, i)));
    Expr cast_32_to_8 = vc_bvExtract(vc, a_of_0, 7, 0);
    Expr cast_8_to_32 = vc_bvSignExtend(vc, cast_32_to_8, 32);
    vc_printExpr(vc, cast_8_to_32);
    cast_8_to_32 = vc_simplify(vc, cast_8_to_32);
    vc_Destroy(vc);
  }
}
Пример #2
0
int main() {
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc,'n');
  vc_setFlags(vc,'d');
  vc_setFlags(vc,'p');
  vc_setFlags(vc,'m');

  Expr q;
  Expr asserts;

  
  const char* s =       "(benchmark fg.smt\n"
			":logic QF_AUFBV\n"
			":extrafuns ((x_32 BitVec[32]))\n"
			":extrafuns ((y32 BitVec[32]))\n"
			":assumption true\n)\n";

  vc_parseMemExpr(vc,s,&q,&asserts); 
  
  vc_printExpr(vc, q);
  vc_printExpr(vc, asserts);
  printf("\n");

  vc_Destroy(vc);
  return 0;
}
Пример #3
0
TEST(multiple_queries,one) {
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc,'n');
  vc_setFlags(vc,'c');
  vc_setFlags(vc,'d');
  vc_setFlags(vc,'p');

  Type bv8 = vc_bvType(vc, 8);

  Expr a = vc_varExpr(vc, "a", bv8);
  Expr ct_0 = vc_bvConstExprFromInt(vc, 8, 0);

  Expr a_eq_0 = vc_eqExpr(vc, a, ct_0);

  /* Query 1 */
  vc_push(vc);
  int query = vc_query(vc, a_eq_0);
  vc_pop(vc);
  printf("query = %d\n", query);

  /* Query 2 */
  Expr a_neq_0 = vc_notExpr(vc, a_eq_0);
  vc_push(vc);
  query = vc_query(vc, a_neq_0);
  vc_pop(vc);
  printf("query = %d\n", query);

  vc_Destroy(vc);
  ASSERT_TRUE(false && "FIXME: Actually test something");
}
Пример #4
0
TEST(push_pop, two)
{
  VC vc = vc_createValidityChecker();
  //vc_setFlags(vc, 'n');
  vc_setFlags(vc, 'd');
  //vc_setFlags(vc, 'p');
  //vc_setFlags(vc, 'v');
  //vc_setFlags(vc, 's');
  vc_setFlags(vc, 'c');
  vc_push(vc);

  Type bv8 = vc_bvType(vc, 8);

  Expr a = vc_varExpr(vc, "a", bv8);
  Expr ct_0 = vc_bvConstExprFromInt(vc, 8, 0);

  Expr a_eq_0 = vc_eqExpr(vc, a, ct_0);

  vc_assertFormula(vc, a_eq_0);
  vc_printAsserts(vc);
  vc_push(vc);

  Expr queryexp = vc_eqExpr(vc, a, vc_bvConstExprFromInt(vc, 8, 0));
  //vc_printExpr(vc, queryexp);

  int query;
  query = vc_query(vc, queryexp);
  vc_printCounterExample(vc);
  vc_pop(vc);
  vc_pop(vc);

  ASSERT_TRUE(query);
}
Пример #5
0
TEST(getbv, INT64)
{
  ASSERT_EQ(64, sizeof(uint64_t) * 8);

  for (uint64_t j = 1; j < UINT64_MAX; j |= (j << 1))
  {
    VC vc = vc_createValidityChecker();
    ASSERT_NE(vc, (void*)0);
    vc_setFlags(vc, 'n');
    vc_setFlags(vc, 'd');
    vc_setFlags(vc, 'p');
    vc_setFlags(vc, 'x');

    Type bv8 = vc_bvType(vc, 8); // Why do we need this?
    ASSERT_NE(bv8, (void*)0);

    Expr a = vc_bvCreateMemoryArray(vc, "a"); // Why do we need this?
    ASSERT_NE(a, (void*)0);
    Expr index_3 = vc_bvConstExprFromLL(vc, 64, j);
    ASSERT_NE(index_3, (void*)0);

    uint64_t print_index = getBVUnsignedLongLong(index_3);
    ASSERT_EQ(print_index, j);
    vc_DeleteExpr(a);
    vc_DeleteExpr(index_3);
    vc_Destroy(vc);
  }
}
Пример #6
0
int main() {
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc,'n');
  vc_setFlags(vc,'c');
  vc_setFlags(vc,'d');
  vc_setFlags(vc,'p');

  Type bv8 = vc_bvType(vc, 8);

  Expr a = vc_varExpr(vc, "a", bv8);
  Expr ct_0 = vc_bvConstExprFromInt(vc, 8, 0);

  Expr a_eq_0 = vc_eqExpr(vc, a, ct_0);

  /* Query 1 */
  vc_push(vc);
  int query = vc_query(vc, a_eq_0);
  vc_pop(vc);
  printf("query = %d\n", query);

  /* Query 2 */
  Expr a_neq_0 = vc_notExpr(vc, a_eq_0);
  vc_push(vc);
  query = vc_query(vc, a_neq_0);
  vc_pop(vc);
  printf("query = %d\n", query);

  vc_Destroy(vc);
  return 0;
}
Пример #7
0
TEST(getbv, INT32)
{
  ASSERT_EQ(32, sizeof(int32_t) * 8);

  for (uint32_t j = 1; j < UINT32_MAX; j |= (j << 1))
  {
    VC vc = vc_createValidityChecker();
    ASSERT_NE(vc, (void*)0);
    vc_setFlags(vc, 'n');
    vc_setFlags(vc, 'd');
    vc_setFlags(vc, 'p');
    vc_setFlags(vc, 'x');

    Type bv8 = vc_bvType(vc, 8);
    ASSERT_NE(bv8, (void*)0);

    Expr a = vc_bvCreateMemoryArray(vc, "a"); // Why do we need this?
    ASSERT_NE(a, (void*)0);

    Expr index_3 = vc_bvConstExprFromInt(vc, 32, j);
    ASSERT_NE(index_3, (void*)0);

    uint32_t print_index = getBVUnsignedLongLong(index_3);
    ASSERT_EQ(print_index, j);
    vc_DeleteExpr(a);
    // vc_DeleteExpr(index_3); - Urgh... STP's C API is inconsistent regarding
    // what we should delete ourselves and what vc_Destroy() will do for us.
    vc_Destroy(vc);
  }
}
Пример #8
0
int main(int argc, char *argv[]) {
  VC vc = vc_createValidityChecker();
  vc_setFlags('n');
  vc_setFlags('d');
  vc_setFlags('p');
  
  Expr nresp1 = vc_varExpr(vc, "nresp1", vc_bv32Type(vc));
  Expr packet_get_int0 = vc_varExpr(vc, "packet_get_int0", vc_bv32Type(vc));
  Expr exprs[] = {
    // nresp1 == packet_get_int0
    vc_eqExpr(vc, nresp1, packet_get_int0),
    // nresp1 > 0
    vc_bvGtExpr(vc, nresp1, vc_bv32ConstExprFromInt(vc, 0))
  };
  
  Expr res = vc_andExprN(vc, exprs, sizeof(exprs)/sizeof(exprs[0]));
  vc_printExpr(vc, res);
  
  int x = vc_query(vc, res);
  printf("vc_query result = %d\n", x);
  vc_printCounterExample(vc);
  
  Expr cex = vc_getCounterExample(vc, res);
  //vc_printExpr(vc, cex);
}
Пример #9
0
TEST(push_pop, one)
{
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc, 'n');
  vc_setFlags(vc, 'd');
  vc_setFlags(vc, 'p');
  // vc_setFlags(vc,'v');
  // vc_setFlags(vc,'s');

  Type bv8 = vc_bvType(vc, 8);

  Expr a = vc_varExpr(vc, "a", bv8);
  Expr ct_0 = vc_bvConstExprFromInt(vc, 8, 0);

  Expr a_eq_0 = vc_eqExpr(vc, a, ct_0);

  int query = vc_query(vc, a_eq_0);
  printf("query = %d\n", query);

  vc_push(vc);
  query = vc_query(vc, a_eq_0);
  vc_pop(vc);

  printf("query = %d\n", query);

  vc_DeleteExpr(a_eq_0);
  vc_DeleteExpr(a);

  vc_Destroy(vc);
  // FIXME: Actually test something
  // ASSERT_TRUE(false && "FIXME: Actually test something");
}
Пример #10
0
int main() {  
  VC vc = vc_createValidityChecker();
  vc_setFlags('n');
  vc_setFlags('d');
  //vc_setFlags('p');
  
  Type bv8 = vc_bvType(vc, 8);

  Expr a =  vc_bvCreateMemoryArray(vc, "a");  
 
  Expr index_3 = vc_bvConstExprFromInt(vc, 32, 3);

  Expr a_of_0 = vc_readExpr(vc, a, index_3);
  int i;
  for (i = 2; i >= 0; i--)
    a_of_0 = vc_bvConcatExpr(vc,
			     a_of_0,
			     vc_readExpr(vc, a, 
					 vc_bvConstExprFromInt(vc, 32, i)));
  
 
  Expr ct_5 = vc_bvConstExprFromInt(vc, 32, 5);
  Expr a_of_0_div_5 = vc_bvDivExpr(vc, 32, a_of_0, ct_5);
  
  Expr a_of_0_div_5_eq_5 = vc_eqExpr(vc, a_of_0_div_5, ct_5);
  vc_printExpr(vc, a_of_0_div_5_eq_5); printf("\n");
  
  /* Query 1 */
  vc_push(vc);
  int query = vc_query(vc, a_of_0_div_5_eq_5);
  vc_pop(vc);
  printf("query = %d\n", query);

  vc_assertFormula(vc, a_of_0_div_5_eq_5);
  vc_printExpr(vc, a_of_0_div_5_eq_5);
  
  /* query(false) */
  vc_push(vc);
  query = vc_query(vc, vc_falseExpr(vc));
  vc_pop(vc);
  printf("query = %d\n", query);
  assert(!query);
  
  assert(vc_counterexample_size(vc));
  
  int* a_val = (int*) malloc(sizeof *a_val);
  char *p = (char*) a_val;
  //a_of_1 = vc_simplify(vc, a_of_1);  // BUG here
  for (i=0; i<=3; i++) {
    Expr elem = vc_readExpr(vc, a, vc_bvConstExprFromInt(vc, 32, i));
    Expr ce = vc_getCounterExample(vc, elem);
    unsigned long long v = getBVUnsigned(ce);
    fprintf(stderr, "a[%d] = %ld\n", i, v);
    *p = v; p++;
  }
  printf("a = %d\n", *a_val);
  assert((*a_val)/5  == 5);

  vc_Destroy(vc);
}
Пример #11
0
int main() {
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc,'n');
  vc_setFlags(vc,'d');
  vc_setFlags(vc,'p');

  Expr ct_3 = vc_bvConstExprFromStr(vc,
"00000000000000000000000000000011");
  vc_printExpr(vc, ct_3);  printf("\n");

  ct_3 = vc_bvConstExprFromInt(vc, 32, 5);
  vc_printExpr(vc, ct_3);  printf("\n");

  vc_Destroy(vc);
}
Пример #12
0
TEST(parsefile,CVC) {
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc,'n');
  vc_setFlags(vc,'d');
  vc_setFlags(vc,'p');

  // CVC_FILE is a macro that expands to a file path
  Expr c = vc_parseExpr(vc, CVC_FILE);
  // FIXME: We shouldn't trigger an exit on failure. Libraries DON'T DO THAT!
  
  vc_printExpr(vc, c);
  vc_DeleteExpr(c);
  printf("\n");
  vc_Destroy(vc);
  ASSERT_TRUE(false && "FIXME: We should actually test something!");
}
Пример #13
0
TEST(push_pop, one)
{
  VC vc = vc_createValidityChecker();
  //vc_setFlags(vc, 'n');
  vc_setFlags(vc, 'd');
  //vc_setFlags(vc, 'p');
  // vc_setFlags(vc,'v');
  // vc_setFlags(vc,'s');

  Type bv8 = vc_bvType(vc, 8);

  Expr a = vc_varExpr(vc, "a", bv8);
  Expr ct_0 = vc_bvConstExprFromInt(vc, 8, 0);

  Expr a_eq_0 = vc_eqExpr(vc, a, ct_0);

  int query = vc_query(vc, a_eq_0);
  ASSERT_FALSE(query);

  vc_push(vc);
  query = vc_query(vc, a_eq_0);
  ASSERT_FALSE(query);
  vc_pop(vc);

  vc_DeleteExpr(a_eq_0);
  vc_DeleteExpr(a);

  vc_Destroy(vc);
}
Пример #14
0
// FIXME: this test name sucks!
TEST(x,one) {
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc,'n');
  vc_setFlags(vc,'d');
  vc_setFlags(vc,'p'); 
 
  Expr nresp1 = vc_varExpr(vc, "nresp1", vc_bv32Type(vc));
  Expr packet_get_int0 = vc_varExpr(vc, "packet_get_int0", vc_bv32Type(vc));
  Expr sz = vc_varExpr(vc, "sz", vc_bv32Type(vc));

  Expr d0,d1,d2;
  Expr exprs[] = {
    // nresp1 == packet_get_int0
    vc_eqExpr(vc, nresp1, packet_get_int0),
    
    // nresp1 > 0
    vc_bvGtExpr(vc, nresp1, vc_bv32ConstExprFromInt(vc, 0)),
    
    // sz == nresp1 * 4
    vc_eqExpr(vc, sz, d0=vc_bv32MultExpr(vc, nresp1, vc_bv32ConstExprFromInt(vc, 4))),
    
    // sz > nresp1 || sz < 0
    vc_orExpr(vc, d1=vc_sbvGeExpr(vc, sz, nresp1), d2=vc_sbvLtExpr(vc, sz, vc_bv32ConstExprFromInt(vc, 0))),
  };
  
  Expr res = vc_andExprN(vc, exprs, sizeof(exprs)/sizeof(exprs[0]));
  //vc_printExpr(vc, res);
  vc_query(vc,res);

  vc_DeleteExpr(nresp1);
  vc_DeleteExpr(packet_get_int0);
  vc_DeleteExpr(sz);

  vc_DeleteExpr(d0);
  vc_DeleteExpr(d1);
  vc_DeleteExpr(d2);

  vc_DeleteExpr(exprs[0]);
  vc_DeleteExpr(exprs[1]);
  vc_DeleteExpr(exprs[2]);
  vc_DeleteExpr(exprs[3]);
  vc_DeleteExpr(res);

  vc_Destroy(vc);
  // FIXME: Actually test something
  //ASSERT_TRUE(false && "FIXME: Actually test something");
}
Пример #15
0
TEST(print,one) {
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc,'n');
  vc_setFlags(vc,'d');
  vc_setFlags(vc,'p');

  Expr ct_3 = vc_bvConstExprFromStr(vc,
"00000000000000000000000000000011");
  vc_printExpr(vc, ct_3);  printf("\n");

  ct_3 = vc_bvConstExprFromInt(vc, 32, 5);
  vc_printExpr(vc, ct_3);  printf("\n");

  vc_Destroy(vc);
  // FIXME: Actually test something
  //ASSERT_TRUE(false && "FIXME: Actually test something");
}
Пример #16
0
int main() {  
  VC vc = vc_createValidityChecker();
  vc_setFlags('n');
  vc_setFlags('d');
  //vc_setFlags('p');
  
  Type bv8 = vc_bvType(vc, 8);

  Expr a =  vc_bvCreateMemoryArray(vc, "a");  
 
  Expr index_1 = vc_bvConstExprFromInt(vc, 32, 1);
  Expr a_of_1 = vc_readExpr(vc, a, index_1);  
 
  Expr ct_100 = vc_bvConstExprFromInt(vc, 8, 100);
  Expr a_of_1_eq_100 = vc_eqExpr(vc, a_of_1, ct_100);

  /* Query 1 */  
  vc_push(vc);
  int query = vc_query(vc, a_of_1_eq_100);
  vc_pop(vc);
  printf("query = %d\n", query);

  vc_assertFormula(vc, a_of_1_eq_100);
  
  /* query(false) */
  vc_push(vc);
  query = vc_query(vc, vc_falseExpr(vc));
  vc_pop(vc);
  printf("query = %d\n", query);
  
  if (vc_counterexample_size(vc) == 0) {
    printf("Counterexample size is 0\n");
    exit(1);
  }
      
  a_of_1 = vc_simplify(vc, a_of_1);  
  //vc_printExpr(vc, a_of_1);
  Expr ce = vc_getCounterExample(vc, a_of_1);
  unsigned long long v = getBVUnsigned(ce);
  
  fprintf(stderr, "a[1] = %ld\n", v);

  vc_Destroy(vc);
}
Пример #17
0
TEST(parsefile,missing_file) {
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc,'n');
  vc_setFlags(vc,'d');
  vc_setFlags(vc,'p');

  const char* nonExistantFile="./iShOuLdNoTExiSt.cvc";
  std::ifstream file(nonExistantFile, std::ifstream::in);
  ASSERT_FALSE( file.good() ); // Check the file does not exist

  Expr c = vc_parseExpr(vc, nonExistantFile);
  // FIXME: We shouldn't trigger an exit on failure. Libraries DON'T DO THAT!
  
  vc_printExpr(vc, c);
  vc_DeleteExpr(c);
  printf("\n");
  vc_Destroy(vc);
  ASSERT_TRUE(false && "FIXME: We should actually test something!");
}
Пример #18
0
int main() {
  for(int j=0;j < 3; j++) {
    VC vc = vc_createValidityChecker();
    vc_setFlags(vc,'n');
    vc_setFlags(vc,'d');
    vc_setFlags(vc,'p');
    vc_setFlags(vc,'x');
    
    Type bv8 = vc_bvType(vc, 8);
    Expr a =  vc_bvCreateMemoryArray(vc, "a");    
    Expr index_3 = vc_bvConstExprFromLL(vc, 64, 0xf0000000effff000LL);
    unsigned long long int print_index = getBVUnsignedLongLong(index_3);
    printf("testing getBVUnsignedLongLong function: %llx \n", print_index);
    printf("\n");
    vc_DeleteExpr(a);
    vc_DeleteExpr(index_3);
    vc_Destroy(vc);
  }
}
Пример #19
0
TEST(stp_counterex,one) {  
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc,'n');
  vc_setFlags(vc,'d');
  //vc_setFlags(vc,'p');
  
  Type bv8 = vc_bvType(vc, 8);

  Expr a =  vc_bvCreateMemoryArray(vc, "a");  
 
  Expr index_1 = vc_bvConstExprFromInt(vc, 32, 1);
  Expr a_of_1 = vc_readExpr(vc, a, index_1);  
 
  Expr ct_100 = vc_bvConstExprFromInt(vc, 8, 100);
  Expr a_of_1_eq_100 = vc_eqExpr(vc, a_of_1, ct_100);

  /* Query 1 */  
  vc_push(vc);
  int query = vc_query(vc, a_of_1_eq_100);
  vc_pop(vc);
  printf("query = %d\n", query);

  vc_assertFormula(vc, a_of_1_eq_100);
  
  /* query(false) */
  vc_push(vc);
  query = vc_query(vc, vc_falseExpr(vc));
  vc_pop(vc);
  printf("query = %d\n", query);
  
  ASSERT_FALSE(vc_counterexample_size(vc) == 0);
      
  a_of_1 = vc_simplify(vc, a_of_1);  
  //vc_printExpr(vc, a_of_1);
  Expr ce = vc_getCounterExample(vc, a_of_1);
  unsigned long long v = getBVUnsigned(ce);
  
  fprintf(stderr, "a[1] = %llu\n", v);

  vc_Destroy(vc);
  // FIXME: we should test more things!
}
Пример #20
0
TEST(extend_adder_notexpr, one)
{

  VC vc = vc_createValidityChecker();
  vc_setFlags(vc, 'n');
  vc_setFlags(vc, 'd');

  // 8-bit variable 'x'
  Expr x = vc_varExpr(vc, "x", vc_bvType(vc, 8));

  // 32 bit constant value 1
  Expr one = vc_bvConstExprFromInt(vc, 32, 1);

  // 24 bit constant value 0
  Expr bit24_zero = vc_bvConstExprFromInt(vc, 24, 0);
  // 32 bit constant value 0
  Expr bit32_zero = vc_bvConstExprFromInt(vc, 32, 0);

  // Extending 8-bit variable to 32-bit value
  Expr zero_concat_x = vc_bvConcatExpr(vc, bit24_zero, x);
  Expr xp1 = vc_bvPlusExpr(vc, 32, zero_concat_x, one);

  // Insteading of concat operation, I also tried with SignExtend
  // Expr signextend_x=vc_bvSignExtend(vc,x,32);
  // Expr xp1=vc_bvPlusExpr(vc,32,signextend_x,one);

  // x+1=0
  Expr eq = vc_eqExpr(vc, xp1, bit32_zero);

  // x+1!=0
  eq = vc_notExpr(vc, eq);

  vc_query(vc, eq);
  vc_printCounterExample(vc);
  // FIXME: Actually test something
  // ASSERT_TRUE(false && "FIXME: Actually test something");
}
Пример #21
0
//Create a validity Checker. This is the global BeevMgr
VC vc_createValidityChecker(void) {
  vc_setFlags('d');
#ifdef NATIVE_C_ARITH
#else
  CONSTANTBV::ErrCode c = CONSTANTBV::BitVector_Boot(); 
  if(0 != c) {
    cout << CONSTANTBV::BitVector_Error(c) << endl;
    return 0;
  }
#endif
  bmstar bm = new BEEV::BeevMgr();
  decls = new BEEV::ASTVec();
  //created_exprs.clear();
  return (VC)bm;
}
Пример #22
0
TEST(sbdiv, one)
{
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc, 'p');

  Type int_type = vc_bv32Type(vc);
  Expr zero = vc_bv32ConstExprFromInt(vc, 0);
  Expr int_max = vc_bvConstExprFromInt(vc, 32, 0x7fffffff);
  Expr a = vc_varExpr(vc, "a", int_type);
  Expr b = vc_varExpr(vc, "b", int_type);
  vc_assertFormula(vc, vc_sbvGtExpr(vc, b, zero));
  vc_assertFormula(vc, vc_sbvLeExpr(vc, a, vc_sbvDivExpr(vc, 32, int_max, b)));
  std::cout << vc_query(vc, vc_falseExpr(vc)) << std::endl;
  // FIXME: Actually test something
  // ASSERT_TRUE(false && "FIXME: Actually test something");
}
Пример #23
0
Файл: sbvdiv.cpp Проект: stp/stp
TEST(sbdiv, one)
{
  VC vc = vc_createValidityChecker();
  //vc_setFlags(vc, 'p');
  vc_setFlags(vc, 'd');

  Type int_type = vc_bv32Type(vc);
  Expr zero = vc_bv32ConstExprFromInt(vc, 0);
  Expr int_max = vc_bvConstExprFromInt(vc, 32, 0x7fffffff);
  Expr a = vc_varExpr(vc, "a", int_type);
  Expr b = vc_varExpr(vc, "b", int_type);
  vc_assertFormula(vc, vc_sbvGtExpr(vc, b, zero));
  vc_assertFormula(vc, vc_sbvLeExpr(vc, a, vc_sbvDivExpr(vc, 32, int_max, b)));
  int query = vc_query(vc, vc_falseExpr(vc));
  ASSERT_FALSE(query);
}
Пример #24
0
TEST(push_pop, two)
{
  VC vc = vc_createValidityChecker();
  vc_setFlags(vc, 'n');
  vc_setFlags(vc, 'd');
  vc_setFlags(vc, 'p');
  vc_setFlags(vc, 'v');
  vc_setFlags(vc, 's');
  vc_setFlags(vc, 'c');
  vc_push(vc);

  Type bv8 = vc_bvType(vc, 8);

  Expr a = vc_varExpr(vc, "a", bv8);
  Expr ct_0 = vc_bvConstExprFromInt(vc, 8, 0);

  Expr a_eq_0 = vc_eqExpr(vc, a, ct_0);

  int query;
  // query = vc_query(vc, a_eq_0);
  // printf("query = %d\n", query);

  Expr a_neq_0 = vc_notExpr(vc, a_eq_0);
  vc_assertFormula(vc, a_eq_0);
  vc_printAsserts(vc);
  vc_push(vc);

  Expr queryexp = vc_eqExpr(vc, a, vc_bvConstExprFromInt(vc, 8, 0));
  vc_printExpr(vc, queryexp);

  query = vc_query(vc, queryexp);
  vc_printCounterExample(vc);
  vc_pop(vc);
  vc_pop(vc);

  printf("query = %d\n", query);
  // FIXME: Actually test something
  // ASSERT_TRUE(false && "FIXME: Actually test something");
}
Пример #25
0
// FIXME: Needs better name
TEST(Leaks, leak)
{
  for (int i = 0; i < 10; i++)
  {

    VC vc;
    vc = vc_createValidityChecker();
    vc_setFlags(vc, 'n');
    vc_setFlags(vc, 'd');
    vc_setFlags(vc, 'p');

    // create 50 expression
    Expr a1 = vc_varExpr(vc, "a1", vc_bv32Type(vc));
    Expr a2 = vc_varExpr(vc, "a2", vc_bv32Type(vc));
    Expr a3 = vc_varExpr(vc, "a3", vc_bv32Type(vc));
    Expr a4 = vc_varExpr(vc, "a4", vc_bv32Type(vc));
    Expr a5 = vc_varExpr(vc, "a5", vc_bv32Type(vc));
    Expr a6 = vc_varExpr(vc, "a6", vc_bv32Type(vc));
    Expr a7 = vc_varExpr(vc, "a7", vc_bv32Type(vc));
    Expr a8 = vc_varExpr(vc, "a8", vc_bv32Type(vc));
    Expr a9 = vc_varExpr(vc, "a9", vc_bv32Type(vc));
    Expr a10 = vc_varExpr(vc, "a10", vc_bv32Type(vc));
    Expr a11 = vc_varExpr(vc, "a11", vc_bv32Type(vc));
    Expr a12 = vc_varExpr(vc, "a12", vc_bv32Type(vc));
    Expr a13 = vc_varExpr(vc, "a13", vc_bv32Type(vc));
    Expr a14 = vc_varExpr(vc, "a14", vc_bv32Type(vc));
    Expr a15 = vc_varExpr(vc, "a15", vc_bv32Type(vc));
    Expr a16 = vc_varExpr(vc, "a16", vc_bv32Type(vc));
    Expr a17 = vc_varExpr(vc, "a17", vc_bv32Type(vc));
    Expr a18 = vc_varExpr(vc, "a18", vc_bv32Type(vc));
    Expr a19 = vc_varExpr(vc, "a19", vc_bv32Type(vc));
    Expr a20 = vc_varExpr(vc, "a20", vc_bv32Type(vc));
    Expr a21 = vc_varExpr(vc, "a21", vc_bv32Type(vc));
    Expr a22 = vc_varExpr(vc, "a22", vc_bv32Type(vc));
    Expr a23 = vc_varExpr(vc, "a23", vc_bv32Type(vc));
    Expr a24 = vc_varExpr(vc, "a24", vc_bv32Type(vc));
    Expr a25 = vc_varExpr(vc, "a25", vc_bv32Type(vc));
    Expr a26 = vc_varExpr(vc, "a26", vc_bv32Type(vc));
    Expr a27 = vc_varExpr(vc, "a27", vc_bv32Type(vc));
    Expr a28 = vc_varExpr(vc, "a28", vc_bv32Type(vc));
    Expr a29 = vc_varExpr(vc, "a29", vc_bv32Type(vc));
    Expr a30 = vc_varExpr(vc, "a30", vc_bv32Type(vc));
    Expr a31 = vc_varExpr(vc, "a31", vc_bv32Type(vc));
    Expr a32 = vc_varExpr(vc, "a32", vc_bv32Type(vc));
    Expr a33 = vc_varExpr(vc, "a33", vc_bv32Type(vc));
    Expr a34 = vc_varExpr(vc, "a34", vc_bv32Type(vc));
    Expr a35 = vc_varExpr(vc, "a35", vc_bv32Type(vc));
    Expr a36 = vc_varExpr(vc, "a36", vc_bv32Type(vc));
    Expr a37 = vc_varExpr(vc, "a37", vc_bv32Type(vc));
    Expr a38 = vc_varExpr(vc, "a38", vc_bv32Type(vc));
    Expr a39 = vc_varExpr(vc, "a39", vc_bv32Type(vc));
    Expr a40 = vc_varExpr(vc, "a40", vc_bv32Type(vc));
    Expr a41 = vc_varExpr(vc, "a41", vc_bv32Type(vc));
    Expr a42 = vc_varExpr(vc, "a42", vc_bv32Type(vc));
    Expr a43 = vc_varExpr(vc, "a43", vc_bv32Type(vc));
    Expr a44 = vc_varExpr(vc, "a44", vc_bv32Type(vc));
    Expr a45 = vc_varExpr(vc, "a45", vc_bv32Type(vc));
    Expr a46 = vc_varExpr(vc, "a46", vc_bv32Type(vc));
    Expr a47 = vc_varExpr(vc, "a47", vc_bv32Type(vc));
    Expr a48 = vc_varExpr(vc, "a48", vc_bv32Type(vc));
    Expr a49 = vc_varExpr(vc, "a49", vc_bv32Type(vc));
    Expr a50 = vc_varExpr(vc, "a50", vc_bv32Type(vc));

    vc_DeleteExpr(a1);
    vc_DeleteExpr(a2);
    vc_DeleteExpr(a3);
    vc_DeleteExpr(a4);
    vc_DeleteExpr(a5);
    vc_DeleteExpr(a6);
    vc_DeleteExpr(a7);
    vc_DeleteExpr(a8);
    vc_DeleteExpr(a9);
    vc_DeleteExpr(a10);
    vc_DeleteExpr(a11);
    vc_DeleteExpr(a12);
    vc_DeleteExpr(a13);
    vc_DeleteExpr(a14);
    vc_DeleteExpr(a15);
    vc_DeleteExpr(a16);
    vc_DeleteExpr(a17);
    vc_DeleteExpr(a18);
    vc_DeleteExpr(a19);
    vc_DeleteExpr(a20);
    vc_DeleteExpr(a21);
    vc_DeleteExpr(a22);
    vc_DeleteExpr(a23);
    vc_DeleteExpr(a24);
    vc_DeleteExpr(a25);
    vc_DeleteExpr(a26);
    vc_DeleteExpr(a27);
    vc_DeleteExpr(a28);
    vc_DeleteExpr(a29);
    vc_DeleteExpr(a30);
    vc_DeleteExpr(a31);
    vc_DeleteExpr(a32);
    vc_DeleteExpr(a33);
    vc_DeleteExpr(a34);
    vc_DeleteExpr(a35);
    vc_DeleteExpr(a36);
    vc_DeleteExpr(a37);
    vc_DeleteExpr(a38);
    vc_DeleteExpr(a39);
    vc_DeleteExpr(a40);
    vc_DeleteExpr(a41);
    vc_DeleteExpr(a42);
    vc_DeleteExpr(a43);
    vc_DeleteExpr(a44);
    vc_DeleteExpr(a45);
    vc_DeleteExpr(a46);
    vc_DeleteExpr(a47);
    vc_DeleteExpr(a48);
    vc_DeleteExpr(a49);
    vc_DeleteExpr(a50);

    vc_Destroy(vc);
  }
}