-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.py
55 lines (41 loc) · 1.18 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import ast
from TVMfuzz.elements import ingredient
import os
from TVMfuzz.colors import *
from TVMfuzz.elements import *
import random
if not os.path.exists('byproduct'):
import platform
osType = platform.system()
if osType == 'Windows':
os.makedirs('byproduct')
elif osType == 'Linux':
os.makedirs('byproduct')
record_path = 'byproduct/astTree.txt'
dir = 'tests/'
print(Red('dir: '+ dir))
filelist = os.listdir(dir)
fileID = 0
os.environ['funcID'] = str(0)
os.environ['isFunc'] = str('False')
import random
random.shuffle(filelist)
for file in filelist:
helperStatDef_global.clear()
helperStatDef_local.clear()
funcDefs.clear()
fileID += 1
os.environ['fileID'] = str(fileID)
from TVMfuzz.getAST import *
file_path = dir + file
with open(file_path, 'r') as source:
tree_node = ast.parse(source.read())
with open(record_path, 'w') as astTree:
astTree.write(ast.dump(tree_node, indent=2))
NodeTransformer().visit(tree_node)
f = open('byproduct/log.txt', 'w')
for ing in ingredient:
f.write('~~~~~~~~~~~~~~~~~~~~\n')
f.write(str(ing) + '\n')
from TVMfuzz.generation import generate
generate()