Skip to content

Commit

Permalink
sleep example
Browse files Browse the repository at this point in the history
  • Loading branch information
lamyaa committed Apr 9, 2014
1 parent 948b679 commit 55dbe99
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cs526/sleep/sleep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <klee/klee.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>

int val=0;

void *func(void* threadid){
unsigned seconds;
klee_make_symbolic(seconds, sizeof(int), "seconds");
sleep(seconds);
val=5;
pthread_exit(NULL);
}

void test_func(){
pthread_t thread;
int id=1;
pthread_create(&thread, NULL, func, (void *)id);

//wait for func to change the value
sleep(20);
//assert that value was changed to 5
assert(val==5);
}

int main(int argc, char **argv) {
test_func();
}

0 comments on commit 55dbe99

Please sign in to comment.