Skip to content

cmd/mfp-test: add print system testing pipeline skeleton#78

Open
ArmxG wants to merge 12 commits into
OpenPrinting:masterfrom
ArmxG:master
Open

cmd/mfp-test: add print system testing pipeline skeleton#78
ArmxG wants to merge 12 commits into
OpenPrinting:masterfrom
ArmxG:master

Conversation

@ArmxG

@ArmxG ArmxG commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

This PR introduces cmd/mfp-test:- the skeleton of the full-stack print system testing pipeline.

What was added
cmd/mfp-test/test/capture.go
DocumentCapture implements abstract.Printer and collects all incoming print documents (job parameters + raw bytes)
for later inspection. It is thread-safe and signals via a channel when the first document arrives.

cmd/mfp-test/test/cupsctl.go
CreateCUPSQueue and RemoveCUPSQueue manage CUPS printer queues via lpadmin. The queue uses the IPP
Everywhere driver (-m everywhere) which works with any standards-compliant IPP printer.

cmd/mfp-test/test/command.go
The main command handler:

  • Parses CLI flags: --model, --port, --name, --output, --threshold, --list, --batch, --single, --verbose
  • Loads printer model via modeling.NewModel() + model.Load()
  • Starts virtual IPP printer via model.NewIPPServer() on a real TCP port (CUPS requires a real network connection)
  • Registers the printer with CUPS via CreateCUPSQueue()
  • Generates a test PNG image (300x300, RGB colour bands) and sends it through CUPS via lp
  • Waits for DocumentCapture to receive the document (30s timeout)
  • Reports captured document size and format
  • Exits automatically after tests complete
  • Always removes the CUPS queue on exit via defer RemoveCUPSQueue(context.WithoutCancel(ctx), name)
    (WithoutCancel ensures cleanup runs even after ctx is cancelled)

cmd/mfp-test/main.go
Thin entry point following project convention:
test.Command.Main(nil)

How to test
cd cmd/mfp-test
go build -o mfp-test .
./mfp-test --model <printer-model-file.py> -v

A model file with ipp.attrs defined is required. Example model files can be generated with mfp-query or obtained from the modeling package.

Expected output:
virtual IPP printer at ipp://localhost:60000/ipp/print
CUPS queue "mfp-test" ready at ipp://localhost:60000/ipp/print
sending test PNG via lp...
captured doc 1: N bytes, format="image/pwg-raster", job="..."

Notes

  • PNG is used instead of plain text because CUPS conversion of plain text depends on fonts and gives unpredictable output. PNG/PDF gives consistent results across systems.
  • CUPS queue is always removed after each run to prevent accumulation of stale queues in CUPS configuration.
  • Phase 3 will integrate Sanskar's ImageComparator framework to compare captured output against the original test image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant