-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlkTimeGenerator.py
More file actions
92 lines (66 loc) · 2.36 KB
/
BlkTimeGenerator.py
File metadata and controls
92 lines (66 loc) · 2.36 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#Visualization Engine
#Parse The Trace files and collect Block Information and Time Stamps
import os.path
import sys
import shutil
runno=sys.argv[1:]
runno=map(str,runno)
runno=''.join(runno)
ftApploc="/home/tasu/Downloads/pin-3.0-76991-gcc-linux/Results/appTest/Traces"
ftOrLoc="/home/tasu/Downloads/pin-3.0-76991-gcc-linux/Results/Oracle/Traces"
deslocation="/home/tasu/Downloads/pin-3.0-76991-gcc-linux/Runs/Traces/TestFuzzer/Trace"+runno
if not os.path.exists(deslocation):
os.makedirs(deslocation)
#Get the Total count of files in the folders and parse them
traceAppfileNames=[]
traceAppfilelocations=[]
traceOracleFileNames=[]
traceOracleFileLocations=[]
#Get All Traces generated by Pin for the Application under test
for name in os.listdir(ftApploc):
traceAppfileNames.append(name)
traceAppfilelocations.append(os.path.join(ftApploc,name))
#Get All Traces for oracle
for name in os.listdir(ftOrLoc):
traceOracleFileNames.append(name)
traceOracleFileLocations.append(os.path.join(ftOrLoc,name))
#Open Each Trace file for Ananlysis
##### For Application Under Test#########
for i in range(0, len(traceAppfileNames)):
fttest=open(traceAppfilelocations[i], "r+")
currfilename=traceAppfileNames[i]
testarr=[]
dictRes={}
diccount={}
countBlk=0
for i in fttest.readlines():
testarr.append(i)
for i in range(0, len(testarr)):
if "Block" in testarr[i]:
currblk=testarr[i-1].strip("\n")
currtime=testarr[i].split(" ")[1].strip("\n")
dictRes[currblk]=currtime
if currblk in diccount:
#Update Value
tempval=diccount[currblk]+1
diccount[currblk]=tempval
else:
#Blk is not present
countBlk+=1
diccount[currblk]=countBlk
firsttime=int(dictRes[str(1)])
for key in dictRes:
tempval=firsttime
temptime=dictRes[key]
actualtime=int(temptime)-tempval
#update the Array
dictRes[key]=actualtime
#Write to a File
FappTest=open("BlkTime"+currfilename, "w+")
FappTest.write("BlkNumber,Time in Milliseconds,TimesAppeared")
FappTest.write("\n")
for key in dictRes:
FappTest.write(key+","+str(dictRes[key])+","+str(diccount[key]))
FappTest.write("\n")
shutil.move("BlkTime"+currfilename, deslocation)
FappTest.close()