A CIL Tutorial - Department of Computer Science - ETH Zürich

A CIL Tutorial - Department of Computer Science - ETH Zürich A CIL Tutorial - Department of Computer Science - ETH Zürich

29.01.2014 Views

CHAPTER 15. AUTOMATED TEST GENERATION 130 ../test/tut15.c uint64_t (autotest f)(int input a, int input b) { if ((a * b) - (a + b) == 14862436) { return 1; } else return 0; } The function g compares the string given by its argument with the string "autotest". The type of the argument s has the annotation inputnt indicating that it is a null-terminated array. This indicates to the test generation runtime that it must generate valid null-terminated strings when concocting new inputs for g. ../test/tut15.c uint64_t (autotest g)(char *inputnt s) { return string_compare(s, "autotest"); } int main () { uint64_t res; char cheese[1024] = "cheese"; res = f(0,0); res = g(cheese); } return res; This example can be compiled by invoking the following command: $ ciltutcc --enable-tut15 -o tut15 test/tut15.c Then invoking the resulting program, tut15, produces the following output: autotest f: a

CHAPTER 15. AUTOMATED TEST GENERATION 131 s

CHAPTER 15. AUTOMATED TEST GENERATION 131<br />

s

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!