VirtualBox

Changeset 54118 in vbox for trunk


Ignore:
Timestamp:
Feb 9, 2015 8:21:45 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
98128
Message:

ValidationKit/USB: Updates for the automated USB testing system

Location:
trunk/src/VBox/ValidationKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py

    r53415 r54118  
    10241024            fRc = False;
    10251025        else:
    1026             reporter.log('changed UsbHid to %s for "%s"' % (fEnable, self.sName));
     1026            reporter.log('changed OHCI to %s for "%s"' % (fEnable, self.sName));
    10271027        self.oTstDrv.processPendingEvents();
    10281028        return fRc;
     
    10491049            else:
    10501050                if self.fpApiVer >= 4.3:
    1051                     cEhciCtls = self.o.machine.getUSBControllerCountByType(vboxcon.USBControllerType_ECI);
     1051                    cEhciCtls = self.o.machine.getUSBControllerCountByType(vboxcon.USBControllerType_EHCI);
    10521052                    if cEhciCtls == 1:
    10531053                        self.o.machine.RemoveUSBController('EHCI');
     
    10581058            fRc = False;
    10591059        else:
    1060             reporter.log('changed UsbHid to %s for "%s"' % (fEnable, self.sName));
     1060            reporter.log('changed EHCI to %s for "%s"' % (fEnable, self.sName));
    10611061        self.oTstDrv.processPendingEvents();
    10621062        return fRc;
    10631063
     1064    def enableUsbXhci(self, fEnable):
     1065        """
     1066        Enables or disables the USB XHCI controller. Error information is logged.
     1067        """
     1068        fRc = True;
     1069        try:
     1070            if fEnable:
     1071                    cXhciCtls = self.o.machine.getUSBControllerCountByType(vboxcon.USBControllerType_XHCI);
     1072                    if cXhciCtls == 0:
     1073                        self.o.machine.addUSBController('XHCI', vboxcon.USBControllerType_XHCI);
     1074            else:
     1075                cXhciCtls = self.o.machine.getUSBControllerCountByType(vboxcon.USBControllerType_XHCI);
     1076                if cXhciCtls == 1:
     1077                    self.o.machine.RemoveUSBController('XHCI');
     1078        except:
     1079            reporter.errorXcpt('failed to change XHCI to %s for "%s"' % (fEnable, self.sName));
     1080            fRc = False;
     1081        else:
     1082            reporter.log('changed XHCI to %s for "%s"' % (fEnable, self.sName));
     1083        self.oTstDrv.processPendingEvents();
     1084        return fRc;
    10641085
    10651086    def setFirmwareType(self, eType):
  • trunk/src/VBox/ValidationKit/tests/usb/tdUsb1.py

    r52776 r54118  
    3434import os;
    3535import sys;
     36import socket;
    3637
    3738# Only the main script needs to modify the path.
     
    5455    USB benchmark.
    5556    """
     57
     58    # The available test devices
     59    #
     60    # The first key is the hostname of the host the test is running on.
     61    # It contains a new dictionary with the attached gadgets based on the
     62    # USB speed we want to test (Low, Full, High, Super).
     63    # The parameters consist of the hostname of the gadget in the network
     64    # and the hardware type.
     65    kdGadgetParams = {
     66        # The following is for local testing and not for the test lab.
     67        'adaris': {
     68            'Low':   ('beaglebone', 'BeagleBoneBlack'),
     69            'Full':  ('beaglebone', 'BeagleBoneBlack'),
     70            'High':  ('beaglebone', 'BeagleBoneBlack'),
     71            'Super': ('odroidxu3', 'ODroid-XU3')
     72        },
     73    };
     74
     75    # Mappings of USB controllers to supported USB device speeds.
     76    kdUsbSpeedMappings = {
     77        'OHCI': ['Low', 'Full'],
     78        'EHCI': ['High'],
     79        'XHCI': ['Low', 'Full', 'High', 'Super']
     80    };
    5681
    5782    def __init__(self):
     
    6186        self.oGuestToGuestSess = None;
    6287        self.oGuestToGuestTxs  = None;
    63         self.asTestVMsDef      = ['tst-debian', 'tst-arch'];
     88        self.asTestVMsDef      = ['tst-arch'];
    6489        self.asTestVMs         = self.asTestVMsDef;
    6590        self.asSkipVMs         = [];
    66         self.asVirtModesDef    = ['hwvirt', 'hwvirt-np', 'raw',]
    67         self.asVirtModes       = self.asVirtModesDef
    68         self.acCpusDef         = [1, 2,]
     91        self.asVirtModesDef    = ['hwvirt', 'hwvirt-np', 'raw'];
     92        self.asVirtModes       = self.asVirtModesDef;
     93        self.acCpusDef         = [1, 2,];
    6994        self.acCpus            = self.acCpusDef;
     95        self.asUsbCtrlsDef     = ['OHCI', 'EHCI', 'XHCI'];
     96        self.asUsbCtrls        = self.asUsbCtrlsDef;
     97        self.asUsbSpeedDef     = ['Low', 'Full', 'High', 'Super'];
     98        self.asUsbSpeed        = self.asUsbSpeedDef;
     99        self.sHostname         = socket.gethostname().lower();
    70100
    71101    #
     
    86116        reporter.log('  --skip-vms      <vm1[:vm2[:...]]>');
    87117        reporter.log('      Skip the specified VMs when testing.');
     118        reporter.log('  --usb-ctrls     <u1[:u2[:]]');
     119        reporter.log('      Default: %s' % (':'.join(str(c) for c in self.asUsbCtrlsDef)));
     120        reporter.log('  --usb-speed     <s1[:s2[:]]');
     121        reporter.log('      Default: %s' % (':'.join(str(c) for c in self.asUsbSpeedDef)));
    88122        return rc;
    89123
     
    121155                if s not in self.asTestVMsDef:
    122156                    reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s));
     157        elif asArgs[iArg] == '--usb-ctrls':
     158            iArg += 1;
     159            if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-ctrls" takes a colon separated list of USB controllers');
     160            self.asUsbCtrls = asArgs[iArg].split(':');
     161            for s in self.asUsbCtrls:
     162                if s not in self.asUsbCtrlsDef:
     163                    reporter.log('warning: The "--usb-ctrls" value "%s" is not a valid USB controller.' % (s));
     164        elif asArgs[iArg] == '--usb-speed':
     165            iArg += 1;
     166            if iArg >= len(asArgs): raise base.InvalidOption('The "--usb-speed" takes a colon separated list of USB speeds');
     167            self.asUsbSpeed = asArgs[iArg].split(':');
     168            for s in self.asUsbSpeed:
     169                if s not in self.asUsbSpeedDef:
     170                    reporter.log('warning: The "--usb-speed" value "%s" is not a valid USB speed.' % (s));
    123171        else:
    124172            return vbox.TestDriver.parseOption(self, asArgs, iArg);
     
    137185        if self.asRsrcs is None:
    138186            self.asRsrcs = [];
    139             if 'tst-debian' in self.asTestVMs:
    140                 self.asRsrcs.append('4.2/storage/debian.vdi');
    141187
    142188            if 'tst-arch' in self.asTestVMs:
     
    180226
    181227        # Linux VMs
    182         if 'tst-debian' in self.asTestVMs:
    183             oVM = self.createTestVM('tst-debian', 1, '4.2/storage/debian.vdi', sKind = 'Debian_64', fIoApic = True, \
    184                                     eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
    185                                     sDvdImage = sVBoxValidationKit_iso);
    186             if oVM is None:
    187                 return False;
    188 
    189228        if 'tst-arch' in self.asTestVMs:
    190229            oVM = self.createTestVM('tst-arch', 1, '4.2/usb/tst-arch.vdi', sKind = 'ArchLinux_64', fIoApic = True, \
     
    203242        return fRc;
    204243
     244    def getGadgetParams(self, sHostname, sSpeed):
     245        """
     246        Returns the gadget hostname and type from the
     247        given hostname the test is running on and device speed we want to test.
     248        """
     249        kdGadgetsConfigured = self.kdGadgetParams.get(sHostname);
     250        if kdGadgetsConfigured is not None:
     251            return kdGadgetsConfigured.get(sSpeed);
     252
     253        return None;
    205254
    206255    #
    207256    # Test execution helpers.
    208257    #
    209     def testUsbCompliance(self, oSession, oTxsSession, sVmName):
    210         """
    211         Test VirtualBoxs autostart feature in a VM.
    212         """
    213         reporter.testStart('USB ' + sVmName);
     258    def testUsbCompliance(self, oSession, oTxsSession, sVmName, sSpeed):
     259        """
     260        Test VirtualBoxs USB stack in a VM.
     261        """
     262        # Get configured USB test devices from hostname we are running on
     263        sGadgetHost, sGadgetType = self.getGadgetParams(self.sHostname, sSpeed);
    214264
    215265        # Create device filter
     
    217267        if fRc is True:
    218268            oUsbGadget = UsbGadget();
    219             fRc = oUsbGadget.connectTo(30 * 1000, '192.168.2.213');
     269            fRc = oUsbGadget.connectTo(30 * 1000, sGadgetType, sGadgetHost);
    220270            if fRc is True:
    221271                fRc = oUsbGadget.impersonate('Test');
     
    223273
    224274                    # Wait a moment to let the USB device appear
    225                     self.sleep(2);
    226 
    227                     reporter.testStart('USB Test');
    228 
    229                     fRc = self.txsRunTest(oTxsSession, 'USB compliance test', 240 * 1000, \
     275                    self.sleep(3);
     276
     277                    fRc = self.txsRunTest(oTxsSession, 'Compliance', 3600 * 1000, \
    230278                        '${CDROM}/${OS/ARCH}/UsbTest${EXESUFF}', ('UsbTest', ));
    231279
    232                     reporter.testDone();
    233280                else:
    234281                    reporter.testFailure('Failed to impersonate test device');
     
    240287            reporter.testFailure('Failed to create USB device filter');
    241288
    242         reporter.testDone(not fRc);
    243         return fRc;
    244 
    245     def testUsbOneCfg(self, sVmName):
     289        return fRc;
     290
     291    def testUsbOneCfg(self, sVmName, sUsbCtrl, sSpeed):
    246292        """
    247293        Runs the specified VM thru test #1.
     
    258304            fRc = fRc and oSession.enableVirtEx(True);
    259305            fRc = fRc and oSession.enableNestedPaging(True);
    260             fRc = fRc and oSession.enableUsbEhci(True);
     306
     307            # Make sure controllers are disabled initially.
     308            fRc = fRc and oSession.enableUsbOhci(False);
     309            fRc = fRc and oSession.enableUsbEhci(False);
     310            fRc = fRc and oSession.enableUsbXhci(False);
     311
     312            if sUsbCtrl == 'OHCI':
     313                fRc = fRc and oSession.enableUsbOhci(True);
     314            elif sUsbCtrl == 'EHCI':
     315                fRc = fRc and oSession.enableUsbEhci(True);
     316            elif sUsbCtrl == 'XHCI':
     317                fRc = fRc and oSession.enableUsbXhci(True);
    261318            fRc = fRc and oSession.saveSettings();
    262319            fRc = oSession.close() and fRc and True; # pychecker hack.
     
    275332                self.sleep(5);
    276333
    277                 fRc = self.testUsbCompliance(oSession, oTxsSession, sVmName);
     334                fRc = self.testUsbCompliance(oSession, oTxsSession, sVmName, sSpeed);
    278335
    279336                # cleanup.
     
    289346        """
    290347        reporter.testStart(sVmName);
    291         fRc = True;
    292         self.testUsbOneCfg(sVmName);
     348        for sUsbCtrl in self.asUsbCtrls:
     349            reporter.testStart(sUsbCtrl)
     350            for sUsbSpeed in self.asUsbSpeed:
     351                asSupportedSpeeds = self.kdUsbSpeedMappings.get(sUsbCtrl);
     352                if sUsbSpeed in asSupportedSpeeds:
     353                    reporter.testStart(sUsbSpeed)
     354                    fRc = self.testUsbOneCfg(sVmName, sUsbCtrl, sUsbSpeed);
     355                    reporter.testDone(not fRc);
     356            reporter.testDone();
    293357        reporter.testDone();
    294358        return fRc;
     
    296360    def testUsb(self):
    297361        """
    298         Executes autostart test.
    299         """
     362        Executes USB test.
     363        """
     364
     365        reporter.log("Running on host: " + self.sHostname);
    300366
    301367        # Loop thru the test VMs.
  • trunk/src/VBox/ValidationKit/tests/usb/usbgadget.py

    r52776 r54118  
    4545        self.oTxsSession = None;
    4646        self.sImpersonation = 'Invalid';
     47        self.sGadgetType    = 'Invalid';
    4748
    4849    def _loadModule(self, sModule):
     
    5556        if self.oTxsSession is not None:
    5657            fRc = self.oTxsSession.syncExecEx('/usr/bin/modprobe', ('/usr/bin/modprobe', sModule));
     58            # For the ODroid-XU3 gadget we have to do a soft connect for the attached host to recognise the device.
     59            if self.sGadgetType == 'ODroid-XU3':
     60                fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', ('/usr/bin/sh', '-c', 'echo connect > /sys/class/udc/12400000.dwc3/soft_connect'));
    5761
    5862        return fRc;
     
    6670        fRc = False;
    6771        if self.oTxsSession is not None:
     72            # For the ODroid-XU3 gadget we do a soft disconnect before unloading the gadget driver.
     73            if self.sGadgetType == 'ODroid-XU3':
     74                fRc = self.oTxsSession.syncExecEx('/usr/bin/sh', ('/usr/bin/sh', '-c', 'echo disconnect > /sys/class/udc/12400000.dwc3/soft_connect'));
    6875            fRc = self.oTxsSession.syncExecEx('/usr/bin/rmmod', ('/usr/bin/rmmod', sModule));
    6976
     
    119126        return False;
    120127
    121     def connectTo(self, cMsTimeout, sHostname, uPort = None):
     128    def connectTo(self, cMsTimeout, sGadgetType, sHostname, uPort = None):
    122129        """
    123130        Connects to the specified target device.
     
    139146            fRc = False;
    140147
     148        if fRc is True:
     149            self.sGadgetType = sGadgetType;
     150
    141151        return fRc;
    142152
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