Index: /trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py
===================================================================
--- /trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py	(revision 86539)
+++ /trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py	(revision 86540)
@@ -35,16 +35,4 @@
 import sys;
 import re;
-import ssl;
-
-# Python 3 hacks:
-if sys.version_info[0] < 3:
-    import urllib2 as urllib; # pylint: disable=import-error,no-name-in-module
-    from urllib2        import ProxyHandler as urllib_ProxyHandler; # pylint: disable=import-error,no-name-in-module
-    from urllib2        import build_opener as urllib_build_opener; # pylint: disable=import-error,no-name-in-module
-else:
-    import urllib; # pylint: disable=import-error,no-name-in-module
-    from urllib.request import ProxyHandler as urllib_ProxyHandler; # pylint: disable=import-error,no-name-in-module
-    from urllib.request import build_opener as urllib_build_opener; # pylint: disable=import-error,no-name-in-module
-
 
 # Only the main script needs to modify the path.
@@ -60,10 +48,4 @@
 from testdriver import vboxcon;
 from testdriver import vboxwrappers;
-from common     import utils;
-
-# Python 3 hacks:
-if sys.version_info[0] >= 3:
-    long = int      # pylint: disable=redefined-builtin,invalid-name
-    xrange = range; # pylint: disable=redefined-builtin,invalid-name
 
 
@@ -115,55 +97,4 @@
 
 
-def downloadFile(sUrlFile, sDstFile, sLocalPrefix, fnLog, fnError = None, fNoProxies=True):
-    """
-    Downloads the given file if an URL is given, otherwise assume it's
-    something on the build share and copy it from there.
-
-    Raises no exceptions, returns log + success indicator instead.
-
-    Note! This method may use proxies configured on the system and the
-          http_proxy, ftp_proxy, no_proxy environment variables.
-
-    """
-    if fnError is None:
-        fnError = fnLog;
-
-    if  sUrlFile.startswith('http://') \
-     or sUrlFile.startswith('https://') \
-     or sUrlFile.startswith('ftp://'):
-        # Download the file.
-        fnLog('Downloading "%s" to "%s"...' % (sUrlFile, sDstFile));
-        try:
-            # Disable SSL certificate verification for our servers
-            ssl_ctx = ssl.create_default_context();
-            ssl_ctx.check_hostname = False;
-            ssl_ctx.verify_mode = ssl.CERT_NONE;
-
-            ## @todo We get 404.html content instead of exceptions here, which is confusing and should be addressed.
-            if not fNoProxies:
-                oOpener = urllib_build_opener(urllib.HTTPSHandler(context = ssl_ctx));
-            else:
-                oOpener = urllib_build_opener(urllib.HTTPSHandler(context = ssl_ctx), urllib_ProxyHandler(proxies = dict()));
-            oSrc = oOpener.open(sUrlFile);
-            oDst = utils.openNoInherit(sDstFile, 'wb');
-            oDst.write(oSrc.read());
-            oDst.close();
-            oSrc.close();
-        except Exception as oXcpt:
-            fnError('Error downloading "%s" to "%s": %s' % (sUrlFile, sDstFile, oXcpt));
-            return False;
-    else:
-        # Assumes file from the build share.
-        sSrcPath = os.path.join(sLocalPrefix, sUrlFile);
-        fnLog('Copying "%s" to "%s"...' % (sSrcPath, sDstFile));
-        try:
-            utils.copyFileSimple(sSrcPath, sDstFile);
-        except Exception as oXcpt:
-            fnError('Error copying "%s" to "%s": %s' % (sSrcPath, sDstFile, oXcpt));
-            return False;
-
-    return True;
-
-
 class tdAutostartOs(object):
     """
@@ -171,6 +102,6 @@
     """
 
-    def __init__(self, oTestDriver, fpApiVer, sGuestAdditionsIso):
-        self.oTestDriver = oTestDriver;
+    def __init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso):
+        self.oTstDrv = oTstDrv;
         self.fpApiVer = fpApiVer;
         self.sGuestAdditionsIso = sGuestAdditionsIso;
@@ -236,5 +167,5 @@
                         break;
 
-            self.oTestDriver.sleep(10);
+            self.oTstDrv.sleep(10);
             cAttempt += 1;
         return fRc;
@@ -481,6 +412,5 @@
         else:
             if oCurProgress is not None:
-                oWrapperProgress = vboxwrappers.ProgressWrapper(oCurProgress, self.oTestDriver.oVBoxMgr,
-                                                                self.oTestDriver, "uploadFile");
+                oWrapperProgress = vboxwrappers.ProgressWrapper(oCurProgress, self.oTstDrv.oVBoxMgr, self.oTstDrv, "uploadFile");
                 oWrapperProgress.wait();
                 if not oWrapperProgress.isSuccess():
@@ -494,5 +424,5 @@
     def downloadFile(self, oGuestSession, sSrc, sDst, fIgnoreErrors = False):
         """
-        Upload the string into guest.
+        Get a file (sSrc) from the guest storing it on the host (sDst).
         """
         fRc = True;
@@ -510,6 +440,6 @@
         else:
             if oCurProgress is not None:
-                oWrapperProgress = vboxwrappers.ProgressWrapper(oCurProgress, self.oTestDriver.oVBoxMgr,
-                                                                self.oTestDriver, "downloadFile");
+                oWrapperProgress = vboxwrappers.ProgressWrapper(oCurProgress, self.oTstDrv.oVBoxMgr,
+                                                                self.oTstDrv, "downloadFile");
                 oWrapperProgress.wait();
                 if not oWrapperProgress.isSuccess():
@@ -536,5 +466,8 @@
         fRc = True;
         for sGstFile in asFiles:
-            sTmpFile = os.path.join(self.oTestDriver.sScratchPath, 'tmp-' + os.path.basename(sGstFile));
+            ## @todo r=bird: You need to use the guest specific path functions here.
+            ##       Best would be to add basenameEx to common/pathutils.py.  See how joinEx
+            ##       is used by BaseTestVm::pathJoin and such.
+            sTmpFile = os.path.join(self.oTstDrv.sScratchPath, 'tmp-' + os.path.basename(sGstFile));
             reporter.log2('Downloading file "%s" to "%s" ...' % (sGstFile, sTmpFile));
             # First try to remove (unlink) an existing temporary file, as we don't truncate the file.
@@ -559,11 +492,11 @@
     """
 
-    def __init__(self, oTestDriver, asTestBuildDirs, fpApiVer, sGuestAdditionsIso):
-        tdAutostartOs.__init__(self, oTestDriver, fpApiVer, sGuestAdditionsIso);
+    def __init__(self, oTstDrv, asTestBuildDirs, fpApiVer, sGuestAdditionsIso):
+        tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);
         self.sTestBuild = self._findFile('^VirtualBox-.*\\.run$', asTestBuildDirs);
         if not self.sTestBuild:
             raise base.GenError("VirtualBox install package not found");
 
-    def waitVMisReady(self, oSession, fWaitTrayControl):
+    def waitVmIsReady(self, oSession, fWaitTrayControl):
         """
         Waits the VM is ready after start or reboot.
@@ -572,5 +505,5 @@
         _ = fWaitTrayControl;
         # Give the VM a time to reboot
-        self.oTestDriver.sleep(30);
+        self.oTstDrv.sleep(30);
 
         # Waiting the VM is ready.
@@ -585,5 +518,5 @@
         while cAttempt < 30:
             fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
-                                            'vbox', 'password', 10 * 1000, False);
+                                                    'vbox', 'password', 10 * 1000, False);
             if fRc:
                 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process',
@@ -596,5 +529,5 @@
                 self.closeSession(oGuestSession, False);
 
-            self.oTestDriver.sleep(10);
+            self.oTstDrv.sleep(10);
             cAttempt += 1;
 
@@ -615,5 +548,5 @@
         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
         if fRc:
-            (fRc, oGuestSession) = self.waitVMisReady(oSession, False);
+            (fRc, oGuestSession) = self.waitVmIsReady(oSession, False);
 
         if not fRc:
@@ -655,6 +588,6 @@
         fRc = False;
         # Install Kernel headers, which are required for actually installing the Linux Additions.
-        if oVM.OSTypeId.startswith('Debian') \
-        or oVM.OSTypeId.startswith('Ubuntu'):
+        if   oVM.OSTypeId.startswith('Debian') \
+          or oVM.OSTypeId.startswith('Ubuntu'):
             (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Installing Kernel headers',
                                                   5 * 60 *1000, '/usr/bin/apt-get',
@@ -673,8 +606,8 @@
 
         elif oVM.OSTypeId.startswith('OL') \
-        or   oVM.OSTypeId.startswith('Oracle') \
-        or   oVM.OSTypeId.startswith('RHEL') \
-        or   oVM.OSTypeId.startswith('Redhat') \
-        or   oVM.OSTypeId.startswith('Cent'):
+          or oVM.OSTypeId.startswith('Oracle') \
+          or oVM.OSTypeId.startswith('RHEL') \
+          or oVM.OSTypeId.startswith('Redhat') \
+          or oVM.OSTypeId.startswith('Cent'):
             (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Installing Kernel headers',
                                                   5 * 60 *1000, '/usr/bin/yum',
@@ -711,5 +644,5 @@
                 fRc = self.closeSession(oGuestSession);
                 if fRc:
-                    (fRc, oGuestSession) = self.waitVMisReady(oSession, False);
+                    (fRc, oGuestSession) = self.waitVmIsReady(oSession, False);
 
                 # Download log files.
@@ -764,6 +697,5 @@
         return fRc;
 
-    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow',
-                           asUserAllow = (), asUserDeny = ()):
+    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
         """
         Configures the autostart feature in the guest.
@@ -886,5 +818,5 @@
         """
 
-        self.oTestDriver.sleep(30);
+        self.oTstDrv.sleep(30);
 
         _ = oSession;
@@ -912,7 +844,7 @@
     """
 
-    def __init__(self, oTestDriver, sTestBuildDir, fpApiVer, sGuestAdditionsIso):
+    def __init__(self, oTstDrv, sTestBuildDir, fpApiVer, sGuestAdditionsIso):
         _ = sTestBuildDir;
-        tdAutostartOs.__init__(self, oTestDriver, fpApiVer, sGuestAdditionsIso);
+        tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);
         raise base.GenError('Testing the autostart functionality for Darwin is not implemented');
 
@@ -923,7 +855,7 @@
     """
 
-    def __init__(self, oTestDriver, sTestBuildDir, fpApiVer, sGuestAdditionsIso):
+    def __init__(self, oTstDrv, sTestBuildDir, fpApiVer, sGuestAdditionsIso):
         _ = sTestBuildDir;
-        tdAutostartOs.__init__(self, oTestDriver, fpApiVer, sGuestAdditionsIso);
+        tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);
         raise base.GenError('Testing the autostart functionality for Solaris is not implemented');
 
@@ -934,6 +866,6 @@
     """
 
-    def __init__(self, oTestDriver, asTestBuildDirs, fpApiVer, sGuestAdditionsIso):
-        tdAutostartOs.__init__(self, oTestDriver, fpApiVer, sGuestAdditionsIso);
+    def __init__(self, oTstDrv, asTestBuildDirs, fpApiVer, sGuestAdditionsIso):
+        tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);
         self.sTestBuild = self._findFile('^VirtualBox-.*\\.(exe|msi)$', asTestBuildDirs);
         if not self.sTestBuild:
@@ -941,10 +873,10 @@
         return;
 
-    def waitVMisReady(self, oSession, fWaitTrayControl, fWaitFacility = True):
+    def waitVmIsReady(self, oSession, fWaitTrayControl, fWaitFacility = True):
         """
         Waits the VM is ready after start or reboot.
         """
         # Give the VM a time to reboot
-        self.oTestDriver.sleep(30);
+        self.oTstDrv.sleep(30);
 
         # Waiting the VM is ready.
@@ -957,6 +889,5 @@
         oGuestSession = None;
         while cAttempt < 10:
-            fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
-                                            'vbox', 'password', 10 * 1000, False);
+            fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox', 'vbox', 'password', 10 * 1000, False);
             if fRc:
                 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process',
@@ -968,5 +899,5 @@
                 self.closeSession(oGuestSession, False);
 
-            self.oTestDriver.sleep(10);
+            self.oTstDrv.sleep(10);
             cAttempt += 1;
 
@@ -987,5 +918,5 @@
         fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
         if fRc:
-            (fRc, oGuestSession) = self.waitVMisReady(oSession, True);
+            (fRc, oGuestSession) = self.waitVmIsReady(oSession, True);
         if not fRc:
             reporter.error('VM is not ready after reboot');
@@ -1035,6 +966,6 @@
         else:
             if oCurProgress is not None:
-                oWrapperProgress = vboxwrappers.ProgressWrapper(oCurProgress, self.oTestDriver.oVBoxMgr,
-                                                                self.oTestDriver, "installAdditions");
+                oWrapperProgress = vboxwrappers.ProgressWrapper(oCurProgress, self.oTstDrv.oVBoxMgr,
+                                                                self.oTstDrv, "installAdditions");
                 oWrapperProgress.wait(cMsTimeout = 10 * 60 * 1000);
                 if not oWrapperProgress.isSuccess():
@@ -1050,5 +981,5 @@
         ##
         #
-        #self.oTestDriver.sleep(60 * 2);
+        #self.oTstDrv.sleep(60 * 2);
         #
         #if oVM.OSTypeId not in ('WindowsNT4', 'Windows2000', 'WindowsXP', 'Windows2003'):
@@ -1083,5 +1014,5 @@
         #    fRc = self.closeSession(oGuestSession, True);
         #    if fRc:
-        #        (fRc, oGuestSession) = self.waitVMisReady(oSession, False, False);
+        #        (fRc, oGuestSession) = self.waitVmIsReady(oSession, False, False);
         #---------------------------------------
 
@@ -1162,10 +1093,10 @@
         return fRc;
 
-    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow',
-                           asUserAllow = (), asUserDeny = ()):
+    def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()):
         """
         Configures the autostart feature in the guest.
         """
         reporter.testStart('Configure autostart');
+
         # Create autostart database directory writeable for everyone
         (fRc, _, _, _) = \
@@ -1177,7 +1108,4 @@
                                       'C:\\ProgramData\\autostart.cfg', '/f'],
                                      False, True);
-        if not fRc:
-            reporter.error('Setting the autostart environment variable failed');
-
         if fRc:
             sVBoxCfg = self._createAutostartCfg(sDefaultPolicy, asUserAllow, asUserDeny);
@@ -1185,4 +1113,7 @@
             if not fRc:
                 reporter.error('Upload the autostart.cfg failed');
+        else:
+            reporter.error('Setting the autostart environment variable failed');
+
         reporter.testDone();
         return fRc;
@@ -1242,5 +1173,5 @@
         """
 
-        self.oTestDriver.sleep(30);
+        self.oTstDrv.sleep(30);
 
         _ = oGuestSession;
@@ -1256,7 +1187,7 @@
 
             (fRc, _, _, aBuf) = self.guestProcessExecute(oGuestSession, 'Check for running VM',
-                                                       60 * 1000, 'C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe',
-                                                       ['C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe',
-                                                        'list', 'runningvms'], True, True);
+                                                         60 * 1000, 'C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe',
+                                                         [ 'C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe',
+                                                           'list', 'runningvms' ], True, True);
             if not fRc:
                 reporter.error('Checking the VM %s is running for user %s failed' % (sVmName, sUser));
@@ -1329,5 +1260,5 @@
 
 WScript.Echo "Logon As A Service Right granted to user '"& strUserName &"'"
-                           """ % sUser;
+                           """ % (sUser,);
             fRc = self.uploadString(oGuestSession, sSecPolicyEditor, 'C:\\Temp\\adjustsec.vbs');
             if not fRc:
@@ -1365,5 +1296,7 @@
         self.asTestVMs          = self.asTestVMsDef;
         self.asSkipVMs          = [];
-        self.asTestBuildDirs      = None; #'D:/AlexD/TestBox/TestAdditionalFiles';
+        ## @todo r=bird: The --test-build-dirs option as primary way to get the installation files to test
+        ## is not an acceptable test practice as we don't know wtf you're testing.  See defect for more.
+        self.asTestBuildDirs    = None; #'D:/AlexD/TestBox/TestAdditionalFiles';
         self.sGuestAdditionsIso = None; #'D:/AlexD/TestBox/TestAdditionalFiles/VBoxGuestAdditions_6.1.2.iso';
 
@@ -1527,5 +1460,5 @@
         if oGuestOsHlp is not None:
             #wait the VM is ready after starting
-            (fRc, oGuestSession) = oGuestOsHlp.waitVMisReady(oSession, True);
+            (fRc, oGuestSession) = oGuestOsHlp.waitVmIsReady(oSession, True);
             #install fresh guest additions
             if fRc:
