diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-11 10:04:33 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-11 10:04:33 -0800 |
commit | 3634b45c63e420910c77a631352ab257b8a6039f (patch) | |
tree | e43051c8b9b6339cddb57a7d8dd6929fbeedb56a /src/relooper/test_fuzz4.cpp | |
parent | 795bcc6e76e59824d725acea1e9c2e1c553a6658 (diff) |
add relooper sources
Diffstat (limited to 'src/relooper/test_fuzz4.cpp')
-rw-r--r-- | src/relooper/test_fuzz4.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/relooper/test_fuzz4.cpp b/src/relooper/test_fuzz4.cpp new file mode 100644 index 00000000..8f969386 --- /dev/null +++ b/src/relooper/test_fuzz4.cpp @@ -0,0 +1,38 @@ + + +#include <stdlib.h> +#include "Relooper.h" + +int main() { + #define SIZE (10*1024*1024) + char *buffer = (char*)malloc(SIZE); + Relooper::SetOutputBuffer(buffer, SIZE); + + Block *b0 = new Block("print('entry'); var label; var state; var decisions = [2, 2, 1, 3, 2, 2, 1, 3, 2, 3, 3, 1, 3, 2, 1]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }"); + Block *b1 = new Block("print(1); state = check();"); + Block *b2 = new Block("print(2); state = check();"); + Block *b3 = new Block("print(3); state = check();"); + Block *b4 = new Block("print(4); state = check();"); + b0->AddBranchTo(b2, "state == 2"); + b0->AddBranchTo(b4, NULL); + b1->AddBranchTo(b1, NULL); + b2->AddBranchTo(b2, NULL); + b3->AddBranchTo(b1, NULL); + b4->AddBranchTo(b4, "state == 4"); + b4->AddBranchTo(b3, NULL); + + Relooper r; + r.AddBlock(b0); + r.AddBlock(b1); + r.AddBlock(b2); + r.AddBlock(b3); + r.AddBlock(b4); + + r.Calculate(b0); + printf("\n\n"); + r.Render(); + + puts(buffer); + + return 1; +} |