a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#!/usr/bin/env python
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync# -*- coding: utf-8 -*-
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync# $Id$
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync"""
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncVirtualBox Validation Kit - Smoke Test #1.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync"""
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync__copyright__ = \
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync"""
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncCopyright (C) 2010-2014 Oracle Corporation
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncavailable from http://www.virtualbox.org. This file is free software;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncGeneral Public License (GPL) as published by the Free Software
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncThe contents of this file may alternatively be used under the terms
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncof the Common Development and Distribution License Version 1.0
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncVirtualBox OSE distribution, in which case the provisions of the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncCDDL are applicable instead of those of the GPL.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncYou may elect to license modified versions of this file under the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncterms and conditions of either the GPL or the CDDL or both.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync"""
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync__version__ = "$Revision$"
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync# Standard Python imports.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncimport os;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncimport sys;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync# Only the main script needs to modify the path.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsynctry: __file__
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncexcept: __file__ = sys.argv[0];
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncg_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncsys.path.append(g_ksValidationKitDir);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync# Validation Kit imports.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncfrom testdriver import reporter;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncfrom testdriver import base;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncfrom testdriver import vbox;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncfrom testdriver import vboxcon;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncclass tdSmokeTest1(vbox.TestDriver):
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync """
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync VBox Smoke Test #1.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync """
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync def __init__(self):
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync vbox.TestDriver.__init__(self);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync self.asRsrcs = None;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync self.oTestVmSet = self.oTestVmManager.getSmokeVmSet();
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync self.sNicAttachmentDef = 'mixed';
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync self.sNicAttachment = self.sNicAttachmentDef;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync self.fQuick = False;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync #
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync # Overridden methods.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync #
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync def showUsage(self):
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync rc = vbox.TestDriver.showUsage(self);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync reporter.log('');
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync reporter.log('Smoke Test #1 options:');
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync reporter.log(' --nic-attachment <bridged|nat|mixed>');
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync reporter.log(' Default: %s' % (self.sNicAttachmentDef));
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync reporter.log(' --quick');
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync reporter.log(' Very selective testing.')
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync return rc;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync def parseOption(self, asArgs, iArg):
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync if asArgs[iArg] == '--nic-attachment':
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync iArg += 1;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync if iArg >= len(asArgs): raise base.InvalidOption('The "--nic-attachment" takes an argument');
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync self.sNicAttachment = asArgs[iArg];
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync if self.sNicAttachment not in ('bridged', 'nat', 'mixed'):
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync raise base.InvalidOption('The "--nic-attachment" value "%s" is not supported. Valid values are: bridged, nat' \
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync % (self.sNicAttachment));
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync elif asArgs[iArg] == '--quick':
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync # Disable all but a few VMs and configurations.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync for oTestVm in self.oTestVmSet.aoTestVms:
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync if oTestVm.sVmName == 'tst-win2k3ent': # 32-bit paging
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.asVirtModesSup = [ 'hwvirt' ];
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.acCpusSup = range(1, 2);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync elif oTestVm.sVmName == 'tst-rhel5': # 32-bit paging
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.asVirtModesSup = [ 'raw' ];
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.acCpusSup = range(1, 2);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync elif oTestVm.sVmName == 'tst-win2k8': # 64-bit
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.asVirtModesSup = [ 'hwvirt-np' ];
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.acCpusSup = range(1, 2);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync elif oTestVm.sVmName == 'tst-sol10-64': # SMP, 64-bit
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.asVirtModesSup = [ 'hwvirt' ];
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.acCpusSup = range(2, 3);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync elif oTestVm.sVmName == 'tst-sol10': # SMP, 32-bit
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.asVirtModesSup = [ 'hwvirt-np' ];
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.acCpusSup = range(2, 3);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync else:
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync oTestVm.fSkip = True;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync else:
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync return vbox.TestDriver.parseOption(self, asArgs, iArg);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync return iArg + 1;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync def actionVerify(self):
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync if self.sVBoxValidationKitIso is None or not os.path.isfile(self.sVBoxValidationKitIso):
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync reporter.error('Cannot find the VBoxValidationKit.iso! (%s)'
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync 'Please unzip a Validation Kit build in the current directory or in some parent one.'
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync % (self.sVBoxValidationKitIso,) );
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync return False;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync return vbox.TestDriver.actionVerify(self);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync def actionConfig(self):
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync # Make sure vboxapi has been imported so we can use the constants.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync if not self.importVBoxApi():
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync return False;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
# Do the configuring.
if self.sNicAttachment == 'nat': eNic0AttachType = vboxcon.NetworkAttachmentType_NAT;
elif self.sNicAttachment == 'bridged': eNic0AttachType = vboxcon.NetworkAttachmentType_Bridged;
else: eNic0AttachType = None;
assert self.sVBoxValidationKitIso is not None;
return self.oTestVmSet.actionConfig(self, eNic0AttachType = eNic0AttachType, sDvdImage = self.sVBoxValidationKitIso);
def actionExecute(self):
"""
Execute the testcase.
"""
return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
#
# Test execution helpers.
#
def testOneVmConfig(self, oVM, oTestVm):
"""
Runs the specified VM thru test #1.
"""
# Simple test.
self.logVmInfo(oVM);
oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = True);
if oSession is not None:
self.addTask(oSession);
## @todo do some quick tests: save, restore, execute some test program, shut down the guest.
# cleanup.
self.removeTask(oTxsSession);
self.terminateVmBySession(oSession)
return True;
return None;
if __name__ == '__main__':
sys.exit(tdSmokeTest1().main(sys.argv));