Exemplo n.º 1
0
int main() {
  int i = 0;
  int *arrayOne = (int*)malloc(MAXSIZE * sizeof(int));
  int *arrayTwo = (int*)malloc(MAXSIZE * sizeof(int));

  resetArray(arrayOne);
  setArray(arrayTwo);

  for (i = 0; i < MAXSIZE; i++) {
    __SMACK_assert(arrayOne[i] == RESET);
    __SMACK_assert(arrayTwo[i] == SET);
  }

  setArray(arrayOne);
  resetArray(arrayTwo);

  for (i = 0; i < MAXSIZE; i++) {
    __SMACK_assert(arrayOne[i] == SET);
    __SMACK_assert(arrayTwo[i] == RESET);
  }

  free(arrayOne);
  free(arrayTwo);
  return 0;
}
Exemplo n.º 2
0
int main() {
  int i = 0;
  elem *arrayOne;
  elem *arrayTwo;

  __SMACK_assume(arraySize > 0);

  arrayOne = (elem*)malloc(arraySize * sizeof(elem));
  arrayTwo = (elem*)malloc(arraySize * sizeof(elem));

  resetArray(arrayOne);
  setArray(arrayTwo);
  initializeCount(arrayTwo);

  for (i = 0; i < arraySize; i++) {
    __SMACK_assert(arrayOne[i].status == RESET);
    __SMACK_assert(arrayTwo[i].status == SET);
    __SMACK_assert(arrayTwo[i].count == 0);
  }

  initializeCount(arrayOne);
  setArray(arrayOne);
  resetArray(arrayTwo);

  for (i = arraySize - 1; i >= 0; i--) {
    __SMACK_assert(arrayOne[i].count != 0 || arrayOne[i].status != SET || arrayTwo[i].status != RESET);
  }

  free(arrayOne);
  free(arrayTwo);
  return 0;
}
Exemplo n.º 3
0
int main() {
  int *a = (int*)malloc(sizeof(int));
  int *b = (int*)malloc(sizeof(int));

  *a = *b = 0;

  incr(a);
  incr(b);

  __SMACK_assert(*a == 1);
  __SMACK_assert(*b == 1);

  return 0;
}
Exemplo n.º 4
0
int main(void) {
  int a;

  a = 1;
  a = -1;
  __SMACK_assert(a != -1);
  return a;
}
Exemplo n.º 5
0
int main(void) {
  int a;

  a = 1;
  a = incr(a);
  __SMACK_assert(a == 2);
  return a;
}
Exemplo n.º 6
0
int main(void){
  int *x = (int*)malloc(sizeof(int));

  g1 = 3;
  *x = 4;
  g2 = 5;
  __SMACK_assert(g1 == 3 && *x == 4 && g2 == 5);
}
Exemplo n.º 7
0
int main(void) {
  int a;

  a = -1;
  a = returnOne();
  __SMACK_assert(a == 1 || a == 2);
  return a;
}
Exemplo n.º 8
0
int main(void) {
    int x, y, z;

    x = 10;
    y = 20;
    z = x + y;
    __SMACK_assert(z == 30);
    return 0;
}
Exemplo n.º 9
0
void errorFn(void) 
{ 

  {
  goto ERROR;
  ERROR: __SMACK_assert(0);
#line 29
  return;
}
}
Exemplo n.º 10
0
int main() {
  int i = 0;

  x = 0;

  for (i = 0; i < MAXSIZE; i++) {
    x = i;
  }
  __SMACK_assert(x != MAXSIZE - 1);
  return 0;
}
Exemplo n.º 11
0
int main(void) {
  S2* s2 = (S2*)malloc(sizeof(S2));
  S1* s1 = (S1*)s2;

  s2->a = 3;
  s2->b = 5;
  s1->x = 4;

  __SMACK_assert(s2->a == 4);
  return 0;
}
Exemplo n.º 12
0
void free_array() {
  int i;
  DATA a[MAXSIZE];

  for (i = 0; i < MAXSIZE; i++) {
    a[i].f = (int*)malloc(sizeof(int));
    *(a[i].f) = 1;
    a[i].x = 2;
    a[i].y = 3;
  }

  for (i = 0; i < MAXSIZE; i++) {
    __SMACK_assert(*(a[i].f) == 1);
    __SMACK_assert(a[i].x == 2);
    __SMACK_assert(a[i].y == 3);
    if (a[i].f != 0) {
      free(a[i].f);
      a[i].f = 0;
    }
  }
}
Exemplo n.º 13
0
int main() {
  int i = 0;
  elem *arrayOne = (elem*)malloc(MAXSIZE * sizeof(elem));
  elem *arrayTwo = (elem*)malloc(MAXSIZE * sizeof(elem));

  resetArray(arrayOne);
  setArray(arrayTwo);
  initializeCount(arrayTwo);

  for (i = 0; i < MAXSIZE; i++) {
    __SMACK_assert(arrayOne[i].status == RESET);
    __SMACK_assert(arrayTwo[i].status == SET);
    __SMACK_assert(arrayTwo[i].count == 0);
  }

  initializeCount(arrayOne);
  setArray(arrayOne);
  resetArray(arrayTwo);

  for (i = 0; i < MAXSIZE; i++) {
    __SMACK_assert(arrayOne[i].count == 0);
    __SMACK_assert(arrayOne[i].status == SET);
    __SMACK_assert(arrayTwo[i].status == RESET);
  }

  free(arrayOne);
  free(arrayTwo);
  return 0;
}
Exemplo n.º 14
0
int main() {
  int i = 0;
  int *array = (int*)malloc(MAXSIZE * sizeof(int));

  initializeArray(array);

  for (i = 0; i < MAXSIZE; i++) {
    __SMACK_assert(array[i] == RESET);
  }

  free(array);
  return 0;
}
Exemplo n.º 15
0
int main() {
  int i = 0;
  int *a = (int*)malloc(MAXSIZE * sizeof(int));

  for (i = 0; i < MAXSIZE; i++) {
    a[i] = RESET;
  }

  __SMACK_assert(a[5] == RESET);

  free(a);
  return 0;
}
Exemplo n.º 16
0
int main() {
  int i = 0;
  elem *array = (elem*)malloc((MAXSIZE + 1) * sizeof(elem));

  initializeArray(array);

  for (i = 0; i < MAXSIZE + 1; i++) {
    __SMACK_assert(array[i].status == RESET);
  }

  free(array);
  return 0;
}
Exemplo n.º 17
0
int main() {
  int *x = malloc(4);
  int *y = malloc(4);
  int *z;

  foo(y);
  z = bar();

  *x = 1;
  *z = 2;

  __SMACK_assert(x != z);
}
Exemplo n.º 18
0
int main() {
  element elem;

  elem.count = 1;
  elem.count = 2;
  elem.point1.y = 100;
  elem.data = 5;
  elem.point2.x = 200;

  __SMACK_assert(elem.count != 2 || elem.point1.y != 100 || elem.data != 5 || elem.point2.x != 200);

  return 0;
}
Exemplo n.º 19
0
int main() {
  int (*fp)(int);
  int x;

  x = 0;
  if (__SMACK_nondet()) {
    fp = incr;
  } else {
    fp = decr;
  }
  x = fp(x);

  __SMACK_assert(x == 1 || x == -1);

  return 0;
}
Exemplo n.º 20
0
void init(int size) {
  int i;
  Elem *a1 = alloc(size);
  Elem *a2 = alloc(size);

  for (i = 0; i < size; i++) {
    a1[i].f1 = 1;
  }

  for (i = 0; i < size; i++) {
    a1[i].f2 = 0;
    a2[i].f1 = 0;
  }

  for (i = 0; i < size; i++) {
    __SMACK_assert(a1[i].f1 == 1);
  }
}
Exemplo n.º 21
0
void *another(void *my_argument) {
  __SMACK_assert(x > 0); // ERROR: but x was set to 0, so it can't exceed 0
  return 0;
}
Exemplo n.º 22
0
int main()
{
    int p1 = __VERIFIER_nondet_int();  // condition variable
    int lk1; // lock variable

    int p2 = __VERIFIER_nondet_int();  // condition variable
    int lk2; // lock variable

    int p3 = __VERIFIER_nondet_int();  // condition variable
    int lk3; // lock variable

    int p4 = __VERIFIER_nondet_int();  // condition variable
    int lk4; // lock variable

    int p5 = __VERIFIER_nondet_int();  // condition variable
    int lk5; // lock variable

    int p6 = __VERIFIER_nondet_int();  // condition variable
    int lk6; // lock variable

    int p7 = __VERIFIER_nondet_int();  // condition variable
    int lk7; // lock variable

    int p8 = __VERIFIER_nondet_int();  // condition variable
    int lk8; // lock variable

    int p9 = __VERIFIER_nondet_int();  // condition variable
    int lk9; // lock variable

    int p10 = __VERIFIER_nondet_int();  // condition variable
    int lk10; // lock variable

    int p11 = __VERIFIER_nondet_int();  // condition variable
    int lk11; // lock variable

    int p12 = __VERIFIER_nondet_int();  // condition variable
    int lk12; // lock variable


    int cond;

    while(1) {
        cond = __VERIFIER_nondet_int();
        if (cond == 0) {
            goto out;
        } else {}
        lk1 = 0; // initially lock is open

        lk2 = 0; // initially lock is open

        lk3 = 0; // initially lock is open

        lk4 = 0; // initially lock is open

        lk5 = 0; // initially lock is open

        lk6 = 0; // initially lock is open

        lk7 = 0; // initially lock is open

        lk8 = 0; // initially lock is open

        lk9 = 0; // initially lock is open

        lk10 = 0; // initially lock is open

        lk11 = 0; // initially lock is open

        lk12 = 0; // initially lock is open


    // lock phase
        if (p1 != 0) {
            lk1 = 1; // acquire lock
        } else {}

        if (p2 != 0) {
            lk2 = 1; // acquire lock
        } else {}

        if (p3 != 0) {
            lk3 = 1; // acquire lock
        } else {}

        if (p4 != 0) {
            lk4 = 1; // acquire lock
        } else {}

        if (p5 != 0) {
            lk5 = 1; // acquire lock
        } else {}

        if (p6 != 0) {
            lk6 = 1; // acquire lock
        } else {}

        if (p7 != 0) {
            lk7 = 1; // acquire lock
        } else {}

        if (p8 != 0) {
            lk8 = 1; // acquire lock
        } else {}

        if (p9 != 0) {
            lk9 = 1; // acquire lock
        } else {}

        if (p10 != 0) {
            lk10 = 1; // acquire lock
        } else {}

        if (p11 != 0) {
            lk11 = 1; // acquire lock
        } else {}

        if (p12 != 0) {
            lk12 = 1; // acquire lock
        } else {}


    // unlock phase
        if (p1 != 0) {
            if (lk1 != 1) goto ERROR; // assertion failure
            lk1 = 0;
        } else {}

        if (p2 != 0) {
            if (lk2 != 1) goto ERROR; // assertion failure
            lk2 = 0;
        } else {}

        if (p3 != 0) {
            if (lk3 != 1) goto ERROR; // assertion failure
            lk3 = 0;
        } else {}

        if (p4 != 0) {
            if (lk4 != 1) goto ERROR; // assertion failure
            lk4 = 0;
        } else {}

        if (p5 != 0) {
            if (lk5 != 1) goto ERROR; // assertion failure
            lk5 = 0;
        } else {}

        if (p6 != 0) {
            if (lk6 != 1) goto ERROR; // assertion failure
            lk6 = 0;
        } else {}

        if (p7 != 0) {
            if (lk7 != 1) goto ERROR; // assertion failure
            lk7 = 0;
        } else {}

        if (p8 != 0) {
            if (lk8 != 1) goto ERROR; // assertion failure
            lk8 = 0;
        } else {}

        if (p9 != 0) {
            if (lk9 != 1) goto ERROR; // assertion failure
            lk9 = 0;
        } else {}

        if (p10 != 0) {
            if (lk10 != 1) goto ERROR; // assertion failure
            lk10 = 0;
        } else {}

        if (p11 != 0) {
            if (lk11 != 1) goto ERROR; // assertion failure
            lk11 = 0;
        } else {}

        if (p12 != 0) {
            if (lk12 != 1) goto ERROR; // assertion failure
            lk12 = 0;
        } else {}

    }
  out:
    return 0;
  ERROR: __SMACK_assert(0);
    return 0;  
}
Exemplo n.º 23
0
int main(void) {
  struct a x = {10, 20};
  __SMACK_assert(x.j == 10);
  return 0;
}