Driver examples

This page contains a list of the examples intended to demonstrate Fuchsia driver concepts.

Basic examples

These examples showcase common driver concepts:

  • Skeleton driver - The skeleton driver example is a minimal driver written in DFv2.

  • Template driver - The template driver is a minimal driver written in DFv2, and built with SDK rules (which can be used in both the Fuchsia source checkout and Fuchsia SDK environments).

  • Simple driver - The simple driver examples showcases how to write a DFv1 driver and a DFv2 driver with the following common patterns:

    • Adding logs
    • Adding a child node
    • Implementing stop functions
    • Setting up a compat device server
  • Metadata - The metadata example demonstrates how to define metadata types and pass metadata from a driver to its children.

Transport examples

These examples showcase communication between drivers:

  • Banjo - These examples demonstrate a parent driver serving a Banjo transport and a child driver that connects and queries data from it.

  • Zircon transport - These examples demonstrate a parent driver serving a FIDL protocol over Zircon transport and a child driver that connects and queries data from it.

  • Driver transport - These examples demonstrate a parent driver serving a FIDL protocol over driver transport and a child driver that connects and queries data from it.

Bind examples

These examples demonstrate how to write and use bind libraries for drivers:

  • Bind library - This example demonstrates how to write a bind library.

  • Bind library codegen - This example demonstrates how to use the C++ and Rust constants generated from a bind library.

  • FIDL bind library codegen - This example demonstrates how to write a bind library.

Test examples

These examples demonstrate writing unit and integration tests for drivers.

Unit tests

Unit test examples:

  • Simple driver - Barebones unit test for the simple driver example
  • Banjo transport - Unit test that verifies that the child driver can query from a fake Banjo server
  • Zircon transport - Unit test that verifies that the child driver can query from a fake FIDL zircon server
  • Driver transport - Unit test that verifies that the child driver can query from a fake FIDL driver server

Integration tests

The Driver Test Realm examples demonstrate how to write hermetic and non-hermetic integration tests for a driver.