-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.php
executable file
·223 lines (179 loc) · 8.34 KB
/
driver.php
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
$server = "localhost";
$username = "CREW_BM";
$password = "CREW_BM";
$database_name = "benchmarking";
$baseDir = "/var/www/mmehari/";
// $baseDir = "/var/www/benchmarking/";
function testbed_getPlatformList(&$TB_platformList)
{
global $server, $username, $password, $database_name;
mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($database_name) or die(mysql_error());
$platformList = mysql_query("SELECT platform FROM platformTable") or die(mysql_error());
while($row = mysql_fetch_array($platformList))
$TB_platformList[] = $row[0];
return TRUE;
}
// if(testbed_getPlatformList($platformList))
// foreach($platformList as $platform)
// echo $platform;
function testbed_getAppList($TB_platformName, &$TB_appList)
{
global $server, $username, $password, $database_name;
mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($database_name) or die(mysql_error());
$appList = mysql_query("SELECT application FROM applicationTable WHERE platform = '$TB_platformName'") or die(mysql_error());
while($row = mysql_fetch_array($appList))
$TB_appList[] = $row[0];
return TRUE;
}
// testbed_getAppList("tinyOS",$appList);
// foreach($appList as $app)
// echo $app;
function testbed_getAppInfo($TB_platformName, $TB_appName, &$TB_appInfo)
{
global $server, $username, $password, $database_name;
mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($database_name) or die(mysql_error());
$appInfo = mysql_query("SELECT version,description FROM applicationTable WHERE platform = '$TB_platformName' and application = '$TB_appName'") or die(mysql_error());
$row = mysql_fetch_array($appInfo);
$TB_appInfo[] = $row[0];
$TB_appInfo[] = $row[1];
return TRUE;
}
// testbed_getAppInfo("x86Linux","iperf",$appInfo);
// echo $appInfo[0];
// echo $appInfo[1];
function testbed_getAppInputFormatNameList($TB_platformName, $TB_appName, &$TB_appInputFormatNameList)
{
mysql_connect("localhost", "CREW_BM", "CREW_BM") or die(mysql_error());
mysql_select_db("benchmarking") or die(mysql_error());
$appInputFormatList = mysql_query("SELECT inputFormat FROM applicationTable WHERE platform = '$TB_platformName' and application = '$TB_appName'") or die(mysql_error());
$inputFormatList = mysql_fetch_array($appInputFormatList);
$inputFormatArray = split(";",$inputFormatList[0]);
$TB_appInputFormatNameList = "<inputFormat>";
foreach($inputFormatArray as $inputFormatItemList)
{
$inputFormatItemArray = split("#",$inputFormatItemList);
$TB_appInputFormatNameList = $TB_appInputFormatNameList."<parameter name='".$inputFormatItemArray[0]."' dscr='".$inputFormatItemArray[1]."' type='".$inputFormatItemArray[2]."' />";
}
$TB_appInputFormatNameList = $TB_appInputFormatNameList."</inputFormat>";
return TRUE;
}
// if(testbed_getAppInputFormatNameList("x86Linux","iperf",$appInputformat));
// echo $appInputformat;
function testbed_getAppOutputFormatNameList($TB_platformName, $TB_appName, &$TB_appOutputFormatNameList)
{
mysql_connect("localhost", "CREW_BM", "CREW_BM") or die(mysql_error());
mysql_select_db("benchmarking") or die(mysql_error());
$appOutputFormatList = mysql_query("SELECT outputFormat FROM applicationTable WHERE platform = '$TB_platformName' and application = '$TB_appName'") or die(mysql_error());
$outputFormatList = mysql_fetch_array($appOutputFormatList);
$MPArray = explode("|",$outputFormatList[0]);
$TB_appOutputFormatNameList = "<outputFormat>";
foreach($MPArray as $MP)
{
$MPList = explode("%",$MP);
$TB_appOutputFormatNameList = $TB_appOutputFormatNameList."<mp name='".$MPList[0]."'>";
$outputFormatArray = explode(";",$MPList[1]);
foreach($outputFormatArray as $outputFormatItemList)
{
$outputFormatItemArray = explode("#",$outputFormatItemList);
$TB_appOutputFormatNameList = $TB_appOutputFormatNameList."<parameter name='".$outputFormatItemArray[0]."' dscr='".$outputFormatItemArray[1]."' type='".$outputFormatItemArray[2]."' unit='".$outputFormatItemArray[3]."' />";
}
$TB_appOutputFormatNameList = $TB_appOutputFormatNameList."</mp>";
}
$TB_appOutputFormatNameList = $TB_appOutputFormatNameList."</outputFormat>";
return TRUE;
}
// if(testbed_getAppOutputFormatNameList("x86Linux","iperf",$appOutputformat))
// echo $appOutputformat;
function testbed_getSensorParamList($TB_sensorAppName, &$TB_sensorParamList)
{
mysql_connect("localhost", "CREW_BM", "CREW_BM") or die(mysql_error());
mysql_select_db("benchmarking") or die(mysql_error());
$sensorParamList = mysql_query("SELECT property,value FROM sensorParameterTable WHERE application = '$TB_sensorAppName'") or die(mysql_error());
while($row = mysql_fetch_array($sensorParamList))
$TB_sensorParamList[]=array($row[0],$row[1]);
return TRUE;
}
// if(testbed_getSensorParamList("RadioPerf",$sensorParamList))
// foreach($sensorParamList as $sensorParam)
// echo $sensorParam[0];
function testbed_getNodeInfo(&$TB_nodeInfo,$platform)
{
mysql_connect("localhost", "CREW_BM", "CREW_BM") or die(mysql_error());
mysql_select_db("benchmarking") or die(mysql_error());
$nodeInfo = mysql_query("SELECT * FROM nodeInfoTable where platform='".$platform."'") or die(mysql_error());
while($row = mysql_fetch_array($nodeInfo))
$TB_nodeInfo[]=array($row[0],$row[1],$row[2],$row[3]);
return TRUE;
}
// if(testbed_getNodeInfo($nodeInfo),"x86Linux")
// foreach($nodeInfo as $info)
// echo $info[3];
function testbed_getImageList($TB_platformName, &$TB_imageList)
{
mysql_connect("localhost", "CREW_BM", "CREW_BM") or die(mysql_error());
mysql_select_db("benchmarking") or die(mysql_error());
$imageList = mysql_query("SELECT image FROM imageTable WHERE platform = '$TB_platformName'") or die(mysql_error());
while($row = mysql_fetch_array($imageList))
$TB_imageList[] = $row[0];
return TRUE;
}
// if(testbed_getImageList("x86Linux",$imageList))
// foreach($imageList as $image)
// echo $image;
function testbed_getInterfaceList($TB_nodeName, &$TB_interfaceList)
{
mysql_connect("localhost", "CREW_BM", "CREW_BM") or die(mysql_error());
mysql_select_db("benchmarking") or die(mysql_error());
$interfaceList = mysql_query("SELECT interface FROM hardConfigTable WHERE node = '$TB_nodeName'") or die(mysql_error());
$row = mysql_fetch_array($interfaceList);
$TB_interfaceList = split(",",$row[0]);
return TRUE;
}
// if(testbed_getWiFiInterfaceList("zotac1",$interfaceList))
// foreach($interfaceList as $interface)
// echo $interface;
function testbed_getWirelessModeList($TB_nodeName, &$TB_wirelessModeList)
{
mysql_connect("localhost", "CREW_BM", "CREW_BM") or die(mysql_error());
mysql_select_db("benchmarking") or die(mysql_error());
$wirelessModeList = mysql_query("SELECT mode FROM hardConfigTable WHERE node = '$TB_nodeName'") or die(mysql_error());
$row = mysql_fetch_array($wirelessModeList);
$TB_wirelessModeList = split(",",$row[0]);
return TRUE;
}
// if(testbed_getWirelessModeList("zotac1",$wirelessModeList))
// foreach($wirelessModeList as $wirelessMode)
// echo $wirelessMode;
function testbed_getChannelList($TB_nodeName, &$TB_channelList)
{
mysql_connect("localhost", "CREW_BM", "CREW_BM") or die(mysql_error());
mysql_select_db("benchmarking") or die(mysql_error());
$channelList = mysql_query("SELECT channel FROM hardConfigTable WHERE node = '$TB_nodeName'") or die(mysql_error());
$row = mysql_fetch_array($channelList);
$TB_channelList = split(",",$row[0]);
return TRUE;
}
// if(testbed_getChannelList("zotac1",$channelList))
// foreach($channelList as $channel)
// echo $channel;
function runED($ED_Name,&$PID,&$exprID,&$exprLogFile)
{
global $baseDir;
$exprLogFile = "tmp/".date('Y-m-d\tH.i.s').".log";
$cmdResult = shell_exec("cd ".$baseDir."tmp/ && omf exec ".$ED_Name." > ".$baseDir.$exprLogFile." & echo $!"); // start ED and retrieve PID
$resultArray = explode("\n",$cmdResult);
$PID = $resultArray[0];
usleep(500000); // need to wait sometime until the log file start populating
$handle = fopen($baseDir.$exprLogFile, "r");
while (strstr($line = fgets($handle),"Experiment ID") == false); // search until the string "Experiment ID" is found
$temp = explode(":",$line);
$exprID = trim($temp[2]);
fclose($handle);
}
// runED("tmp/ED.rb",$PID,$exprID,$exprLogFile);
// echo $PID ."\n".$exprID ."\n".$exprLogFile;
?>