More fixes for running teston from anywhere

Change-Id: I1c9ca56306698b00801cd9baccf9e1c55cf4ec25
diff --git a/TestON/bin/cleanup.sh b/TestON/bin/cleanup.sh
index d921147..2d78b1e 100755
--- a/TestON/bin/cleanup.sh
+++ b/TestON/bin/cleanup.sh
@@ -1,5 +1,6 @@
 #!/bin/bash 
 # This script will kill any TestON, ssh, and Mininet sessions that are running.
 sudo kill -9 `ps -ef | grep "./cli.py" | grep -v grep | awk '{print $2}'`
+sudo kill -9 `ps -ef | grep "bin/teston" | grep -v grep | awk '{print $2}'`
 sudo kill -9 `ps -ef | grep "ssh -X" | grep -v grep | awk '{print $2}'`
 sudo mn -c
diff --git a/TestON/bin/updatedriver.py b/TestON/bin/updatedriver.py
index bd6974d..ca5c0f2 100644
--- a/TestON/bin/updatedriver.py
+++ b/TestON/bin/updatedriver.py
@@ -349,8 +349,9 @@
         try :
             self.driverPath = self.configDict['config-driver']['importTypes'][self.driver]['driver-path']
 
-        except KeyError :
-            path = re.sub("(bin)$", "", os.getcwd())
+        except KeyError:
+            location = os.path.abspath( os.path.dirname( __file__ ) )
+            path = re.sub( "(bin)$", "", location )
             self.driverPath = path + "/lib/updatedriver/"
         return self.driverPath
 
diff --git a/TestON/tests/FUNCintent/FUNCintent.py b/TestON/tests/FUNCintent/FUNCintent.py
index 49c2969..9ef8884 100644
--- a/TestON/tests/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNCintent/FUNCintent.py
@@ -1,9 +1,5 @@
-
 # Testing the basic intent functionality of ONOS
 
-import time
-import json
-
 class FUNCintent:
 
     def __init__( self ):
@@ -13,6 +9,7 @@
         import time
         import os
         import imp
+        import re
 
         """
         - Construct tests variables
@@ -33,7 +30,7 @@
 
         # Test variables
         try:
-            main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
+            main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
             main.apps = main.params[ 'ENV' ][ 'cellApps' ]
             gitBranch = main.params[ 'GIT' ][ 'branch' ]
             main.dependencyPath = main.testOnDirectory + \
diff --git a/TestON/tests/SAMPscaleTopo/SAMPscaleTopo.py b/TestON/tests/SAMPscaleTopo/SAMPscaleTopo.py
index 2458c71..9a77f64 100644
--- a/TestON/tests/SAMPscaleTopo/SAMPscaleTopo.py
+++ b/TestON/tests/SAMPscaleTopo/SAMPscaleTopo.py
@@ -11,6 +11,7 @@
         import time
         import os
         import imp
+        import re
 
         """
         - Construct tests variables
@@ -27,7 +28,7 @@
         stepResult = main.FALSE
 
         # Test variables
-        main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
+        main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
         main.apps = main.params[ 'ENV' ][ 'cellApps' ]
         gitBranch = main.params[ 'GIT' ][ 'branch' ]
         main.dependencyPath = main.testOnDirectory + \
diff --git a/TestON/tests/SAMPstartTemplate/SAMPstartTemplate.py b/TestON/tests/SAMPstartTemplate/SAMPstartTemplate.py
index 96d24a9..464a0d3 100644
--- a/TestON/tests/SAMPstartTemplate/SAMPstartTemplate.py
+++ b/TestON/tests/SAMPstartTemplate/SAMPstartTemplate.py
@@ -11,6 +11,7 @@
         import time
         import os
         import imp
+        import re
 
         """
         - Construct tests variables
@@ -27,7 +28,7 @@
         stepResult = main.FALSE
 
         # Test variables
-        main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
+        main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
         main.cellName = main.params[ 'ENV' ][ 'cellName' ]
         main.apps = main.params[ 'ENV' ][ 'cellApps' ]
         gitBranch = main.params[ 'GIT' ][ 'branch' ]
diff --git a/TestON/tests/SCPFportLat/SCPFportLat.py b/TestON/tests/SCPFportLat/SCPFportLat.py
index 9c75cb8..12d305d 100644
--- a/TestON/tests/SCPFportLat/SCPFportLat.py
+++ b/TestON/tests/SCPFportLat/SCPFportLat.py
@@ -9,7 +9,7 @@
 
     def CASE1( self, main ):
         import sys
-        import os.path
+        import re
         import os
         import time
 
@@ -34,7 +34,7 @@
         topoCfgName = main.params['TEST']['topoConfigName']
         portEventResultPath = main.params['DB']['portEventResultPath']
         skipMvn = main.params ['TEST']['mci']
-        testONpath = os.getcwd() #testON/bin
+        testONpath = re.sub( "(tests)$", "bin", main.testDir )  # TestON/bin
 
         # -- INIT SECTION, ONLY RUNS ONCE -- #
         if init == False:
diff --git a/TestON/tests/SCPFswitchLat/SCPFswitchLat.py b/TestON/tests/SCPFswitchLat/SCPFswitchLat.py
index 78ae16c..c0c4ba4 100644
--- a/TestON/tests/SCPFswitchLat/SCPFswitchLat.py
+++ b/TestON/tests/SCPFswitchLat/SCPFswitchLat.py
@@ -9,7 +9,7 @@
 
     def CASE1( self, main ):
         import sys
-        import os.path
+        import re
         import os
         import time
 
@@ -34,7 +34,7 @@
         topoCfgName = main.params['TEST']['topoConfigName']
         switchEventResultPath = main.params['DB']['switchEventResultPath']
         skipMvn = main.params ['TEST']['mci']
-        testONpath = os.getcwd() #testON/bin
+        testONpath = re.sub( "(tests)$", "bin", main.testDir )  # TestON/bin
         user = main.params[ 'CTRL' ][ 'user' ]
 
         # -- INIT SECTION, ONLY RUNS ONCE -- #