VirtualBox

Changeset 36958 in vbox for trunk/src/VBox/Main/testcase


Ignore:
Timestamp:
May 4, 2011 2:50:32 PM (14 years ago)
Author:
vboxsync
Message:

Main/linux/USB: better permissions checking and code cleanup

Location:
trunk/src/VBox/Main/testcase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/testcase/tstHostHardwareLinux.cpp

    r36348 r36958  
    128128        RTPrintf ("\n");
    129129    }
    130     PCUSBDEVTREELOCATION pcLocation = USBProxyLinuxGetDeviceRoot(false);
    131     if (pcLocation && !pcLocation->fUseSysfs)
     130    RTPrintf("NOTE: checking for usbfs at /dev/bus/usb, not /proc/bus/usb!!!\n");
     131    if (USBProxyLinuxCheckDeviceRoot("/dev/bus/usb", false))
    132132    {
    133         PUSBDEVICE pDevice = USBProxyLinuxGetDevices(pcLocation->szDevicesRoot,
     133        PUSBDEVICE pDevice = USBProxyLinuxGetDevices("/dev/bus/usb",
    134134                                                     false);
    135         printDevices(pDevice, pcLocation->szDevicesRoot, "usbfs");
     135        printDevices(pDevice, "/dev/bus/usb", "usbfs");
    136136        freeDevices(pDevice);
    137137    }
     138    else
     139        RTPrintf("-> not found\n");
    138140#ifdef VBOX_USB_WITH_SYSFS
    139     pcLocation = USBProxyLinuxGetDeviceRoot(true);
    140     if (pcLocation && pcLocation->fUseSysfs)
     141    RTPrintf("Testing for USB devices at /dev/vboxusb\n");
     142    if (USBProxyLinuxCheckDeviceRoot("/dev/vboxusb", true))
    141143    {
    142         PUSBDEVICE pDevice = USBProxyLinuxGetDevices(pcLocation->szDevicesRoot,
     144        PUSBDEVICE pDevice = USBProxyLinuxGetDevices("/dev/vboxusb",
    143145                                                     true);
    144         printDevices(pDevice, pcLocation->szDevicesRoot, "sysfs");
     146        printDevices(pDevice, "/dev/vboxusb", "sysfs");
    145147        freeDevices(pDevice);
    146148    }
    147     VBoxMainHotplugWaiter waiter(pcLocation->szDevicesRoot);
     149    else
     150        RTPrintf("-> not found\n");
     151    VBoxMainHotplugWaiter waiter("/dev/vboxusb");
    148152    RTPrintf ("Waiting for a hotplug event for five seconds...\n");
    149153    doHotplugEvent(&waiter, 5000);
  • trunk/src/VBox/Main/testcase/tstUSBProxyLinux.cpp

    r36419 r36958  
    6262}
    6363
    64 static USBDEVTREELOCATION s_deviceRoot = { "", false };
    65 static bool s_fGetDeviceRootPreferSysfs = false;
     64static const char *s_pcszDeviceRoot = "";
     65static bool s_fIsDeviceNodes = false;
    6666
    67 PCUSBDEVTREELOCATION USBProxyLinuxGetDeviceRoot(bool fPreferSysfs)
     67bool USBProxyLinuxCheckDeviceRoot(const char *pcszRoot,
     68                                  bool fIsDeviceNodes)
    6869{
    69     s_fGetDeviceRootPreferSysfs = fPreferSysfs;
    70     return &s_deviceRoot;
     70    return (   (!strcmp(s_pcszDeviceRoot, pcszRoot))
     71            && (s_fIsDeviceNodes == fIsDeviceNodes));
    7172}
    7273
     
    153154        else
    154155            RTEnvUnset("VBOX_USB_ROOT");
    155         strcpy(s_deviceRoot.szDevicesRoot,
    156                s_testEnvironment[i].pcszReturnedRoot);
    157         s_deviceRoot.fUseSysfs = s_testEnvironment[i].fReturnedUseSysfs;
     156        s_pcszDeviceRoot = s_testEnvironment[i].pcszReturnedRoot;
     157        s_fIsDeviceNodes = s_testEnvironment[i].fReturnedUseSysfs;
    158158        RTTESTI_CHECK(test.init() == S_OK);
    159159        test.getDevices();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette