commit | 2406220ec224dcee378f0b61c2c1cf0fbd3de5ef | [log] [tgz] |
---|---|---|
author | Kalvin Lee <kdlee@chromium.org> | Tue Aug 10 22:12:02 2021 |
committer | Commit Bot <commit-bot@chromium.org> | Fri Aug 13 07:48:36 2021 |
tree | 11103cabcfd2ff12babde390e04875de56dfb2b6 | |
parent | 5face0740206899b4717c89c722ab7f89fb13181 [diff] |
mock_printer: Use `uint32` in Protobufs This change * converts the `mocking::Resolution` to use unsigned integers and * changes the `version_number` and `operation_id` fields of `mocking::IppMessage` to use unsigned integers. This CL does not touch fields of `mocking::DateTime` that might be validly zero-valued because the question of sentinel values remains open. This CL introduces no behavioral change. BUG=b:178649877 TEST=cros_run_unit_tests --board=octopus \ TEST=--packages=chromeos-base/virtual-usb-printer Disallow-Recycled-Builds: test-failures Change-Id: I23de9c4f4a153cb7606d1d4e2257a5f2f9fca3e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/virtual-usb-printer/+/3088292 Commit-Queue: Kalvin Lee <kdlee@chromium.org> Tested-by: Kalvin Lee <kdlee@chromium.org> Reviewed-by: Pranav Batra <batrapranav@chromium.org>
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.
This project was created in order to make on-device tests which check for any regressions in the native USB printing system.
In order to actually “connect” the virtual printer to the system the USBIP program is used.
USBIP is typically used to export real USB devices over a network so that other systems on the network can bind them and treat them as connected devices.
For the purposes of the virtual printer, only the client portion of USBIP is required so that the virtual device can be bound to the system.
Currently the USBIP program is only installed by default for the elm and betty boards.
In order to install it on your test image, you need to build an image with the usbip
USE flag enabled. To do this, all you need to to is run build_packages
with the USE flag enabled.
USE="usbip" ./build_packages --board=$BOARD
virtual-usb-printer
can behave like
Before the first use you have to load a required kernel module:
modprobe vhci-hcd
Run the virtual-usb-printer program:
virtual-usb-printer --descriptors_path=<path>
(Optional) Check the list of exported printers with USBIP:
usbip list -r localhost
Should return something like this:
Exportable USB devices ====================== - localhost 1-1: Canon, Inc. : unknown product (04a9:27e8) : /sys/devices/pci0000:00/0000:00:01.2/usb1/1-1 : (Defined at Interface level) (00/00/00) : 0 - Printer / Printer Bidirectional (07/01/02)
Bind the virtual printer to the system:
usbip attach -r localhost -b 1-1
Once the device has been attached it should appear in the list of connected USB devices (lsusb
), and can be used with the native printing system in Chrome OS.
--help
dialogue, the usage of VLOG()
in some source files can be made visible by passing an appropriate --vmodule=
argument. Consult the primary documentation in base/logging.h
for details.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--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 loggedRefer to these existing tast tests for examples of how to use the virtual-usb-printer
to test the Chromium OS printing stack.