Reviewed on 2022-05-12
This directory contains the necessary Fuchsia components to run a client/server implementation of a calculator.
The main goals of this example are to:
The build steps differ slightly depending on if you‘re using the rust or c++ version of the code. Both are functionally the same, so use the language you’re most familiar with or interested in.
To add this project to your build, append the following to your fx set
invocation:
fx set workstation.qemu-x64\ --with //examples/fidl/calculator:all\ --with //examples/fidl/calculator:tests
and then build:
fx build
TODO(fxbug.dev/103280)
Start the emulator and package server.
ffx emu start --headless workstation.qemu-x64
fx serve-updates
After the emulator & package server are running, the instructions differ based on language.
Between, client, server, fidl, and realm, all necessary services are provided to run a simple calculator on Fuchsia.
To run these components together add calculator-example-rust
to the ffx-laboratory:
ffx component create /core/ffx-laboratory:calculator-example-rust \ fuchsia-pkg://fuchsia.com/calculator-example-rust#meta/realm.cm
and then start the component:
ffx component start /core/ffx-laboratory:calculator-example-rust ffx component start /core/ffx-laboratory:calculator-example-rust/client
To see the output, use ffx log
:
ffx log --filter calculator
There are tests for both the client and server. The command for running tests differs slightly depending on the language used.
Client
To run the client tests, ensure you have an available Fuchsia target (ex: ffx emu start
) and are serving packages (ex: fx serve-updates
) then run the following:
fx test calculator-client-rust-unittests
Server
To run the server tests, ensure you have an available Fuchsia target (ex: ffx emu start
) and are serving packages (ex: fx serve-updates
) then run the following:
fx test calculator-server-rust-unittests
TODO
The source is split into four parts: