VirtualBox

Changeset 103386 in vbox


Ignore:
Timestamp:
Feb 15, 2024 1:43:31 PM (10 months ago)
Author:
vboxsync
Message:

Validation Kit/tdAudioTest: More bugfixes for running on testboxes.

File:
1 edited

Legend:

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

    r103379 r103386  
    301301
    302302        Might be called synchronously in main thread or via the thread exeuction helper (asynchronous).
     303
     304        Returns (success status, exit code).
    303305        """
    304306        fRc = False;
     307        iRc = -42;
    305308
    306309        asEnvTmp = os.environ.copy();
     
    322325            if not oProcess:
    323326                reporter.error('Starting process for "%s" failed!' % (sWhat));
    324                 return False;
     327                return fRc, iRc;
    325328
    326329            iPid = oProcess.pid;
    327330            self.pidFileAdd(iPid, sWhat);
    328 
    329             iRc  = 0;
    330331
    331332            while True if sys.version_info[0] < 3 else oProcess.stdout.readable(): # pylint: disable=no-member
     
    341342            if iRc == 0:
    342343                reporter.log('*** %s: exit code %d' % (sWhat, iRc));
    343                 fRc = True;
    344344            else:
    345345                reporter.log('!*! %s: exit code %d' % (sWhat, iRc));
    346346
     347            fRc = True;
    347348            self.pidFileRemove(iPid);
    348 
    349             # Save thread result code.
    350             self.iThreadHstProcRc = iRc;
    351 
    352349        except:
    353350            reporter.logXcpt('Executing "%s" failed!' % (sWhat));
    354351
    355352        reporter.log('Executing \"%s\" on host %s' % (sWhat, 'done' if fRc else 'failed',));
    356         return fRc;
     353        return (fRc, iRc);
    357354
    358355    def executeHstThread(self, sWhat, asArgs, asEnv = None, fAsAdmin = False):
     
    360357        Thread execution helper to run a process on the host.
    361358        """
    362         return self.executeHstLoop(sWhat, asArgs, asEnv, fAsAdmin);
    363 
    364     def executeHst(self, sWhat, asArgs, asEnv = None, fAsAdmin = False, fBlocking = True):
     359        _, iRc = self.executeHstLoop(sWhat, asArgs, asEnv, fAsAdmin);
     360
     361        # Save thread result code.
     362        self.iThreadHstProcRc = iRc;
     363
     364    def executeHst(self, sWhat, asArgs, asEnv = None, fAsAdmin = False, fBlocking = True, iExpectedRc = None):
    365365        """
    366366        Runs a binary (image) with optional admin (root) rights on the host and
     
    369369        Windows currently is not supported yet running stuff as Administrator.
    370370
    371         Returns success status (exit code is 0).
    372         """
    373         reporter.log('Executing \"%s\" on host (as admin = %s, blocking = %s)' % (sWhat, fAsAdmin, fBlocking));
     371        Returns (success status, exit code).
     372        """
     373        reporter.log('Executing \"%s\" on host (as admin = %s, blocking = %s, expected rc = %d)'
     374                     % (sWhat, fAsAdmin, fBlocking, iExpectedRc));
    374375        reporter.log2('Arguments: %s' % (asArgs,));
    375376        if asEnv:
     
    381382        except: pass;
    382383
     384        fRc = False;
     385        iRc = -42;
     386
    383387        if fBlocking: # Run in same thread (blocking).
    384             fRc = self.executeHstLoop(sWhat, asArgs, asEnv, fAsAdmin);
     388            fRc, iRc = self.executeHstLoop(sWhat, asArgs, asEnv, fAsAdmin);
    385389        else: # Run in separate thread (asynchronous).
    386390            self.iThreadHstProcRc = -42; # Initialize thread rc.
     
    393397                    self.processEvents(0);
    394398                reporter.log2('Thread returned exit code for "%s": %d' % (sWhat, self.iThreadHstProcRc));
     399                fRc = True;
     400                iRc = self.iThreadHstProcRc;
    395401            except:
    396402                reporter.logXcpt('Starting thread for "%s" failed' % (sWhat,));
    397             fRc = self.iThreadHstProcRc == 0;
    398 
    399         return fRc;
     403
     404        # Adjust fRc if caller expected a specific exit code.
     405        if  iExpectedRc \
     406        and iRc is not iExpectedRc:
     407            reporter.error('Executing \"%s\" on host failed (got exit code %d, expected %d'
     408                           % (sWhat, iRc, iExpectedRc,));
     409            fRc = False;
     410
     411        return fRc, iRc;
    400412
    401413    def getWinFirewallArgsDisable(self, sOsType):
     
    470482            asArgs = self.getWinFirewallArgsDisable('vista');
    471483            if asArgs:
    472                 fRc = self.executeHst('Disabling host firewall', asArgs, fAsAdmin = True);
     484                fRc, _ = self.executeHst('Disabling host firewall', asArgs, fAsAdmin = True);
    473485        else:
    474486            reporter.log('Firewall not available on host, skipping');
     
    609621        # Let VKAT on the host run synchronously.
    610622        #
    611         fRc = self.executeHst("VKAT Host", asArgs);
     623        fRc, _ = self.executeHst("VKAT Host", asArgs);
    612624
    613625        reporter.testDone();
     
    633645                asArgs += self.asVkatVerifyArgs;
    634646
    635             fRc = self.executeHst("VKAT Host Verify", asArgs);
     647            fRc, _ = self.executeHst("VKAT Host Verify", asArgs, iExpectedRc = 0);
    636648            if fRc:
    637649                reporter.log("Verification audio data successful");
     
    736748        # Doesn't take long and gives us some more clue if it flies on the testboxes.
    737749        reporter.testStart('VKAT Selftest');
    738         fRc = self.executeHst("VKAT Host Selftest", [ sVkatExe, 'selftest' ]);
     750        fRc, _ = self.executeHst("VKAT Host Selftest", [ sVkatExe, 'selftest' ], iExpectedRc = 0);
    739751        reporter.testDone();
    740752        if not fRc:
     
    742754
    743755        # Now probe the backends.
     756        reporter.testStart('VKAT Probing');
    744757        asArgs   = [ sVkatExe, 'enum', '--probe-backends' ];
    745758        for _ in range(1, reporter.getVerbosity()): # Verbosity always is initialized at 1.
    746759            asArgs.extend([ '-v' ]);
    747         fRc      = self.executeHst("VKAT Host Audio Probing", asArgs);
    748         if not fRc:
     760        fRc, iRc = self.executeHst("VKAT Host Audio Probing", asArgs);
     761        if iRc != 0:
    749762            # Not fatal, as VBox then should fall back to the NULL audio backend (also worth having as a test case).
    750763            reporter.log('Warning: Backend probing on host failed, no audio available (pure server installation?)');
     764        reporter.testDone();
    751765
    752766        # Reconfigure the VM.
Note: See TracChangeset for help on using the changeset viewer.

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