Reland "virtual-usb-printer: fix unit tests"

This is a reland of commit d10a77b4b080ba927755c20d1d8556ba544e1c27

Original change's description:
> virtual-usb-printer: fix unit tests
>
> Remove the requesting-user-name, document-format and
> requested-attributes fields from the libipp wrapper unit tests.
>
> BUG=b:175631323
> TEST=FEATURES=test emerge-nami virtual-usb-printer
>
> Change-Id: Ic3970bf30ace3e6901ae55c296e9e2d6e6e9eb11
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/virtual-usb-printer/+/3655109
> Commit-Queue: Paul Moy <pmoy@chromium.org>
> Reviewed-by: Piotr Pawliczek <pawliczek@chromium.org>
> Tested-by: Paul Moy <pmoy@chromium.org>

Bug: b:175631323

Cq-Depend: chromium:3669474
Change-Id: I599491d2df996b57b66ce4ceb34dd4e85288505a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/virtual-usb-printer/+/3669005
Commit-Queue: Paul Moy <pmoy@chromium.org>
Reviewed-by: Piotr Pawliczek <pawliczek@chromium.org>
Tested-by: Paul Moy <pmoy@chromium.org>
2 files changed
tree: 06d5e04498a69dd5d3997c8877482f3e2e597bf8
  1. config/
  2. docs/
  3. init/
  4. mock_printer/
  5. tools/
  6. .clang-format
  7. BUILD.gn
  8. CPPLINT.cfg
  9. cups_constants.cc
  10. cups_constants.h
  11. device_descriptors.cc
  12. device_descriptors.h
  13. escl_manager.cc
  14. escl_manager.h
  15. escl_manager_test.cc
  16. http_util.cc
  17. http_util.h
  18. http_util_test.cc
  19. ipp_manager.cc
  20. ipp_manager.h
  21. ipp_manager_test.cc
  22. ipp_util.cc
  23. ipp_util.h
  24. ipp_util_test.cc
  25. jpeg_util.cc
  26. jpeg_util.h
  27. jpeg_util_test.cc
  28. LICENSE
  29. load_config.cc
  30. load_config.h
  31. load_config_test.cc
  32. op_commands.cc
  33. op_commands.h
  34. OWNERS
  35. PRESUBMIT.cfg
  36. README.md
  37. server.cc
  38. server.h
  39. smart_buffer.cc
  40. smart_buffer.h
  41. smart_buffer_test.cc
  42. usb_printer.cc
  43. usb_printer.h
  44. usbip.cc
  45. usbip.h
  46. usbip_constants.h
  47. value_util.cc
  48. value_util.h
  49. virtual_usb_printer.cc
  50. xml_util.cc
  51. xml_util.h
README.md

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