summaryrefslogtreecommitdiffstats
path: root/Under-Testing/Website/mutexTry.php
diff options
context:
space:
mode:
Diffstat (limited to 'Under-Testing/Website/mutexTry.php')
-rw-r--r--[-rwxr-xr-x]Under-Testing/Website/mutexTry.php232
1 files changed, 122 insertions, 110 deletions
diff --git a/Under-Testing/Website/mutexTry.php b/Under-Testing/Website/mutexTry.php
index 20da2a4..308323d 100755..100644
--- a/Under-Testing/Website/mutexTry.php
+++ b/Under-Testing/Website/mutexTry.php
@@ -1,5 +1,4 @@
-<html>
-<head>
+d>
<script src='delayedLoading.js' type="text/javascript"></script>
<!--ADD HERE ALL THE NEEDED META DATA -->
<title>Network test live results!</title>
@@ -11,9 +10,9 @@
@apache_setenv('no-gzip',1);
@ini_set('zlib.output_compression',0);
@ini_set('implicit_flush',1);
-
//Connection stuff
-include 'dbconnection.php'
+//DB
+include 'dbconnection.php';
//Socket
$port = 34500;
@@ -21,114 +20,122 @@ $ip = 'localhost';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
+//$dbname = 'gsmselftesting';
mysql_select_db($dbname);
-
-//mutex functions, isfree, lock and release
-include 'mutexFunctions.php';
-//insert task functions
-include 'insertData.php';
+//End of connection stuff
+include 'mutexFunctions.php'; //mutex functions, isfree, lock and release
+include 'insertData.php'; //insert task functions
$nameOfLock = 'Webpage';
$timeToKeepTheMutex = 360;
-//Check if the webpage is already open
-$locking = isLocked($nameOfLock);
+$locking = isLocked($nameOfLock);//Check if the webpage is already open
if ($locking == '1') //1 means nobody is on the website
{
- //Set a mutex for the webpage
- $lockMe = Lock($nameOfLock,$timeToKeepTheMutex);
- if ($lockMe == '1') //1 means a successful lock
- {
- // read posted data and add them to the database
- include 'post.php';
- $softwareLock = 'SoftwareStarted';
-
- if($taskAmount != 0)
- {
- #try to lock the startSoftware
- $StartSoftware = isLocked($softwareLock);
- if($StartSoftware == '1') //1 means software is not started yet, start it
- {
- $startApp = fsockopen($ip, 34600, $errno, $error, 5);
- if (!$startApp)
- {
- printf('THE SOFTWARE THAT SHOULD RUN IN BACKGROUND IS NOT RUNNING!');
- printf('Solution: - You need to start the script which always running background (startSoftware.py)');
- printf(' - You can find this script on Code -> Server-Code -startSoftware.py');
- printf(' - python startSoftware.py');
- }
- else
- {
- socket_set_timeout( $startApp, 50); //one should set the number of the longest test, so we can define the timeout
- fwrite($startApp, "START APP");
- usleep(2500);
- fclose($startApp);
- }
- //sleep till the software starts
- sleep(6);
- $controller = isLocked($softwareLock);
- if($controller == '0') //Software running and waiting for connection!
- {
- //try to open the socket and connect to the software
- $fp = fsockopen($ip, $port, $errno, $error, 5);
- if (!$fp)
- {
- echo 'Could not open the socket or connect to the testing software! Check ports on both sides!';
+ $lockMe = Lock($nameOfLock,$timeToKeepTheMutex); //Set a mutex for the webpage
+ if ($lockMe == '1') //1 means a successful lock
+ {
+
+ include 'post.php'; // read posted data and add them to the database
+// echo 'WE had errors: '. $errorAdding;
+ //stuff to do here
+ //check if the software is running!
+ $softwareLock = 'SoftwareStarted';
+
+ //$taskAmount= 1
+ if($taskAmount != 0)
+ {
+ $softwareRunning = isLocked($softwareLock);
+ if($softwareRunning == '1') //1 means software is not started yet, start it
+ {
+ $startApp = fsockopen($ip, 34600, $errno, $error, 5);
+ if (!$startApp)
+ {
+ printf('THE SOFTWARE THAT SHOULD RUN IN BACKGROUND IS NOT RUNNING!');
+ }
+ else
+ {
+ socket_set_timeout( $startApp, 50); //one should set the number of the longest test, so we can define the timeout
+ fwrite($startApp, "START APP");
+ usleep(2500);
+ fclose($startApp);
+ }
+
+ //exec("/usr/bin/python /var/www/tricode/gsmselftest2.py > /dev/null 2>&1 &"); //start the software in background and don't wait for any output
+ sleep(6); //sleep half second till the software starts
+ //the software should be running already and set the lock, now we test it and then connect to it!
+
+ $softwareRunning1 = isLocked($softwareLock);
+ if($softwareRunning1 == '0') //Software running and waiting for connection!
+ {
+ //try to open the socket and connect to the software
+ $fp = fsockopen($ip, $port, $errno, $error, 5);
+
+ if (!$fp)
+ {
+ echo 'Could not open the socket or connect to the testing software! Check ports on both sides!';
- }
- else
- {
- socket_set_timeout($fp,50);
- fwrite($fp, "START TEST");
- if(!feof($fp))
- {
- while(!feof($fp))
- {
- $received = fgets($fp, 128); //receive data!
- //we got the confirmation from the testing software
- if ($received == "CONFIRM\n")
- {
- $GSMRZ1 = 0;
- $GSMRZ2 = 0;
- $GSMRZ3 = 0;
-
- $SIP = 0;
- $UNISIP = 0;
- $LANDLINE = 0;
- $LSFKS = 0;
+ }
+ else
+ {
+ socket_set_timeout($fp,50); //one should set the number of the longest test, so we can define the timeout function (it is the number after "$fp,")
+
+ fwrite($fp, "START TEST");
+
+ //fwrite($fp, "SMART TEST"); //send command to start the tests
+ if(!feof($fp))
+ {
+ while(!feof($fp))
+ {
+ $received = fgets($fp, 128); //receive data!
+
+ if ($received == "CONFIRM\n") //we got the confirmation from the testing software
+ {
+ //test finished successfully
+
+ $GSMRZ1 = 0;
+ $GSMRZ2 = 0;
+ $GSMRZ3 = 0;
- $GSMEE = 0;
- $GSMEV = 0;
- $GSMET = 0;
- $GSMEO = 0;
-
- $SIPP = 2;
- $LANDLINEP = 2;
- $UNISIPP = 2;
- $NANOBTS1P = 2;
- $NANOBTS2P = 2;
- echo str_pad(' ',4096).'<br>'."\n";
- ob_implicit_flush(1);
- echo '<div id="main">
- <table summary = "Results">
- <thead>
- <tr>
- <th scope = "col"> From: </th>
- <th scope = "col" > To: </th>
- <th scope = "col"> Message: </th>
- <th scope = "col"> Status: </th>
- </tr>
- </thead>
- <!-- start of the table rows-->
- <tbody>';
- echo str_repeat("\n",7024);
- flush();
- sleep(6);
- $pings = mysql_query("select * from PingResultTable where taskNo=(select max(taskNo) from PingResultTable)");
-
- while($row = mysql_fetch_array($pings))
- {
+ $SIP = 0;
+ $UNISIP = 0;
+ $LANDLINE = 0;
+ $LSFKS = 0;
+
+ $GSMEE = 0;
+ $GSMEV = 0;
+ $GSMET = 0;
+ $GSMEO = 0;
+
+ $SIPP = 2;
+ $LANDLINEP = 2;
+ $UNISIPP = 2;
+ $NANOBTS1P = 2;
+ $NANOBTS2P = 2;
+ /////////// end of test!
+ echo str_pad(' ',4096).'<br>'."\n";
+ ob_implicit_flush(1);
+
+ echo '<div id="main">
+ <table summary = "Results">
+ <thead>
+ <tr>
+ <th scope = "col"> From: </th>
+ <th scope = "col" > To: </th>
+ <th scope = "col"> Message: </th>
+ <th scope = "col"> Status: </th>
+ </tr>
+ </thead>
+ <!-- start of the table rows-->
+ <tbody>';
+ ob_implicit_flush(1);
+ sleep(6);
+ $pings = mysql_query("select * from PingResultTable where taskNo=(select max(taskNo) from PingResultTable)");
+
+ while($row = mysql_fetch_array($pings))
+ {
+ // echo $row['taskNo'];
$SIPP = $row['sipServer'];
$LANDLINEP = $row['sipGate'];
$UNISIPP = $row['unisip'];
@@ -158,6 +165,7 @@ if ($locking == '1') //1 means nobody is on the website
$callFrom = strtoupper($dataForTable[1]);
$callTo = strtoupper($dataForTable[2]);
$testStatus = strtoupper($dataForTable[3]);
+ //ADD HERE THE TEST CASES BUT MAKE IT INSIDE OF A FILE (e.q. include 'testing.php'); HERE I PUT IT ONLY FOR EXAMPLE PURPOSES!
if($callFrom == 'SIP' || $callTo == 'SIP')
{
@@ -260,7 +268,7 @@ if ($locking == '1') //1 means nobody is on the website
}
elseif($testStatus == '998' || $testStatus == '802')
{
- $GSMRZ1 = 0;
+ $GSMRZ1 = 0; //where is nanoBTS1
}
}
elseif ($callTo == 'GSMRZ1')
@@ -274,7 +282,7 @@ if ($locking == '1') //1 means nobody is on the website
}
elseif($testStatus == '999' || $testStatus == '801')
{
- $GSMRZ1 = 0;
+ $GSMRZ1 = 0; //where is nanoBTS1
}
}
}
@@ -322,7 +330,7 @@ if ($locking == '1') //1 means nobody is on the website
}
elseif($testStatus == '998' || $testStatus == '802')
{
- $GSMRZ2 = 0;
+ $GSMRZ2 = 0; //where is nanoBTS1
$NANOBTS1P= 1;
}
}
@@ -353,7 +361,7 @@ if ($locking == '1') //1 means nobody is on the website
}
elseif($testStatus == '999' || $testStatus == '801')
{
- $GSMRZ2 = 0;
+ $GSMRZ2 = 0; //where is nanoBTS1
if ($NANOBTS1P != 1)
{
$NANOBTS1P= 2;
@@ -408,7 +416,7 @@ if ($locking == '1') //1 means nobody is on the website
}
elseif($testStatus == '998' || $testStatus == '802')
{
- $GSMRZ3 = 0;
+ $GSMRZ3 = 0; //where is nanoBTS1
$NANOBTS2P= 1;
}
}
@@ -439,7 +447,7 @@ if ($locking == '1') //1 means nobody is on the website
}
elseif($testStatus == '999' || $testStatus == '801')
{
- $GSMRZ3 = 0;
+ $GSMRZ3 = 0; //where is nanoBTS1
if ($NANOBTS1P != 1)
{
$NANOBTS2P= 2;
@@ -749,6 +757,7 @@ if ($locking == '1') //1 means nobody is on the website
}
elseif($testStatus == '486')
{
+ $LANDLINEP = 1;
if ($LANDLINE != 1)
{
$LANDLINE = -1;
@@ -904,6 +913,7 @@ if ($locking == '1') //1 means nobody is on the website
<td> ' . $dataForTable[4] . ' </td>
<td>' . $dataForTable[3] . '</td>
</tr>';
+ //echo $received . '<br>';
ob_implicit_flush(1);
usleep(100);
fwrite($fp, "CONTINUE"); //tell the software to proceed with the test and confirm receiving data
@@ -916,7 +926,7 @@ if ($locking == '1') //1 means nobody is on the website
}
}
- elseif($controller == '1')
+ elseif($softwareRunning1 == '1')
{
echo 'Testing software was not started(didn\'t obtain the lock)! Check it!';
}
@@ -925,7 +935,7 @@ if ($locking == '1') //1 means nobody is on the website
echo 'Testing software didn\'t obtain the lock';
}
}
- elseif($StartSoftware == '0') //0 means the software is still running in the background
+ elseif($softwareRunning == '0') //0 means the software is still running in the background
{
echo 'Testing software is still running! Maybe you should kill it (if not started manually!)';
}
@@ -934,6 +944,8 @@ if ($locking == '1') //1 means nobody is on the website
echo 'We have an unknown error! Refresh te web page!';
}
+ //$release = ReleaseLock($nameOfLock);
+ //echo $release . "<br>";
}
else
{