VirtualBox

Ignore:
Timestamp:
Jun 23, 2011 5:16:39 PM (13 years ago)
Author:
vboxsync
Message:

Main/USB/linux: move USBProxyLinuxChooseMethod to USBGetDevices

File:
1 edited

Legend:

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

    r37617 r37618  
    8989    /* "sysfs" and valid root in the environment */
    9090    { "sysfs", "/dev/bus/usb", "/dev/bus/usb", true, NULL, false, VINF_SUCCESS, "/dev/bus/usb", false, VINF_SUCCESS },
    91     /* "sysfs" and valid root in the environment, method-specific init failed */
    92     { "sysfs", "/dev/bus/usb",  "/dev/bus/usb", true, NULL, false, VERR_NO_MEMORY, "/dev/bus/usb", false, VERR_NO_MEMORY },
    9391    /* "sysfs" and bad root in the environment */
    9492    { "sysfs", "/dev/bus/usb", "/dev/vboxusb", false, "/proc/usb/bus", false, VINF_SUCCESS, "", true, VERR_NOT_FOUND },
     
    9795    /* "usbfs" and valid root in the environment */
    9896    { "usbfs", "/dev/bus/usb", NULL, false, "/dev/bus/usb", true, VINF_SUCCESS, "/dev/bus/usb", true, VINF_SUCCESS },
    99     /* "usbfs" and valid root in the environment, method-specific init failed */
    100     { "usbfs", "/dev/bus/usb", NULL, false, "/dev/bus/usb", true, VERR_NO_MEMORY, "/dev/bus/usb", true, VERR_NO_MEMORY },
    10197    /* "usbfs" and bad root in the environment */
    10298    { "usbfs", "/dev/bus/usb", "/dev/vboxusb", false, "/proc/usb/bus", false, VINF_SUCCESS, "", true, VERR_NOT_FOUND },
     
    119115    /* No environment, sysfs available but without access permissions. */
    120116    { NULL, NULL, "/dev/vboxusb", false, NULL, false, VERR_NO_MEMORY, "", true, VERR_VUSB_USB_DEVICE_PERMISSION },
    121     /* No environment, sysfs available with access permissions, method-specific init failed. */
    122     { NULL, NULL, "/dev/vboxusb", true, NULL, false, VERR_NO_MEMORY, "/dev/vboxusb", false, VERR_NO_MEMORY },
    123117    /* No environment, usbfs available but without access permissions. */
    124118    { NULL, NULL, NULL, false, "/proc/bus/usb", false, VERR_NO_MEMORY, "", true, VERR_VUSB_USBFS_PERMISSION },
    125     /* No environment, usbfs available with access permissions, method-specific
    126      * init failed. */
    127     { NULL, NULL, NULL, false, "/proc/bus/usb", true, VERR_NO_MEMORY, "/proc/bus/usb", true, VERR_NO_MEMORY }
    128119};
    129120
    130121static void testInit(RTTEST hTest)
    131122{
    132     RTTestSub(hTest, "Testing USBProxyServiceLinux initialisation");
     123    RTTestSub(hTest, "Testing USBProxyLinuxChooseMethod");
    133124    for (unsigned i = 0; i < RT_ELEMENTS(s_testEnvironment); ++i)
    134125    {
    135         USBProxyServiceLinux test(NULL);
     126        bool fUsingUsbfs = true;
     127        const char *pcszDevicesRoot = "";
     128
    136129        TestUSBSetEnv(s_testEnvironment[i].pcszEnvUsb,
    137                         s_testEnvironment[i].pcszEnvUsbRoot);
     130                      s_testEnvironment[i].pcszEnvUsbRoot);
    138131        TestUSBSetupInit(s_testEnvironment[i].pcszUsbfsRoot,
    139                            s_testEnvironment[i].fUsbfsAccessible,
    140                            s_testEnvironment[i].pcszDevicesRoot,
    141                            s_testEnvironment[i].fDevicesAccessible,
    142                            s_testEnvironment[i].rcMethodInit);
    143         HRESULT hrc = test.init();
    144         RTTESTI_CHECK_MSG(hrc == S_OK,
    145                            ("init() returned 0x%x (test index %i)!\n", hrc, i));
    146         int rc = test.getLastError();
     132                         s_testEnvironment[i].fUsbfsAccessible,
     133                         s_testEnvironment[i].pcszDevicesRoot,
     134                         s_testEnvironment[i].fDevicesAccessible,
     135                         s_testEnvironment[i].rcMethodInit);
     136        int rc = USBProxyLinuxChooseMethod(&fUsingUsbfs, &pcszDevicesRoot);
    147137        RTTESTI_CHECK_MSG(rc == s_testEnvironment[i].rcExpected,
    148                           ("getLastError() returned %Rrc (test index %i) instead of %Rrc!\n",
     138                          ("rc=%Rrc (test index %i) instead of %Rrc!\n",
    149139                           rc, i, s_testEnvironment[i].rcExpected));
    150         const char *pcszDevicesRoot = test.testGetDevicesRoot();
    151140        RTTESTI_CHECK_MSG(!RTStrCmp(pcszDevicesRoot,
    152141                               s_testEnvironment[i].pcszDevicesRootExpected),
     
    154143                           pcszDevicesRoot, i,
    155144                           s_testEnvironment[i].pcszDevicesRootExpected));
    156         bool fUsingUsbfs = test.testGetUsingUsbfs();
    157145        RTTESTI_CHECK_MSG(   fUsingUsbfs
    158146                          == s_testEnvironment[i].fUsingUsbfsExpected,
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