-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileEdit.py
More file actions
133 lines (102 loc) · 3.91 KB
/
FileEdit.py
File metadata and controls
133 lines (102 loc) · 3.91 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#File Editor
#Descriptor:
#Arrange the input to produce outputs for the Analysis file
#Produces Two Text Files
#Textfile 1: Test Application: I/p Time : The value is chosen for the next population Y or N
#Textfile 2: Oracle Application : I/p Time :
#Location of OutofRuns for Application under test
import os.path
import shutil
#Globalvariable that decides that keeps the margin of how much the testinput time needs to be greater than the input time for the
#oracle to be considered
greaterthan=3
loc1="./Results/appTest"
loc2="./Results/Oracle"
fileName="customBS"
fileGCda=fileName+".c.gcov"
cummugcdaloc="./Results/Runs"
fileGCda=fileName+".c.gcov"
applicationunderTestNames=[]
applicationunderTestLocations=[]
oracleNames=[]
oracleLocations=[]
if (os.path.isfile(fileGCda)):
if(os.path.isfile(os.path.join(cummugcdaloc,fileGCda))):
os.remove(os.path.join(os.path.join(cummugcdaloc,fileGCda)))
shutil.copy(fileGCda, cummugcdaloc)
#create the Input Array
inparray=[]
ifile=open("inputrandom.txt","r+")
for li in ifile.readlines():
inparray.append(int(li.strip("\n")))
#Get name and locations for the Application Under Test files
for name in os.listdir(loc1):
if os.path.isfile(os.path.join(loc1,name)):
applicationunderTestNames.append(name)
applicationunderTestLocations.append(os.path.join(loc1,name))
#Get name and location for the Oracle files
for name in os.listdir(loc2):
if os.path.isfile(os.path.join(loc2,name)):
oracleNames.append(name)
oracleLocations.append(os.path.join(loc2,name))
#Create Two Files
fpAppTest=open("OutPutFileUnderTest.txt", "w+")
fpOracle=open("OutputOracle.txt", "w+")
timmingapp=[]
########## Writing to Application ubder test file ###################
#For each file
for i in range(0,len(applicationunderTestLocations)):
temp=open(applicationunderTestLocations[i], "r+")
temptiming=open(applicationunderTestLocations[i], "r+")
#for each file in each file
# first line will have the input
#temparr=temp.readlines()[0].split(' ')[3].strip('\n')
#inputarrayapp.append(temparr)
#timing information will begin with a "real word"
for lin in temptiming.readlines():
if lin!=' ':
if "real" in lin:
temptime=lin.split('\t')[1].strip('\n').strip('s').split('m')
mins=temptime[0]
secs=temptime[1]
minstosecs=float(mins)*60+float(secs)
timmingapp.append(minstosecs)
############ End of Application under test writing #####################
########## Writing to Oracle file ######################
timmingor=[]
for i in range(0,len(oracleLocations)):
tempor=open(oracleLocations[i], "r+")
temptimingor=open(oracleLocations[i], "r+")
#for each file in each file
# first line will have the input
#temparr=tempor.readlines()[0].split(' ')[3].strip('\n')
#inputarrayor.append(temparr)
#timing information will begin with a "real word"
for lin in temptimingor.readlines():
if "real" in lin:
temptime=lin.split('\t')[1].strip('\n').strip('s').split('m')
mins=temptime[0]
secs=temptime[1]
minstosecs=float(mins)*60+float(secs)
timmingor.append(minstosecs)
break
# write to file
for i in range(0, len(inparray)):
if (float(timmingapp[i])*1000 - float(timmingor[i]*1000)>= 5):
fpAppTest.write(str(inparray[i]) + " " + str(timmingapp[i])+" "+"Y")
fpAppTest.write("\n")
else:
fpAppTest.write(str(inparray[i]) + " " + str(timmingapp[i]) + " " + "N")
fpAppTest.write("\n")
#write to file
for i in range(0, len(inparray)):
fpOracle.write(str(inparray[i])+" "+str(timmingor[i]))
fpOracle.write("\n")
########### End of oracle File Writing Phase ##########################
#Close the Two open files
fpAppTest.close()
fpOracle.close()
temp.close()
temptiming.close()
#tempor.close()
#temptimingor.close()