~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to src/relooper/test_fuzz4.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
#include <stdlib.h>
 
4
#include "Relooper.h"
 
5
 
 
6
int main() {
 
7
  #define SIZE (10*1024*1024)
 
8
  char *buffer = (char*)malloc(SIZE);
 
9
  Relooper::SetOutputBuffer(buffer, SIZE);
 
10
 
 
11
  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++] }");
 
12
  Block *b1 = new Block("print(1); state = check();");
 
13
  Block *b2 = new Block("print(2); state = check();");
 
14
  Block *b3 = new Block("print(3); state = check();");
 
15
  Block *b4 = new Block("print(4); state = check();");
 
16
  b0->AddBranchTo(b2, "state == 2");
 
17
  b0->AddBranchTo(b4, NULL);
 
18
  b1->AddBranchTo(b1, NULL);
 
19
  b2->AddBranchTo(b2, NULL);
 
20
  b3->AddBranchTo(b1, NULL);
 
21
  b4->AddBranchTo(b4, "state == 4");
 
22
  b4->AddBranchTo(b3, NULL);
 
23
 
 
24
  Relooper r;
 
25
  r.AddBlock(b0);
 
26
  r.AddBlock(b1);
 
27
  r.AddBlock(b2);
 
28
  r.AddBlock(b3);
 
29
  r.AddBlock(b4);
 
30
 
 
31
  r.Calculate(b0);
 
32
  printf("\n\n");
 
33
  r.Render();
 
34
 
 
35
  puts(buffer);
 
36
 
 
37
  return 1;
 
38
}