Clone this repo:
  1. cf7ffec virtual-usb-printer: Migrate base::StringPiece to std::string_view by Wei-Luan Wang · 7 months ago chromeos factory-rex-15708.B firmware-rex-15709.B release-R122-15753.B release-R123-15786.B stabilize-15714.B stabilize-15753.46.B stabilize-15753.55.B stabilize-15756.B stabilize-15786.48.B stabilize-15786.58.B stabilize-quickfix-15786.49.B
  2. 4992fb4 Add media-col-database and media-type-supported to printer attributes by Bryan Cain · 8 months ago factory-brya-15684.B release-R121-15699.B stabilize-15699.58.B stabilize-15699.66.B
  3. 40a8848 PRESUBMIT: switch to cros format by Mike Frysinger · 9 months ago release-R120-15662.B stabilize-15654.B stabilize-15662.64.B stabilize-15662.76.B stabilize-15662.78.B stabilize-15662.80.B stabilize-15662.88.B stabilize-15677.B stabilize-quickfix-15662.77.B
  4. a847069 Update OWNERS by Benjamin Gordon · 1 year, 2 months ago firmware-cr50-efi-15611.28.B firmware-cr50-mp-15611.B firmware-cr50-prepvt-15608.B release-R116-15509.B release-R117-15572.B release-R118-15604.B release-R119-15633.B stabilize-15483.B stabilize-15485.B stabilize-15509.37.B stabilize-15509.63.B stabilize-15509.72.B stabilize-15511.B stabilize-15519.B stabilize-15531.B stabilize-15532.B stabilize-15561.B stabilize-15562.B stabilize-15563.B stabilize-15564.B stabilize-15572.16.B stabilize-15572.39.B stabilize-15572.4.B stabilize-15572.50.B stabilize-15572.57.B stabilize-15572.63.B stabilize-15588.B stabilize-15604.16.B stabilize-15604.45.B stabilize-15604.56.B stabilize-15604.57.B stabilize-15610.B stabilize-15633.44.B stabilize-15633.58.B stabilize-15633.69.B stabilize-15642.B
  5. 0df993c virtual-usb-printer: Add DIR_METADATA by Benjamin Gordon · 1 year, 2 months ago release-R115-15474.B stabilize-15474.38.B stabilize-15474.53.B stabilize-15474.70.B

Virtual USB Printer

Virtual USB Printer provides a server which can be used with USBIP in order to emulate a USB printing device and bind it to the system as if it were physically connected to a USB port.

Virtual USB Printer supports both regular USB printers as well as IPP-over-USB devices.

Motivation

This project was created in order to make on-device tests which check for any regressions in the native USB printing system.

Installation

As of https://crrev.com/c/3093381, virtual-usb-printer is built and installed by default on all test images that support it.

If for some reason you need to build it yourself, you can USE=usbip when building packages for your board - i.e.

USE="usbip" ./build_packages --board=$BOARD
virtual-usb-printer relies on usbip to manifest as a virtual USB device. Most test images seem to come with this built-in by default. If you need to build your own kernel with usbip support, make sure to build with CONFIG_USBIP_CORE and CONFIG_USBIP_VHCI_HCD.

How to Use

virtual-usb-printer can behave like

For ease of human operation, start virtual-usb-printer via its Upstart unit. Pass the appropriate arguments to the invocation as needed.

For example, to start and connect the virtual-usb-printer as an IPP-over-USB printer, issue

start virtual-usb-printer USB_DESCRIPTORS=ippusb_printer.json IPP_ATTRIBUTES=ipp_attributes.json

Consult the Upstart config file to see the arguments understood in this context.

When managed by Upstart, virtual-usb-printer sends its output to the system log.

Configuration

The printer's USB descriptors and defined IPP attributes can be configured using a JSON file and are loaded at run-time using command line flags. Example configurations can be found in the config/ directory.

The configuration files can be loaded with the following flags:

  • --descriptors_path - full path to the JSON file which defines the USB descriptors
  • --attributes_path - full path to the JSON file which defines the supported IPP attributes
    • Only needed for IPP-over-USB printer configurations
  • --record_doc_path - full path to the file used to record documents received from print jobs
  • --output_log_dir - directory path specifying where scan settings will be logged

Using in Tast

Refer to these existing tast tests for examples of how to use the virtual-usb-printer to test the Chromium OS printing stack.

Print Tests

Scan Tests