tdUsb1.py revision 5bbb9454328dfeedc25e69918425996f1f8eae60
# -*- coding: utf-8 -*-
# $Id$
"""
VirtualBox Validation Kit - USB testcase and benchmark.
"""
__copyright__ = \
"""
Copyright (C) 2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
__version__ = "$Revision$"
# Standard Python imports.
import os;
import sys;
import socket;
# Only the main script needs to modify the path.
try: __file__
g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
# Validation Kit imports.
from testdriver import reporter;
from testdriver import base;
from testdriver import vbox;
from testdriver import vboxcon;
# USB gadget control import
"""
USB benchmark.
"""
# The available test devices
#
# The first key is the hostname of the host the test is running on.
# It contains a new dictionary with the attached gadgets based on the
# USB speed we want to test (Low, Full, High, Super).
# The parameters consist of the hostname of the gadget in the network
# and the hardware type.
kdGadgetParams = {
# The following is for local testing and not for the test lab.
'adaris': {
'Low': ('beaglebone', 'BeagleBoneBlack'),
'Full': ('beaglebone', 'BeagleBoneBlack'),
'High': ('beaglebone', 'BeagleBoneBlack'),
'Super': ('odroidxu3', 'ODroid-XU3')
},
};
# Mappings of USB controllers to supported USB device speeds.
'OHCI': ['Low', 'Full'],
'EHCI': ['High'],
'XHCI': ['Low', 'Full', 'High', 'Super']
};
self.oGuestToGuestVM = None;
self.oGuestToGuestSess = None;
self.oGuestToGuestTxs = None;
#
# Overridden methods.
#
return rc;
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
for s in self.asVirtModes:
if s not in self.asVirtModesDef:
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
try: c = int(s);
iArg += 1;
if s not in self.asTestVMsDef:
iArg += 1;
if s not in self.asTestVMsDef:
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-ctrls" takes a colon separated list of USB controllers');
for s in self.asUsbCtrls:
if s not in self.asUsbCtrlsDef:
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-speed" takes a colon separated list of USB speeds');
for s in self.asUsbSpeed:
if s not in self.asUsbSpeedDef:
else:
return iArg + 1;
def completeOptions(self):
# Remove skipped VMs from the test list.
except: pass;
def getResourceSet(self):
# Construct the resource list the first time it's queried.
def actionConfig(self):
# Some stupid trickery to guess the location of the iso. ## fixme - testsuite unzip ++
sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxValidationKit.iso'));
sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxTestSuite.iso'));
break;
break;
# Make sure vboxapi has been imported so we can use the constants.
if not self.importVBoxApi():
return False;
#
# Configure the VMs we're going to use.
#
# Linux VMs
oVM = self.createTestVM('tst-arch', 1, '4.2/usb/tst-arch.vdi', sKind = 'ArchLinux_64', fIoApic = True, \
if oVM is None:
return False;
return True;
def actionExecute(self):
"""
Execute the testcase.
"""
return fRc;
"""
Returns the gadget hostname and type from the
given hostname the test is running on and device speed we want to test.
"""
if kdGadgetsConfigured is not None:
return None;
#
# Test execution helpers.
#
"""
Test VirtualBoxs USB stack in a VM.
"""
# Get configured USB test devices from hostname we are running on
# Create device filter
oUsbGadget = UsbGadget();
# Wait a moment to let the USB device appear
else:
else:
else:
return fRc;
"""
Runs the specified VM thru test #1.
Returns a success indicator on the general test execution. This is not
the actual test result.
"""
# Reconfigure the VM
if oSession is not None:
# Make sure controllers are disabled initially.
if sUsbCtrl == 'OHCI':
elif sUsbCtrl == 'EHCI':
elif sUsbCtrl == 'XHCI':
oSession = None;
else:
# Start up.
oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(sVmName, fCdWait = False, fNatForwardingForTxs = False);
if oSession is not None:
# Fudge factor - Allow the guest to finish starting up.
# cleanup.
else:
return fRc;
"""
Runs one VM thru the various configurations.
"""
if sUsbSpeed in asSupportedSpeeds:
return fRc;
"""
Executes USB test.
"""
# Loop thru the test VMs.
# run test on the VM.
else:
return fRc;
if __name__ == '__main__':