VirtualBox

Changeset 90646 in vbox


Ignore:
Timestamp:
Aug 12, 2021 10:11:37 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146258
Message:

Audio/ValKit: Added initial support to tdAudioTest.py to disable the guest and host firewalls to let VKAT / ATS through (and to not make the tests hang in such cases). ​bugref:10008

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/audio/tdAudioTest.py

    r90644 r90646  
    5151from testdriver import vbox
    5252from testdriver import vboxtestvms
     53from common     import utils;
    5354
    5455# pylint: disable=unnecessary-semicolon
     
    231232        self.killProcessByName("VBoxAudioTest");
    232233
     234    def getWinFirewallArgsDisable(self, sOsType):
     235        """
     236        Returns the command line arguments for Windows OSes
     237        to disable the built-in firewall (if any).
     238
     239        If not supported, returns an empty array.
     240        """
     241        if   sOsType == 'vista': # Vista and up.
     242            return (['netsh', 'advfirewall', 'set', 'allprofiles', 'state', 'off']);
     243        elif sOsType == 'xp':    # Older stuff (XP / 2003).
     244            return(['netsh', 'firewall', 'set', 'opmode', 'mode=DISABLE']);
     245        # Not supported / available.
     246        return [];
     247
     248    def disableGstFirewall(self, oTestVm, oTxsSession):
     249        """
     250        Disables the firewall on a guest (if any).
     251
     252        Needs elevated / admin / root privileges.
     253
     254        Returns success status, not logged.
     255        """
     256        fRc = False;
     257
     258        asArgs  = [];
     259        sOsType = '';
     260        if oTestVm.isWindows():
     261            if oTestVm.sKind in ['WindowsNT4', 'WindowsNT3x']:
     262                sOsType = 'nt3x'; # Not supported, but define it anyway.
     263            elif oTestVm.sKind in ('Windows2000', 'WindowsXP', 'Windows2003'):
     264                sOsType = 'xp';
     265            else:
     266                sOsType = 'vista';
     267            asArgs = self.getWinFirewallArgsDisable(sOsType);
     268        else:
     269            sOsType = 'unsupported';
     270
     271        reporter.log('Disabling firewall on guest (type: %s) ...' % (sOsType,));
     272
     273        if len(asArgs) > 0:
     274            fRc = self.txsRunTest(oTxsSession, 'Disabling guest firewall', \
     275                                  oTestVm.pathJoin(self.getGuestSystemDir(oTestVm), asArgs[0]), asArgs);
     276            if not fRc:
     277                reporter.error('Disabling firewall on guest returned exit code error %d' % (self.getLastRcFromTxs(oTxsSession)));
     278        else:
     279            reporter.log('Firewall not available on guest, skipping');
     280            fRc = True; # Not available, just skip.
     281
     282        return fRc;
     283
     284    def disableHstFirewall(self):
     285        """
     286        Disables the firewall on the host (if any).
     287
     288        Needs elevated / admin / root privileges.
     289
     290        Returns success status, not logged.
     291        """
     292        fRc = False;
     293
     294        asArgs  = [];
     295        sOsType = sys.platform;
     296
     297        if sOsType == 'win32':
     298            reporter.log('Disabling firewall on host (type: %s) ...' % (sOsType));
     299
     300            ## @todo For now we ASSUME that we don't run (and don't support even) on old(er)
     301            #        Windows hosts than Vista.
     302            asArgs = self.getWinFirewallArgsDisable('vista');
     303
     304        if len(asArgs) > 0:
     305            oProcess = utils.sudoProcessPopen(asArgs, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
     306                                              stderr=subprocess.PIPE, shell = False, close_fds = False);
     307            if oProcess:
     308                sOut, sErr = oProcess.communicate();
     309
     310                sOut = sOut.decode(sys.stdin.encoding);
     311                for sLine in sOut.split('\n'):
     312                    reporter.log(sLine);
     313
     314                sErr = sErr.decode(sys.stdin.encoding);
     315                for sLine in sErr.split('\n'):
     316                    reporter.log(sLine);
     317
     318                iExitCode  = oProcess.poll();
     319                if iExitCode != 0:
     320                    fRc = False;
     321            else:
     322                fRc = False;
     323
     324            if not fRc:
     325                reporter.error('Disabling firewall on host returned exit code error %d' % iExitCode);
     326        else:
     327            reporter.log('Firewall not available on host, skipping ');
     328            fRc = True; # Not available, just skip.
     329
     330        return fRc;
     331
    233332    def getLastRcFromTxs(self, oTxsSession):
    234333        """
     
    353452        Executes the specified audio tests.
    354453        """
     454
     455        # Disable any OS-specific firewalls preventing VKAT / ATS to run.
     456        self.disableHstFirewall();
     457        self.disableGstFirewall(oTestVm, oTxsSession);
    355458
    356459        # First try to kill any old VKAT / VBoxAudioTest processes lurking around on the host.
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette