VirtualBox

Changeset 84590 in vbox


Ignore:
Timestamp:
May 28, 2020 1:13:09 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138320
Message:

Main: bugref:9341: Added powering down the VM by calling the guest process in the testcase

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py

    r84559 r84590  
    605605        return fRc;
    606606
     607    def powerDownVM(self, oSession):
     608        """
     609        Power down the VM by calling guest process without wating
     610        the VM is really powered off.
     611        It helps the terminateBySession to stop the VM without aborting.
     612        """
     613
     614        fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
     615                                            'vbox', 'password', 10 * 1000, True);
     616        if not fRc:
     617            return fRc;
     618
     619        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM',
     620                                                  30 * 1000, '/usr/bin/sudo',
     621                                                  ['sudo', 'poweroff'],
     622                                                  False, True);
     623        fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
     624        return fRc;
     625
    607626    def installAdditions(self, oSession, oVM):
    608627        """
     
    924943
    925944        fRc = fRc and self.waitVMisReady(oSession);
     945        return fRc;
     946
     947    def powerDownVM(self, oSession):
     948        """
     949        Power down the VM by calling guest process without wating
     950        the VM is really powered off.
     951        It helps the terminateBySession to stop the VM without aborting.
     952        """
     953
     954        fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox',
     955                                            'vbox', 'password', 10 * 1000, True);
     956        if not fRc:
     957            return fRc;
     958
     959        (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM',
     960                                                  30 * 1000, 'C:\\Windows\\System32\\shutdown.exe',
     961                                                  ['C:\\Windows\\System32\\shutdown.exe', '/f',
     962                                                   '/s', '/t', '0'],
     963                                                  False, True);
     964        fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack.
    926965        return fRc;
    927966
     
    14281467            else:
    14291468                reporter.log('Creating test users failed');
     1469
     1470            try:    oGuestOsHlp.powerDownVM(oSession);
     1471            except: pass;
     1472
    14301473        else:
    14311474            reporter.log('Guest OS helper not created for VM %s' % (sVmName));
     
    14801523            if oSession is not None:
    14811524                fRc = self.testAutostartRunProgs(oSession, sVmName, oVM);
    1482                 self.terminateVmBySession(oSession);
     1525                try:    self.terminateVmBySession(oSession);
     1526                except: pass;
    14831527                self.deleteVM(oVM);
    14841528            else:
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