Changeset 36995 in vbox
- Timestamp:
- May 6, 2011 10:49:41 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/linux/USBProxyServiceLinux.cpp
r36994 r36995 114 114 * available we fall back to USBFS. 115 115 * In the event of both failing, an appropriate error will be returned. 116 * The user may also specify a method and root using the VBOX_USB and 117 * VBOX_USB_ROOT environment variables. In this case we don't check 118 * the root they provide for validity. 116 119 */ 117 120 bool fUsbfsChosen = false, fSysfsChosen = false; -
trunk/src/VBox/Main/testcase/tstUSBProxyLinux.cpp
r36994 r36995 82 82 bool fUsbfsAccessible; 83 83 int rcMethodInit; 84 int rcExpected;85 84 const char *pcszDevicesRootExpected; 86 85 bool fUsingUsbfsExpected; 86 int rcExpected; 87 87 } s_testEnvironment[] = 88 88 { 89 { "sysfs", "/dev/bus/usb", NULL, false, NULL, false, VINF_SUCCESS, VINF_SUCCESS, "/dev/bus/usb", false }, 90 { "sysfs", "/dev/bus/usb", NULL, false, NULL, false, VERR_NO_MEMORY, VERR_NO_MEMORY, "/dev/bus/usb", false }, 91 { "sysfs", "/dev/bus/usb", "/dev/usbvbox", false, "/proc/usb/bus", false, VINF_SUCCESS, VINF_SUCCESS, "/dev/bus/usb", false }, 92 { "sysfs", "/dev/bus/usb", "/dev/usbvbox", false, "/proc/usb/bus", false, VERR_NO_MEMORY, VERR_NO_MEMORY, "/dev/bus/usb", false }, 93 { "sysfs", NULL, "/dev/vboxusb", true, NULL, false, VINF_SUCCESS, VINF_SUCCESS, "/dev/vboxusb", false }, 94 { "usbfs", "/dev/bus/usb", NULL, false, NULL, false, VINF_SUCCESS, VINF_SUCCESS, "/dev/bus/usb", true }, 95 { "usbfs", "/dev/bus/usb", NULL, false, NULL, false, VERR_NO_MEMORY, VERR_NO_MEMORY, "/dev/bus/usb", true }, 96 { "usbfs", "/dev/bus/usb", "/dev/usbvbox", false, "/proc/usb/bus", false, VINF_SUCCESS, VINF_SUCCESS, "/dev/bus/usb", true }, 97 { "usbfs", "/dev/bus/usb", "/dev/usbvbox", false, "/proc/usb/bus", false, VERR_NO_MEMORY, VERR_NO_MEMORY, "/dev/bus/usb", true }, 98 { "usbfs", NULL, NULL, false, "/proc/bus/usb", true, VINF_SUCCESS, VINF_SUCCESS, "/proc/bus/usb", true }, 99 { NULL, NULL, "/dev/vboxusb", false, "/proc/bus/usb", false, VERR_NO_MEMORY, VERR_VUSB_USB_DEVICE_PERMISSION, "", true }, 100 { NULL, NULL, "/dev/vboxusb", true, "/proc/bus/usb", false, VERR_NO_MEMORY, VERR_NO_MEMORY, "/dev/vboxusb", false }, 101 { NULL, NULL, NULL, false, "/proc/bus/usb", false, VERR_NO_MEMORY, VERR_VUSB_USBFS_PERMISSION, "", true }, 102 { NULL, NULL, NULL, false, "/proc/bus/usb", true, VERR_NO_MEMORY, VERR_NO_MEMORY, "/proc/bus/usb", true } 89 /* "sysfs" and root in the environment */ 90 { "sysfs", "/dev/bus/usb", NULL, false, NULL, false, VINF_SUCCESS, "/dev/bus/usb", false, VINF_SUCCESS }, 91 /* "sysfs" and root in the environment, method-specific init failed */ 92 { "sysfs", "/dev/bus/usb", NULL, false, NULL, false, VERR_NO_MEMORY, "/dev/bus/usb", false, VERR_NO_MEMORY }, 93 /* "sysfs" and bad root in the environment (should succeed as we don't 94 * do checks if the user specifies everything) */ 95 { "sysfs", "/dev/bus/usb", "/dev/usbvbox", false, "/proc/usb/bus", false, VINF_SUCCESS, "/dev/bus/usb", false, VINF_SUCCESS }, 96 /* "sysfs" and bad root in the environment, method-specific init failed */ 97 { "sysfs", "/dev/bus/usb", "/dev/usbvbox", false, "/proc/usb/bus", false, VERR_NO_MEMORY, "/dev/bus/usb", false, VERR_NO_MEMORY }, 98 /* "sysfs" and no root in the environment */ 99 { "sysfs", NULL, "/dev/vboxusb", true, NULL, false, VINF_SUCCESS, "/dev/vboxusb", false, VINF_SUCCESS }, 100 /* "usbfs" and root in the environment */ 101 { "usbfs", "/dev/bus/usb", NULL, false, NULL, false, VINF_SUCCESS, "/dev/bus/usb", true, VINF_SUCCESS }, 102 /* "usbfs" and root in the environment, method-specific init failed */ 103 { "usbfs", "/dev/bus/usb", NULL, false, NULL, false, VERR_NO_MEMORY, "/dev/bus/usb", true, VERR_NO_MEMORY }, 104 /* "usbfs" and bad root in the environment (should succeed as we don't 105 * do checks if the user specifies everything) */ 106 { "usbfs", "/dev/bus/usb", "/dev/usbvbox", false, "/proc/usb/bus", false, VINF_SUCCESS, "/dev/bus/usb", true, VINF_SUCCESS }, 107 /* "usbfs" and bad root in the environment, method-specific init failed */ 108 { "usbfs", "/dev/bus/usb", "/dev/usbvbox", false, "/proc/usb/bus", false, VERR_NO_MEMORY, "/dev/bus/usb", true, VERR_NO_MEMORY }, 109 /* "usbfs" and no root in the environment */ 110 { "usbfs", NULL, NULL, false, "/proc/bus/usb", true, VINF_SUCCESS, "/proc/bus/usb", true, VINF_SUCCESS }, 111 /* No environment, sysfs and usbfs available but without access 112 * permissions. */ 113 { NULL, NULL, "/dev/vboxusb", false, "/proc/bus/usb", false, VERR_NO_MEMORY, "", true, VERR_VUSB_USB_DEVICE_PERMISSION }, 114 /* No environment, sysfs and usbfs available, access permissions for sysfs, 115 * method-specific init failed. */ 116 { NULL, NULL, "/dev/vboxusb", true, "/proc/bus/usb", false, VERR_NO_MEMORY, "/dev/vboxusb", false, VERR_NO_MEMORY }, 117 /* No environment, usbfs available but without access permissions. */ 118 { NULL, NULL, NULL, false, "/proc/bus/usb", false, VERR_NO_MEMORY, "", true, VERR_VUSB_USBFS_PERMISSION }, 119 /* No environment, usbfs available with access permissions, method-specific 120 * init failed. */ 121 { NULL, NULL, NULL, false, "/proc/bus/usb", true, VERR_NO_MEMORY, "/proc/bus/usb", true, VERR_NO_MEMORY } 103 122 }; 104 123 … … 118 137 HRESULT hrc = test.init(); 119 138 RTTESTI_CHECK_MSG(hrc == S_OK, 120 ("init() returned 0x%x on line %i!\n", hrc, i));139 ("init() returned 0x%x (test index %i)!\n", hrc, i)); 121 140 int rc = test.getLastError(); 122 141 RTTESTI_CHECK_MSG(rc == s_testEnvironment[i].rcExpected, 123 ("getLastError() returned %Rrc on line %iinstead of %Rrc!\n",142 ("getLastError() returned %Rrc (test index %i) instead of %Rrc!\n", 124 143 rc, i, s_testEnvironment[i].rcExpected)); 125 144 const char *pcszDevicesRoot = test.testGetDevicesRoot(); 126 145 RTTESTI_CHECK_MSG(!RTStrCmp(pcszDevicesRoot, 127 146 s_testEnvironment[i].pcszDevicesRootExpected), 128 ("testGetDevicesRoot() returned %s on line %iinstead of %s!\n",147 ("testGetDevicesRoot() returned %s (test index %i) instead of %s!\n", 129 148 pcszDevicesRoot, i, 130 149 s_testEnvironment[i].pcszDevicesRootExpected)); … … 132 151 RTTESTI_CHECK_MSG( fUsingUsbfs 133 152 == s_testEnvironment[i].fUsingUsbfsExpected, 134 ("testGetUsingUsbfs() returned %RTbool on line %iinstead of %RTbool!\n",153 ("testGetUsingUsbfs() returned %RTbool (test index %i) instead of %RTbool!\n", 135 154 fUsingUsbfs, i, 136 155 s_testEnvironment[i].fUsingUsbfsExpected)); … … 147 166 } s_testCheckDeviceRoot[] = 148 167 { 168 /* /dev/vboxusb accessible -> device nodes method available */ 149 169 { { NULL }, { "/dev/vboxusb" }, "/dev/vboxusb", true, true }, 170 /* /dev/vboxusb present but not accessible -> device nodes method not 171 * available */ 150 172 { { NULL }, { NULL }, "/dev/vboxusb", true, false }, 173 /* /proc/bus/usb available but empty -> usbfs method available (we can't 174 * really check in this case) */ 151 175 { { NULL }, { NULL }, "/proc/bus/usb", false, true }, 176 /* /proc/bus/usb available, one inaccessible device -> usbfs method not 177 * available */ 152 178 { { "/proc/bus/usb/001/001" }, { NULL }, "/proc/bus/usb", false, false }, 179 /* /proc/bus/usb available, one device of two inaccessible -> usbfs method 180 * not available */ 153 181 { { "/proc/bus/usb/001/001", "/proc/bus/usb/002/002" }, 154 182 { "/proc/bus/usb/001/001" }, "/proc/bus/usb", false, false }, 183 /* /proc/bus/usb available, two accessible devices -> usbfs method 184 * available */ 155 185 { { "/proc/bus/usb/001/001", "/proc/bus/usb/002/002" }, 156 186 { "/proc/bus/usb/001/001", "/proc/bus/usb/002/002" }, … … 172 202 RTTESTI_CHECK_MSG( fAvailable 173 203 == s_testCheckDeviceRoot[i].fAvailableExpected, 174 ("USBProxyLinuxCheckDeviceRoot() returned %RTbool on line %iinstead of %RTbool!\n",204 ("USBProxyLinuxCheckDeviceRoot() returned %RTbool (test index %i) instead of %RTbool!\n", 175 205 fAvailable, i, 176 206 s_testCheckDeviceRoot[i].fAvailableExpected));
Note:
See TracChangeset
for help on using the changeset viewer.