Changeset 87113 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Dec 22, 2020 3:59:02 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py
r86558 r87113 1 1 #!/usr/bin/env python 2 2 # -*- coding: utf-8 -*- 3 4 3 """ 5 4 Autostart testcase using. 6 5 """ 7 6 #from pykickstart.commands import repo 8 9 7 __copyright__ = \ 10 8 """ 11 9 Copyright (C) 2013-2020 Oracle Corporation 12 13 10 This file is part of VirtualBox Open Source Edition (OSE), as 14 11 available from http://www.virtualbox.org. This file is free software; … … 18 15 VirtualBox OSE distribution. VirtualBox OSE is distributed in the 19 16 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 20 21 17 The contents of this file may alternatively be used under the terms 22 18 of the Common Development and Distribution License Version 1.0 … … 24 20 VirtualBox OSE distribution, in which case the provisions of the 25 21 CDDL are applicable instead of those of the GPL. 26 27 22 You may elect to license modified versions of this file under the 28 23 terms and conditions of either the GPL or the CDDL or both. 29 24 """ 30 25 __version__ = "$Id$" 31 32 33 26 # Standard Python imports. 34 27 import os; 35 28 import sys; 36 29 import re; 37 38 30 # Only the main script needs to modify the path. 39 31 try: __file__ … … 41 33 g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))); 42 34 sys.path.append(g_ksValidationKitDir); 43 44 35 # Validation Kit imports. 45 36 from testdriver import reporter; … … 47 38 from testdriver import vbox; 48 39 from testdriver import vboxcon; 40 from testdriver import vboxtestvms; 49 41 from testdriver import vboxwrappers; 50 51 52 42 class VBoxManageStdOutWrapper(object): 53 43 """ Parser for VBoxManage list runningvms """ 54 44 def __init__(self): 55 45 self.sVmRunning = ''; 56 57 46 def __del__(self): 58 47 self.close(); 59 60 48 def close(self): 61 49 """file.close""" 62 50 return; 63 64 51 def read(self, cb): 65 52 """file.read""" 66 53 _ = cb; 67 54 return ""; 68 69 55 def write(self, sText): 70 56 """VBoxManage stdout write""" 71 57 if sText is None: 72 58 return None; 73 74 59 try: sText = str(sText); # pylint: disable=redefined-variable-type 75 60 except: pass; 76 77 61 asLines = sText.splitlines(); 78 62 for sLine in asLines: 79 63 sLine = sLine.strip(); 80 81 64 reporter.log('Logging: ' + sLine); 82 83 65 # Extract the value 84 66 idxVmNameStart = sLine.find('"'); 85 67 if idxVmNameStart == -1: 86 68 raise Exception('VBoxManageStdOutWrapper: Invalid output'); 87 88 69 idxVmNameStart += 1; 89 70 idxVmNameEnd = idxVmNameStart; 90 71 while sLine[idxVmNameEnd] != '"': 91 72 idxVmNameEnd += 1; 92 93 73 self.sVmRunning = sLine[idxVmNameStart:idxVmNameEnd]; 94 74 reporter.log('Logging: ' + self.sVmRunning); 95 96 75 return None; 97 98 99 class tdAutostartOs(object): 76 class tdAutostartOs(vboxtestvms.BaseTestVm): 100 77 """ 101 78 Base autostart helper class to provide common methods. 102 79 """ 103 104 def __init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso): 80 def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None, \ 81 cCpus = 1, fPae = None, sGuestAdditionsIso = None): 82 vboxtestvms.BaseTestVm.__init__(self, sVmName, oSet = oSet, sKind = sKind); 105 83 self.oTstDrv = oTstDrv; 106 self.fpApiVer = fpApiVer; 84 self.sHdd = sHdd; 85 self.eNic0Type = eNic0Type; 86 self.cMbRam = cMbRam; 87 self.cCpus = cCpus; 88 self.fPae = fPae; 107 89 self.sGuestAdditionsIso = sGuestAdditionsIso; 108 90 self._asTestBuildDirs = []; 91 self.sVBoxInstaller = ""; 92 self.asVirtModesSup = ['hwvirt-np',]; 93 self.asParavirtModesSup = ['default',]; 94 @property 95 def asTestBuildDirs(self): 96 return self._asTestBuildDirs; 97 @asTestBuildDirs.setter 98 def asTestBuildDirs(self, value): 99 self._asTestBuildDirs = value; 100 self.sTestBuild = self._findFile(self.sVBoxInstaller, value); 101 if not self.sTestBuild: 102 raise base.GenError("VirtualBox install package not found"); 109 103 def _findFile(self, sRegExp, asTestBuildDirs): 110 104 """ … … 112 106 or None if no matching file is found. 113 107 """ 114 115 108 oRegExp = re.compile(sRegExp); 116 109 for sTestBuildDir in asTestBuildDirs: … … 128 121 except: 129 122 pass; 130 131 123 reporter.error('Failed to find a file matching "%s" in %s.' % (sRegExp, ','.join(asTestBuildDirs))); 132 124 return None; 133 134 125 def _createAutostartCfg(self, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()): 135 126 """ 136 127 Creates a autostart config for VirtualBox 137 128 """ 138 139 129 sVBoxCfg = 'default_policy=' + sDefaultPolicy + '\n'; 140 141 130 for sUserAllow in asUserAllow: 142 131 sVBoxCfg = sVBoxCfg + sUserAllow + ' = {\n allow = true\n }\n'; 143 144 132 for sUserDeny in asUserDeny: 145 133 sVBoxCfg = sVBoxCfg + sUserDeny + ' = {\n allow = false\n }\n'; 146 147 134 return sVBoxCfg; 148 149 135 def _waitAdditionsIsRunning(self, oGuest, fWaitTrayControl): 150 136 """ … … 166 152 if fRc: 167 153 break; 168 169 154 self.oTstDrv.sleep(10); 170 155 cAttempt += 1; 171 156 return fRc; 172 173 157 def createSession(self, oSession, sName, sUser, sPassword, cMsTimeout = 10 * 1000, fIsError = True): 174 158 """ … … 179 163 if sName is None: 180 164 sName = "<untitled>"; 181 182 165 reporter.log('Creating session "%s" ...' % (sName,)); 183 166 try: … … 188 171 % (sName, sUser, sPassword)); 189 172 return (False, None); 190 191 173 reporter.log('Waiting for session "%s" to start within %dms...' % (sName, cMsTimeout)); 192 174 aeWaitFor = [ vboxcon.GuestSessionWaitForFlag_Start, ]; 193 175 try: 194 176 waitResult = oGuestSession.waitForArray(aeWaitFor, cMsTimeout); 195 196 177 # 197 178 # Be nice to Guest Additions < 4.3: They don't support session handling and … … 209 190 return (False, None); 210 191 return (True, oGuestSession); 211 212 192 def closeSession(self, oGuestSession, fIsError = True): 213 193 """ … … 219 199 except: 220 200 return reporter.errorXcpt(); 221 222 201 reporter.log('Closing session "%s" ...' % (sName,)); 223 202 try: … … 229 208 return False; 230 209 return True; 231 232 210 def guestProcessExecute(self, oGuestSession, sTestName, cMsTimeout, sExecName, asArgs = (), 233 211 fGetStdOut = True, fIsError = True): … … 238 216 _ = sTestName; 239 217 fRc = True; # Be optimistic. 240 241 218 reporter.log2('Using session user=%s, name=%s, timeout=%d' 242 219 % (oGuestSession.user, oGuestSession.name, oGuestSession.timeout,)); 243 244 220 # 245 221 # Start the process: … … 253 229 try: 254 230 oProcess = oGuestSession.processCreate(sExecName, 255 asArgs if self. fpApiVer >= 5.0 else asArgs[1:],231 asArgs if self.oTstDrv.fpApiVer >= 5.0 else asArgs[1:], 256 232 [], fTaskFlags, cMsTimeout); 257 233 except: … … 260 236 if oProcess is None: 261 237 return (reporter.error('oProcess is None! (%s)' % (asArgs,)), 0, 0, None); 262 263 238 #time.sleep(5); # try this if you want to see races here. 264 265 239 # Wait for the process to start properly: 266 240 reporter.log2('Process start requested, waiting for start (%dms) ...' % (cMsTimeout,)); … … 281 255 else: 282 256 reporter.log2('Wait result returned: %d, current process status is: %d' % (eWaitResult, eStatus,)); 283 284 257 # 285 258 # Wait for the process to run to completion if necessary. … … 289 262 # 290 263 if eStatus == vboxcon.ProcessStatus_Started: 291 292 264 # What to wait for: 293 265 aeWaitFor = [ vboxcon.ProcessWaitForFlag_Terminate, 294 266 vboxcon.ProcessWaitForFlag_StdOut, 295 267 vboxcon.ProcessWaitForFlag_StdErr]; 296 297 268 reporter.log2('Process (PID %d) started, waiting for termination (%dms), aeWaitFor=%s ...' 298 269 % (iPid, cMsTimeout, aeWaitFor)); … … 310 281 break; 311 282 reporter.log2('Wait returned: %d' % (eWaitResult,)); 312 313 283 # Process output: 314 284 for eFdResult, iFd, sFdNm in [ (vboxcon.ProcessWaitResult_StdOut, 1, 'stdout'), … … 339 309 else: 340 310 aBuf = sBuf; 341 342 311 ## Process input (todo): 343 312 #if eWaitResult in (vboxcon.ProcessWaitResult_StdIn, vboxcon.ProcessWaitResult_WaitFlagNotSupported): 344 313 # reporter.log2('Process (PID %d) needs stdin data' % (iPid,)); 345 346 314 # Termination or error? 347 315 if eWaitResult in (vboxcon.ProcessWaitResult_Terminate, … … 353 321 % (iPid, eWaitResult, eStatus,)); 354 322 break; 355 356 323 # End of the wait loop. 357 324 _, cbStdOut, cbStdErr = acbFdOut; 358 359 325 try: eStatus = oProcess.status; 360 326 except: fRc = reporter.errorXcpt('asArgs=%s' % (asArgs,)); 361 327 reporter.log2('Final process status (PID %d) is: %d' % (iPid, eStatus)); 362 328 reporter.log2('Process (PID %d) %d stdout, %d stderr' % (iPid, cbStdOut, cbStdErr)); 363 364 329 # 365 330 # Get the final status and exit code of the process. … … 371 336 fRc = reporter.errorXcpt('asArgs=%s' % (asArgs,)); 372 337 reporter.log2('Process (PID %d) has exit code: %d; status: %d ' % (iPid, iExitCode, uExitStatus)); 373 374 338 return (fRc, uExitStatus, iExitCode, aBuf); 375 376 339 def uploadString(self, oGuestSession, sSrcString, sDst): 377 340 """ … … 393 356 except: 394 357 fRc = reporter.errorXcpt('Upload string failed. Could not close the file %s' % sDst); 395 396 return fRc; 397 358 return fRc; 398 359 def uploadFile(self, oGuestSession, sSrc, sDst): 399 360 """ … … 402 363 fRc = True; 403 364 try: 404 if self. fpApiVer >= 5.0:365 if self.oTstDrv.fpApiVer >= 5.0: 405 366 oCurProgress = oGuestSession.fileCopyToGuest(sSrc, sDst, [0]); 406 367 else: … … 419 380 else: 420 381 fRc = reporter.error('No progress object returned'); 421 422 return fRc; 423 382 return fRc; 424 383 def downloadFile(self, oGuestSession, sSrc, sDst, fIgnoreErrors = False): 425 384 """ … … 428 387 fRc = True; 429 388 try: 430 if self. fpApiVer >= 5.0:389 if self.oTstDrv.fpApiVer >= 5.0: 431 390 oCurProgress = oGuestSession.fileCopyFromGuest(sSrc, sDst, [0]); 432 391 else: … … 452 411 reporter.log('warning: No progress object returned'); 453 412 fRc = False; 454 455 return fRc; 456 413 return fRc; 457 414 def downloadFiles(self, oGuestSession, asFiles, fIgnoreErrors = False): 458 415 """ 459 416 Convenience function to get files from the guest and stores it 460 417 into the scratch directory for later (manual) review. 461 462 418 Returns True on success. 463 464 419 Returns False on failure, logged. 465 420 """ … … 485 440 reporter.log('warning: file "%s" was not downloaded, ignoring.' % (sGstFile,)); 486 441 return True; 487 488 489 class tdAutostartOsLinux(tdAutostartOs): 490 """ 491 Autostart support methods for Linux guests. 492 """ 493 494 def __init__(self, oTstDrv, asTestBuildDirs, fpApiVer, sGuestAdditionsIso): 495 tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso); 496 self.sTestBuild = self._findFile('^VirtualBox-.*\\.run$', asTestBuildDirs); 497 if not self.sTestBuild: 498 raise base.GenError("VirtualBox install package not found"); 499 442 def _checkVmIsReady(self, oGuestSession): 443 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process', 444 30 * 1000, '/sbin/ifconfig', 445 ['ifconfig',], 446 False, False); 447 return fRc; 500 448 def waitVmIsReady(self, oSession, fWaitTrayControl): 501 449 """ … … 506 454 # Give the VM a time to reboot 507 455 self.oTstDrv.sleep(30); 508 509 456 # Waiting the VM is ready. 510 457 # To do it, one will try to open the guest session and start the guest process in loop 511 512 458 if not self._waitAdditionsIsRunning(oSession.o.console.guest, False): 513 459 return (False, None); 514 515 460 cAttempt = 0; 516 461 oGuestSession = None; … … 520 465 'vbox', 'password', 10 * 1000, False); 521 466 if fRc: 522 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process', 523 30 * 1000, '/sbin/ifconfig', 524 ['ifconfig',], 525 False, False); 467 fRc = self._checkVmIsReady(oGuestSession); 526 468 if fRc: 527 469 break; 528 529 470 self.closeSession(oGuestSession, False); 530 531 471 self.oTstDrv.sleep(10); 532 472 cAttempt += 1; 533 534 473 return (fRc, oGuestSession); 535 536 def rebootVMAndCheckReady(self, oSession, oGuestSession): 537 """ 538 Reboot the VM and wait the VM is ready. 539 Returns result and guest session obtained after reboot 540 """ 541 reporter.testStart('Reboot VM and wait for readiness'); 474 def _rebootVM(self, oGuestSession): 542 475 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM', 543 476 30 * 1000, '/usr/bin/sudo', … … 546 479 if not fRc: 547 480 reporter.error('Calling the reboot utility failed'); 481 return fRc; 482 def rebootVMAndCheckReady(self, oSession, oGuestSession): 483 """ 484 Reboot the VM and wait the VM is ready. 485 Returns result and guest session obtained after reboot 486 """ 487 reporter.testStart('Reboot VM and wait for readiness'); 488 fRc = self._rebootVM(oGuestSession); 548 489 fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack. 549 490 if fRc: 550 491 (fRc, oGuestSession) = self.waitVmIsReady(oSession, False); 551 552 492 if not fRc: 553 493 reporter.error('VM is not ready after reboot'); 554 494 reporter.testDone(); 555 495 return (fRc, oGuestSession); 556 557 def powerDownVM(self, oGuestSession): 558 """ 559 Power down the VM by calling guest process without wating 560 the VM is really powered off. Also, closes the guest session. 561 It helps the terminateBySession to stop the VM without aborting. 562 """ 563 564 if oGuestSession is None: 565 return False; 566 567 reporter.testStart('Power down the VM'); 568 496 def _powerDownVM(self, oGuestSession): 569 497 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM', 570 498 30 * 1000, '/usr/bin/sudo', … … 573 501 if not fRc: 574 502 reporter.error('Calling the poweroff utility failed'); 503 return fRc; 504 def powerDownVM(self, oGuestSession): 505 """ 506 Power down the VM by calling guest process without wating 507 the VM is really powered off. Also, closes the guest session. 508 It helps the terminateBySession to stop the VM without aborting. 509 """ 510 if oGuestSession is None: 511 return False; 512 reporter.testStart('Power down the VM'); 513 fRc = self._powerDownVM(oGuestSession); 575 514 fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack. 576 577 515 if not fRc: 578 516 reporter.error('Power down the VM failed'); 579 517 reporter.testDone(); 580 518 return fRc; 581 582 519 def installAdditions(self, oSession, oGuestSession, oVM): 583 520 """ 521 Installs the Windows guest additions using the test execution service. 522 """ 523 _ = oSession; 524 _ = oGuestSession; 525 _ = oVM; 526 reporter.error('Not implemented'); 527 return False; 528 def installVirtualBox(self, oGuestSession): 529 """ 530 Install VirtualBox in the guest. 531 """ 532 _ = oGuestSession; 533 reporter.error('Not implemented'); 534 return False; 535 def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()): 536 """ 537 Configures the autostart feature in the guest. 538 """ 539 _ = oGuestSession; 540 _ = sDefaultPolicy; 541 _ = asUserAllow; 542 _ = asUserDeny; 543 reporter.error('Not implemented'); 544 return False; 545 def createUser(self, oGuestSession, sUser): 546 """ 547 Create a new user with the given name 548 """ 549 _ = oGuestSession; 550 _ = sUser; 551 reporter.error('Not implemented'); 552 return False; 553 def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName): 554 """ 555 Check for VM running in the guest after autostart. 556 Due to the sUser is created whithout password, 557 all calls will be perfomed using 'sudo -u sUser' 558 """ 559 _ = oSession; 560 _ = oGuestSession; 561 _ = sUser; 562 _ = sVmName; 563 reporter.error('Not implemented'); 564 return False; 565 def getResourceSet(self): 566 asRet = []; 567 if not os.path.isabs(self.sHdd): 568 asRet.append(self.sHdd); 569 return asRet; 570 def _createVmDoIt(self, oTestDrv, eNic0AttachType, sDvdImage): 571 """ 572 Creates the VM. 573 Returns Wrapped VM object on success, None on failure. 574 """ 575 _ = eNic0AttachType; 576 _ = sDvdImage; 577 return oTestDrv.createTestVM(self.sVmName, self.iGroup, self.sHdd, sKind = self.sKind, \ 578 fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \ 579 eNic0Type = self.eNic0Type, cMbRam = self.cMbRam, \ 580 sHddControllerType = "SATA Controller", fPae = self.fPae, \ 581 cCpus = self.cCpus, sDvdImage = self.sGuestAdditionsIso); 582 def _createVmPost(self, oTestDrv, oVM, eNic0AttachType, sDvdImage): 583 _ = eNic0AttachType; 584 _ = sDvdImage; 585 fRc = True; 586 oSession = oTestDrv.openSession(oVM); 587 if oSession is not None: 588 fRc = fRc and oSession.enableVirtEx(True); 589 fRc = fRc and oSession.enableNestedPaging(True); 590 fRc = fRc and oSession.enableNestedHwVirt(True); 591 # disable 3D until the error is fixed. 592 fRc = fRc and oSession.setAccelerate3DEnabled(False); 593 fRc = fRc and oSession.setVRamSize(256); 594 fRc = fRc and oSession.setVideoControllerType(vboxcon.GraphicsControllerType_VBoxSVGA); 595 fRc = fRc and oSession.enableUsbOhci(True); 596 fRc = fRc and oSession.enableUsbHid(True); 597 fRc = fRc and oSession.saveSettings(); 598 fRc = oSession.close() and fRc and True; # pychecker hack. 599 oSession = None; 600 else: 601 fRc = False; 602 return oVM if fRc else None; 603 def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None): 604 # 605 # Current test uses precofigured VMs. This override disables any changes in the machine. 606 # 607 _ = cCpus; 608 _ = sVirtMode; 609 _ = sParavirtMode; 610 oVM = oTestDrv.getVmByName(self.sVmName); 611 if oVM is None: 612 return (False, None); 613 return (True, oVM); 614 class tdAutostartOsLinux(tdAutostartOs): 615 """ 616 Autostart support methods for Linux guests. 617 """ 618 def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None, \ 619 cCpus = 1, fPae = None, sGuestAdditionsIso = None): 620 tdAutostartOs.__init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type, cMbRam, \ 621 cCpus, fPae, sGuestAdditionsIso); 622 self.sVBoxInstaller = '^VirtualBox-.*\\.run$'; 623 return; 624 def installAdditions(self, oSession, oGuestSession, oVM): 625 """ 584 626 Install guest additions in the guest. 585 627 """ 586 628 reporter.testStart('Install Guest Additions'); 587 588 629 fRc = False; 589 630 # Install Kernel headers, which are required for actually installing the Linux Additions. … … 604 645 if not fRc: 605 646 reporter.error('Error installing additional installer dependencies'); 606 607 647 elif oVM.OSTypeId.startswith('OL') \ 608 648 or oVM.OSTypeId.startswith('Oracle') \ … … 623 663 if not fRc: 624 664 reporter.error('Error installing additional installer dependencies'); 625 626 665 else: 627 666 reporter.error('Installing Linux Additions for the "%s" is not supported yet' % oVM.OSTypeId); 628 667 fRc = False; 629 630 668 if fRc: 631 669 # … … 633 671 # Also tell the installer to produce the appropriate log files. 634 672 # 635 636 673 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Installing guest additions', 637 674 10 * 60 *1000, '/usr/bin/sudo', … … 645 682 if fRc: 646 683 (fRc, oGuestSession) = self.waitVmIsReady(oSession, False); 647 648 684 # Download log files. 649 685 # Ignore errors as all files above might not be present for whatever reason. … … 655 691 else: 656 692 reporter.error('Installing guest additions failed: Error occured during vbox installer execution') 657 658 693 if fRc: 659 694 (fRc, oGuestSession) = self.rebootVMAndCheckReady(oSession, oGuestSession); … … 662 697 reporter.testDone(); 663 698 return (fRc, oGuestSession); 664 665 699 def installVirtualBox(self, oGuestSession): 666 700 """ … … 669 703 if self.sTestBuild is None: 670 704 return False; 671 672 705 reporter.testStart('Install Virtualbox into the guest VM'); 673 706 reporter.log("Virtualbox install file: %s" % os.path.basename(self.sTestBuild)); 674 675 707 fRc = self.uploadFile(oGuestSession, self.sTestBuild, 676 708 '/tmp/' + os.path.basename(self.sTestBuild)); … … 696 728 reporter.testDone(); 697 729 return fRc; 698 699 730 def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()): 700 731 """ … … 732 763 if not fRc: 733 764 reporter.error('Setting permissions for the virtualbox failed'); 734 735 765 if fRc: 736 766 sVBoxCfg = self._createAutostartCfg(sDefaultPolicy, asUserAllow, asUserDeny); … … 738 768 if not fRc: 739 769 reporter.error('Upload to /tmp/autostart.cfg failed'); 740 741 770 if fRc: 742 771 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Moving to destination', … … 757 786 reporter.testDone(); 758 787 return fRc; 759 760 788 def createUser(self, oGuestSession, sUser): 761 789 """ … … 771 799 reporter.testDone(); 772 800 return fRc; 773 774 801 # pylint: enable=too-many-arguments 775 776 802 def createTestVM(self, oSession, oGuestSession, sUser, sVmName): 777 803 """ … … 780 806 all calls will be perfomed using 'sudo -u sUser' 781 807 """ 782 783 808 _ = oSession; 784 785 809 reporter.testStart('Create test VM for user %s' % sUser); 786 787 810 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Configuring autostart database', 788 811 30 * 1000, '/usr/bin/sudo', … … 810 833 reporter.testDone(); 811 834 return fRc; 812 813 835 def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName): 814 836 """ … … 817 839 all calls will be perfomed using 'sudo -u sUser' 818 840 """ 819 820 841 self.oTstDrv.sleep(30); 821 822 842 _ = oSession; 823 824 843 reporter.testStart('Check the VM %s is running for user %s' % (sVmName, sUser)); 825 844 (fRc, _, _, aBuf) = self.guestProcessExecute(oGuestSession, 'Check for running VM', … … 834 853 bufWrapper.write(aBuf); 835 854 fRc = bufWrapper.sVmRunning == sVmName; 836 837 855 reporter.testDone(); 838 856 return fRc; 839 840 841 857 class tdAutostartOsDarwin(tdAutostartOs): 842 858 """ 843 859 Autostart support methods for Darwin guests. 844 860 """ 845 846 def __init__(self, oTstDrv, sTestBuildDir, fpApiVer, sGuestAdditionsIso):847 _ = sTestBuildDir;848 tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);861 def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None, \ 862 cCpus = 1, fPae = None, sGuestAdditionsIso = None): 863 tdAutostartOs.__init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type, cMbRam, \ 864 cCpus, fPae, sGuestAdditionsIso); 849 865 raise base.GenError('Testing the autostart functionality for Darwin is not implemented'); 850 851 852 866 class tdAutostartOsSolaris(tdAutostartOs): 853 867 """ 854 868 Autostart support methods for Solaris guests. 855 869 """ 856 857 def __init__(self, oTstDrv, sTestBuildDir, fpApiVer, sGuestAdditionsIso):858 _ = sTestBuildDir;859 tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso);870 def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None, \ 871 cCpus = 1, fPae = None, sGuestAdditionsIso = None): 872 tdAutostartOs.__init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type, cMbRam, \ 873 cCpus, fPae, sGuestAdditionsIso); 860 874 raise base.GenError('Testing the autostart functionality for Solaris is not implemented'); 861 862 863 875 class tdAutostartOsWin(tdAutostartOs): 864 876 """ 865 877 Autostart support methods for Windows guests. 866 878 """ 867 868 def __init__(self, oTstDrv, asTestBuildDirs, fpApiVer, sGuestAdditionsIso): 869 tdAutostartOs.__init__(self, oTstDrv, fpApiVer, sGuestAdditionsIso); 870 self.sTestBuild = self._findFile('^VirtualBox-.*\\.(exe|msi)$', asTestBuildDirs); 871 if not self.sTestBuild: 872 raise base.GenError("VirtualBox install package not found"); 879 def __init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type = None, cMbRam = None, \ 880 cCpus = 1, fPae = None, sGuestAdditionsIso = None): 881 tdAutostartOs.__init__(self, oSet, oTstDrv, sVmName, sKind, sHdd, eNic0Type, cMbRam, \ 882 cCpus, fPae, sGuestAdditionsIso); 883 self.sVBoxInstaller = '^VirtualBox-.*\\.(exe|msi)$'; 873 884 return; 874 875 def waitVmIsReady(self, oSession, fWaitTrayControl, fWaitFacility = True): 876 """ 877 Waits the VM is ready after start or reboot. 878 """ 879 # Give the VM a time to reboot 880 self.oTstDrv.sleep(30); 881 882 # Waiting the VM is ready. 883 # To do it, one will try to open the guest session and start the guest process in loop 884 885 if fWaitFacility and not self._waitAdditionsIsRunning(oSession.o.console.guest, fWaitTrayControl): 886 return (False, None); 887 888 cAttempt = 0; 889 oGuestSession = None; 890 while cAttempt < 10: 891 fRc, oGuestSession = self.createSession(oSession, 'Session for user: vbox', 'vbox', 'password', 10 * 1000, False); 892 if fRc: 893 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process', 894 30 * 1000, 'C:\\Windows\\System32\\ipconfig.exe', 895 ['C:\\Windows\\System32\\ipconfig.exe',], 896 False, False); 897 if fRc: 898 break; 899 self.closeSession(oGuestSession, False); 900 901 self.oTstDrv.sleep(10); 902 cAttempt += 1; 903 904 return (fRc, oGuestSession); 905 906 def rebootVMAndCheckReady(self, oSession, oGuestSession): 907 """ 908 Reboot the VM and wait the VM is ready. 909 """ 910 reporter.testStart('Reboot VM and wait for readiness'); 885 def _checkVmIsReady(self, oGuestSession): 886 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process', 887 30 * 1000, 'C:\\Windows\\System32\\ipconfig.exe', 888 ['C:\\Windows\\System32\\ipconfig.exe',], 889 False, False); 890 return fRc; 891 def _rebootVM(self, oGuestSession): 911 892 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM', 912 893 30 * 1000, 'C:\\Windows\\System32\\shutdown.exe', … … 916 897 if not fRc: 917 898 reporter.error('Calling the shutdown utility failed'); 918 fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack. 919 if fRc: 920 (fRc, oGuestSession) = self.waitVmIsReady(oSession, True); 921 if not fRc: 922 reporter.error('VM is not ready after reboot'); 923 reporter.testDone(); 924 return (fRc, oGuestSession); 925 926 def powerDownVM(self, oGuestSession): 927 """ 928 Power down the VM by calling guest process without wating 929 the VM is really powered off. Also, closes the guest session. 930 It helps the terminateBySession to stop the VM without aborting. 931 """ 932 933 if oGuestSession is None: 934 return False; 935 936 reporter.testStart('Power down the VM'); 899 return fRc; 900 def _powerDownVM(self, oGuestSession): 937 901 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM', 938 902 30 * 1000, 'C:\\Windows\\System32\\shutdown.exe', … … 942 906 if not fRc: 943 907 reporter.error('Calling the shutdown utility failed'); 944 fRc = self.closeSession(oGuestSession, True) and fRc and True; # pychecker hack. 945 if not fRc: 946 reporter.error('Power down the VM failed'); 947 reporter.testDone(); 948 return fRc; 949 908 return fRc; 950 909 def installAdditions(self, oSession, oGuestSession, oVM): 951 910 """ … … 955 914 reporter.testStart('Install Guest Additions'); 956 915 asLogFiles = []; 957 958 916 fRc = self.closeSession(oGuestSession, True); # pychecker hack. 959 960 917 try: 961 918 oCurProgress = oSession.o.console.guest.updateGuestAdditions(self.sGuestAdditionsIso, ['/l',], None); … … 974 931 else: 975 932 fRc = reporter.error('No progress object returned'); 976 977 933 #--------------------------------------- 978 934 # … … 1016 972 # (fRc, oGuestSession) = self.waitVmIsReady(oSession, False, False); 1017 973 #--------------------------------------- 1018 1019 974 # Store the result and try download logs anyway. 1020 975 fGaRc = fRc; … … 1030 985 # Note: There won't be a install_ui.log because of the silent installation. 1031 986 asLogFiles.append(sGuestAddsDir + 'install_drivers.log'); 1032 1033 987 # Download log files. 1034 988 # Ignore errors as all files above might not be present (or in different locations) … … 1042 996 reporter.testDone(); 1043 997 return (fRc and fGaRc, oGuestSession); 1044 1045 998 def installVirtualBox(self, oGuestSession): 1046 999 """ 1047 1000 Install VirtualBox in the guest. 1048 1001 """ 1049 1050 1002 if self.sTestBuild is None: 1051 1003 return False; … … 1086 1038 reporter.log('Content of VirtualBxox folder:'); 1087 1039 reporter.log(str(aBuf)); 1088 1089 1040 asLogFiles = [sLogFile,]; 1090 1041 self.downloadFiles(oGuestSession, asLogFiles, fIgnoreErrors = True); 1091 1092 1042 reporter.testDone(); 1093 1043 return fRc; 1094 1095 1044 def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()): 1096 1045 """ … … 1098 1047 """ 1099 1048 reporter.testStart('Configure autostart'); 1100 1101 1049 # Create autostart database directory writeable for everyone 1102 1050 (fRc, _, _, _) = \ … … 1115 1063 else: 1116 1064 reporter.error('Setting the autostart environment variable failed'); 1117 1118 1065 reporter.testDone(); 1119 1066 return fRc; 1120 1121 1067 def createTestVM(self, oSession, oGuestSession, sUser, sVmName): 1122 1068 """ … … 1124 1070 """ 1125 1071 _ = oGuestSession; 1126 1127 1072 reporter.testStart('Create test VM for user %s' % sUser); 1128 1129 1073 fRc, oGuestSession = self.createSession(oSession, 'Session for user: %s' % (sUser,), 1130 1074 sUser, 'password', 10 * 1000, True); … … 1167 1111 reporter.testDone(); 1168 1112 return fRc; 1169 1170 1113 def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName): 1171 1114 """ 1172 1115 Check for VM running in the guest after autostart. 1173 1116 """ 1174 1175 1117 self.oTstDrv.sleep(30); 1176 1177 1118 _ = oGuestSession; 1178 1179 1119 reporter.testStart('Check the VM %s is running for user %s' % (sVmName, sUser)); 1180 1181 1120 fRc, oGuestSession = self.createSession(oSession, 'Session for user: %s' % (sUser,), 1182 1121 sUser, 'password', 10 * 1000, True); … … 1184 1123 reporter.error('Create session for user %s failed' % sUser); 1185 1124 else: 1186 1187 1188 1125 (fRc, _, _, aBuf) = self.guestProcessExecute(oGuestSession, 'Check for running VM', 1189 1126 60 * 1000, 'C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe', … … 1193 1130 reporter.error('Checking the VM %s is running for user %s failed' % (sVmName, sUser)); 1194 1131 else: 1195 1196 1132 bufWrapper = VBoxManageStdOutWrapper(); 1197 1133 bufWrapper.write(aBuf); 1198 1134 fRc = bufWrapper.sVmRunning == sVmName; 1199 1200 1135 fRc1 = self.closeSession(oGuestSession, True); 1201 1136 if not fRc1: … … 1204 1139 reporter.testDone(); 1205 1140 return fRc; 1206 1207 1141 def createUser(self, oGuestSession, sUser): 1208 1142 """ … … 1223 1157 if not fRc: 1224 1158 reporter.error('Adding the user %s to Administrators group failed' % sUser); 1225 1226 1159 #Allow the user to logon as service 1227 1160 if fRc: … … 1277 1210 reporter.testDone(); 1278 1211 return fRc; 1279 1280 1281 1212 class tdAutostart(vbox.TestDriver): # pylint: disable=too-many-instance-attributes 1282 1213 """ 1283 1214 Autostart testcase. 1284 1215 """ 1285 1286 1216 ksOsLinux = 'tst-linux' 1287 1217 ksOsWindows = 'tst-win' … … 1289 1219 ksOsSolaris = 'tst-solaris' 1290 1220 ksOsFreeBSD = 'tst-freebsd' 1291 1292 1221 def __init__(self): 1293 1222 vbox.TestDriver.__init__(self); … … 1300 1229 self.asTestBuildDirs = None; #'D:/AlexD/TestBox/TestAdditionalFiles'; 1301 1230 self.sGuestAdditionsIso = None; #'D:/AlexD/TestBox/TestAdditionalFiles/VBoxGuestAdditions_6.1.2.iso'; 1302 1231 oSet = vboxtestvms.TestVmSet(self.oTestVmManager, acCpus = [2], fIgnoreSkippedVm = True); 1232 # pylint: disable=line-too-long 1233 oSet.aoTestVms.extend([ 1234 tdAutostartOsWin(oSet, self, self.ksOsWindows, 'Windows7_64', \ 1235 '6.0/windows7piglit/windows7piglit.vdi', eNic0Type = None, cMbRam = 2048, \ 1236 cCpus = 2, fPae = True, sGuestAdditionsIso = self.getGuestAdditionsIso()), 1237 tdAutostartOsLinux(oSet, self, self.ksOsLinux, 'Ubuntu_64', \ 1238 '6.0/ub1804piglit/ub1804piglit.vdi', eNic0Type = None, \ 1239 cMbRam = 2048, cCpus = 2, fPae = None, sGuestAdditionsIso = self.getGuestAdditionsIso()) 1240 ]); 1241 # pylint: enable=line-too-long 1242 self.oTestVmSet = oSet; 1303 1243 # 1304 1244 # Overridden methods. … … 1312 1252 reporter.log(' without any default value. The test raises an exception if the'); 1313 1253 reporter.log(' option is not specified. At least, one directory should be pointed.'); 1314 reporter.log(' --test-vms <vm1[:vm2[:...]]>');1315 reporter.log(' Test the specified VMs in the given order. Use this to change');1316 reporter.log(' the execution order or limit the choice of VMs');1317 reporter.log(' Default: %s (all)' % (':'.join(self.asTestVMsDef)));1318 reporter.log(' --skip-vms <vm1[:vm2[:...]]>');1319 reporter.log(' Skip the specified VMs when testing.');1320 1254 return rc; 1321 1322 1255 def parseOption(self, asArgs, iArg): # pylint: disable=too-many-branches,too-many-statements 1323 1256 if asArgs[iArg] == '--test-build-dirs': … … 1325 1258 if iArg >= len(asArgs): raise base.InvalidOption('The "--test-build-dirs" takes a paths argument'); 1326 1259 self.asTestBuildDirs = asArgs[iArg].split(','); 1327 elif asArgs[iArg] == '--test-vms': 1328 iArg += 1; 1329 if iArg >= len(asArgs): raise base.InvalidOption('The "--test-vms" takes colon separated list'); 1330 self.asTestVMs = asArgs[iArg].split(':'); 1331 for s in self.asTestVMs: 1332 if s not in self.asTestVMsDef: 1333 raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \ 1334 % (s, ' '.join(self.asTestVMsDef))); 1335 elif asArgs[iArg] == '--skip-vms': 1336 iArg += 1; 1337 if iArg >= len(asArgs): raise base.InvalidOption('The "--skip-vms" takes colon separated list'); 1338 self.asSkipVMs = asArgs[iArg].split(':'); 1339 for s in self.asSkipVMs: 1340 if s not in self.asTestVMsDef: 1341 reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s)); 1260 for oTestVm in self.oTestVmSet.aoTestVms: 1261 oTestVm.asTestBuildDirs = self.asTestBuildDirs; 1342 1262 else: 1343 1263 return vbox.TestDriver.parseOption(self, asArgs, iArg); 1344 1264 return iArg + 1; 1345 1346 1265 def completeOptions(self): 1347 1266 # Remove skipped VMs from the test list. … … 1351 1270 try: self.asTestVMs.remove(sVM); 1352 1271 except: pass; 1353 1354 1272 return vbox.TestDriver.completeOptions(self); 1355 1356 def getResourceSet(self):1357 # Construct the resource list the first time it's queried.1358 if self.asRsrcs is None:1359 self.asRsrcs = [];1360 if self.ksOsLinux in self.asTestVMs:1361 self.asRsrcs.append('6.0/ub1804piglit/ub1804piglit.vdi');1362 if self.ksOsWindows in self.asTestVMs:1363 self.asRsrcs.append('6.0/windows7piglit/windows7piglit.vdi');1364 #disabled1365 #if self.ksOsSolaris in self.asTestVMs:1366 # self.asRsrcs.append('4.2/autostart/tst-solaris.vdi');1367 1368 return self.asRsrcs;1369 1370 1273 def actionConfig(self): 1371 1372 # Make sure vboxapi has been imported so we can use the constants. 1373 if not self.importVBoxApi(): 1274 if not self.importVBoxApi(): # So we can use the constant below. 1374 1275 return False; 1375 # 1376 # Configure the VMs we're going to use. 1377 # 1378 1379 fRc = True; 1380 1381 # Linux VMs 1382 if self.ksOsLinux in self.asTestVMs: 1383 # ub1804piglit is created with 2 CPUs. 1384 oVM = self.createTestVM(self.ksOsLinux, 1, '6.0/ub1804piglit/ub1804piglit.vdi', sKind = 'Ubuntu_64', \ 1385 fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \ 1386 eNic0Type = vboxcon.NetworkAdapterType_Am79C973, cMbRam = 2048, \ 1387 cCpus = 2, sDvdImage = self.getGuestAdditionsIso()); 1388 if oVM is None: 1389 return False; 1390 # Windows VMs 1391 if self.ksOsWindows in self.asTestVMs: 1392 # windows7piglit is created with PAE enabled and 2 CPUs. 1393 # changed cMbRam to 2GB due to #9618 1394 oVM = self.createTestVM(self.ksOsWindows, 1, '6.0/windows7piglit/windows7piglit.vdi', sKind = 'Windows7_64', \ 1395 fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \ 1396 sHddControllerType = "SATA Controller", cMbRam = 2048, fPae = True, cCpus = 2, \ 1397 sDvdImage = self.getGuestAdditionsIso()); 1398 if oVM is None: 1399 return False; 1400 1401 # additional options used during the windows7piglit creation 1402 oSession = self.openSession(oVM); 1403 if oSession is not None: 1404 fRc = fRc and oSession.setVRamSize(256); 1405 fRc = fRc and oSession.setVideoControllerType(vboxcon.GraphicsControllerType_VBoxSVGA) 1406 fRc = fRc and oSession.setAccelerate3DEnabled(False); 1407 fRc = fRc and oSession.enableUsbOhci(True); 1408 fRc = fRc and oSession.enableUsbHid(True); 1409 fRc = fRc and oSession.saveSettings(); 1410 fRc = oSession.close() and fRc and True; # pychecker hack. 1411 oSession = None; 1412 else: 1413 fRc = False; 1414 1415 # disabled 1416 # Solaris VMs 1417 #if self.ksOsSolaris in self.asTestVMs: 1418 # oVM = self.createTestVM(self.ksOsSolaris, 1, '4.2/autostart/tst-solaris.vdi', sKind = 'Solaris_64', \ 1419 # fIoApic = True, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \ 1420 # sHddControllerType = "SATA Controller"); 1421 # if oVM is None: 1422 # return False; 1423 1424 return fRc; 1425 1276 return self.oTestVmSet.actionConfig(self); 1426 1277 def actionExecute(self): 1427 1278 """ 1428 1279 Execute the testcase. 1429 1280 """ 1430 fRc = self.testAutostart(); 1431 return fRc; 1432 1281 return self.oTestVmSet.actionExecute(self, self.testAutostartOneVfg) 1433 1282 # 1434 1283 # Test execution helpers. 1435 1284 # 1436 def testAutostartRunProgs(self, oSession, sVmName, oVM): 1437 """ 1438 Test VirtualBoxs autostart feature in a VM. 1439 """ 1440 reporter.testStart('Autostart ' + sVmName); 1441 1442 oGuestOsHlp = None # type: tdAutostartOs 1443 if sVmName == self.ksOsLinux: 1444 oGuestOsHlp = tdAutostartOsLinux(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type 1445 self.getGuestAdditionsIso()); 1446 elif sVmName == self.ksOsSolaris: 1447 oGuestOsHlp = tdAutostartOsSolaris(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type 1448 self.getGuestAdditionsIso()); 1449 elif sVmName == self.ksOsDarwin: 1450 oGuestOsHlp = tdAutostartOsDarwin(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type 1451 self.getGuestAdditionsIso()); 1452 elif sVmName == self.ksOsWindows: 1453 oGuestOsHlp = tdAutostartOsWin(self, self.asTestBuildDirs, self.fpApiVer, # pylint: disable=redefined-variable-type 1454 self.getGuestAdditionsIso()); 1455 1456 sTestUserAllow = 'test1'; 1457 sTestUserDeny = 'test2'; 1458 sTestVmName = 'TestVM'; 1459 1460 if oGuestOsHlp is not None: 1285 def testAutostartOneVfg(self, oVM, oTestVm): 1286 # Reconfigure the VM 1287 fRc = True; 1288 self.logVmInfo(oVM); 1289 oSession = self.startVmByName(oTestVm.sVmName); 1290 if oSession is not None: 1291 sTestUserAllow = 'test1'; 1292 sTestUserDeny = 'test2'; 1293 sTestVmName = 'TestVM'; 1461 1294 #wait the VM is ready after starting 1462 (fRc, oGuestSession) = o GuestOsHlp.waitVmIsReady(oSession, True);1295 (fRc, oGuestSession) = oTestVm.waitVmIsReady(oSession, True); 1463 1296 #install fresh guest additions 1464 1297 if fRc: 1465 (fRc, oGuestSession) = o GuestOsHlp.installAdditions(oSession, oGuestSession, oVM);1298 (fRc, oGuestSession) = oTestVm.installAdditions(oSession, oGuestSession, oVM); 1466 1299 # Create two new users 1467 fRc = fRc and o GuestOsHlp.createUser(oGuestSession, sTestUserAllow);1468 fRc = fRc and o GuestOsHlp.createUser(oGuestSession, sTestUserDeny);1300 fRc = fRc and oTestVm.createUser(oGuestSession, sTestUserAllow); 1301 fRc = fRc and oTestVm.createUser(oGuestSession, sTestUserDeny); 1469 1302 if fRc is True: 1470 1303 # Install VBox first 1471 fRc = o GuestOsHlp.installVirtualBox(oGuestSession);1304 fRc = oTestVm.installVirtualBox(oGuestSession); 1472 1305 if fRc is True: 1473 fRc = o GuestOsHlp.configureAutostart(oGuestSession, 'allow', (sTestUserAllow,), (sTestUserDeny,));1306 fRc = oTestVm.configureAutostart(oGuestSession, 'allow', (sTestUserAllow,), (sTestUserDeny,)); 1474 1307 if fRc is True: 1475 1308 # Create a VM with autostart enabled in the guest for both users 1476 fRc = o GuestOsHlp.createTestVM(oSession, oGuestSession, sTestUserAllow, sTestVmName);1477 fRc = fRc and o GuestOsHlp.createTestVM(oSession, oGuestSession, sTestUserDeny, sTestVmName);1309 fRc = oTestVm.createTestVM(oSession, oGuestSession, sTestUserAllow, sTestVmName); 1310 fRc = fRc and oTestVm.createTestVM(oSession, oGuestSession, sTestUserDeny, sTestVmName); 1478 1311 if fRc is True: 1479 1312 # Reboot the guest 1480 (fRc, oGuestSession) = o GuestOsHlp.rebootVMAndCheckReady(oSession, oGuestSession);1313 (fRc, oGuestSession) = oTestVm.rebootVMAndCheckReady(oSession, oGuestSession); 1481 1314 if fRc is True: 1482 1315 # Fudge factor - Allow the guest VMs to finish starting up. 1483 1316 self.sleep(60); 1484 fRc = o GuestOsHlp.checkForRunningVM(oSession, oGuestSession, sTestUserAllow, sTestVmName);1317 fRc = oTestVm.checkForRunningVM(oSession, oGuestSession, sTestUserAllow, sTestVmName); 1485 1318 if fRc is True: 1486 fRc = o GuestOsHlp.checkForRunningVM(oSession, oGuestSession, sTestUserDeny, sTestVmName);1319 fRc = oTestVm.checkForRunningVM(oSession, oGuestSession, sTestUserDeny, sTestVmName); 1487 1320 if fRc is True: 1488 1321 reporter.error('Test VM is running inside the guest for denied user'); … … 1500 1333 else: 1501 1334 reporter.error('Creating test users failed'); 1502 1503 1335 if oGuestSession is not None: 1504 try: o GuestOsHlp.powerDownVM(oGuestSession);1336 try: oTestVm.powerDownVM(oGuestSession); 1505 1337 except: pass; 1506 else: 1507 reporter.error('Guest OS helper not created for VM %s' % (sVmName)); 1508 fRc = False; 1509 1510 reporter.testDone(); 1511 return fRc; 1512 1513 def testAutostartOneCfg(self, sVmName): 1514 """ 1515 Runs the specified VM thru test #1. 1516 1517 Returns a success indicator on the general test execution. This is not 1518 the actual test result. 1519 """ 1520 oVM = self.getVmByName(sVmName); 1521 1522 # Reconfigure the VM 1523 fRc = True; 1524 oSession = self.openSession(oVM); 1525 if oSession is not None: 1526 fRc = fRc and oSession.enableVirtEx(True); 1527 fRc = fRc and oSession.enableNestedPaging(True); 1528 fRc = fRc and oSession.enableNestedHwVirt(True); 1529 # disable 3D until the error is fixed. 1530 fRc = fRc and oSession.setAccelerate3DEnabled(False); 1531 fRc = fRc and oSession.saveSettings(); 1338 try: self.terminateVmBySession(oSession); 1339 except: pass; 1532 1340 fRc = oSession.close() and fRc and True; # pychecker hack. 1533 1341 oSession = None; 1534 1342 else: 1535 1343 fRc = False; 1536 1537 # Start up. 1538 if fRc is True: 1539 self.logVmInfo(oVM); 1540 oSession = self.startVmByName(sVmName); 1541 if oSession is not None: 1542 fRc = self.testAutostartRunProgs(oSession, sVmName, oVM); 1543 try: self.terminateVmBySession(oSession); 1544 except: pass; 1545 else: 1546 fRc = False; 1547 return fRc; 1548 1549 def testAutostartForOneVM(self, sVmName): 1550 """ 1551 Runs one VM thru the various configurations. 1552 """ 1553 reporter.testStart(sVmName); 1554 fRc = True; 1555 self.testAutostartOneCfg(sVmName); 1556 reporter.testDone(); 1557 return fRc; 1558 1559 def testAutostart(self): 1560 """ 1561 Executes autostart test. 1562 """ 1563 1564 # Loop thru the test VMs. 1565 for sVM in self.asTestVMs: 1566 # run test on the VM. 1567 if not self.testAutostartForOneVM(sVM): 1568 fRc = False; 1569 else: 1570 fRc = True; 1571 1572 return fRc; 1573 1574 1575 1344 return fRc; 1576 1345 if __name__ == '__main__': 1577 1346 sys.exit(tdAutostart().main(sys.argv)); 1578
Note:
See TracChangeset
for help on using the changeset viewer.