Lecture 22: Bugs and testing

Preparation

Bug-finding tools

#include <stdio.h>
#include <stdlib.h>

int foo(int n)
{
	int *arr = malloc(n * sizeof(int));
	//arr[0] = 42;
	//free(arr);
	return arr[0];
}

int main(int argc, const char * argv[]) {
    printf("%d\n", foo(argc));
    return 0;
}

Testing systems code

void test_me(int x, int y) {
  int z = 2 * x;
  if (z == y) {
    if (y == x + 10) {
      crash();
    }
  }
}

SAT/SMT solver

klee