Example #1
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);
  }
}
Example #2
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);
  }
}
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);
  }
}
Example #4
0
TEST(Leaks, sqaures)
{
  unsigned int i;

  /* Do some simple arithmetic by creating an expression involving
     constants and then simplifying it. Since we create and destroy
     a fresh VC each time, we shouldn't leak any memory. */
  for (i = 1; i <= 100; i++)
  {
    VC vc = vc_createValidityChecker();
    Expr arg = vc_bvConstExprFromLL(vc, 64, (unsigned long long)i);
    Expr product = vc_bvMultExpr(vc, 64, arg, arg);
    Expr simp = vc_simplify(vc, product);
    unsigned long long j = getBVUnsignedLongLong(simp);
    vc_DeleteExpr(arg);
    vc_DeleteExpr(product);
    vc_DeleteExpr(simp);
    if (i % 10000 == 0)
      printf("%u**2 = %llu\n", i, j);
    vc_Destroy(vc);
  }
}