The Realm Builder sample demonstrates an integration test component that exercises the fuchsia.sdk.examples.GreetingService
FIDL protocol implemented by another component using the Realm Builder testing library.
fidl/
: Contains the definition of a Fuchsia interprocess communication (IPC) protocol (fuchsia.sdk.examples.GreetingService
) defined as a Fuchsia Interface Definition Language (FIDL) library.greeter.cc
: Source code for a component under test that implements and serves the fuchsia.sdk.examples.GreetingService
protocol.test/
: Source code for an integration test component that exercises the fuchsia.sdk.examples.GreetingService
using Realm Builder.Start a FEMU instance:
$ ./third_party/fuchsia-sdk/bin/femu.sh -N
Start a local package repository instance:
$ ./third_party/fuchsia-sdk/tools/x64/fserve --image qemu-x64
Run the build script to compile and package the sample:
$ ./scripts/build.sh
Publish the FAR component package to your local package repository:
$ ./third_party/fuchsia-sdk/tools/x64/fpublish out/x64/greeting_service.far
Publish the FAR test package to your local package repository:
$ ./third_party/fuchsia-sdk/tools/x64/fpublish out/x64/greeter_test.far
Execute the integration test suite using ffx test run
. This resolves the component from the package repository and executes the tests:
$ ffx test run fuchsia-pkg://fuchsia.com/greeter_test#meta/greeter_test.cm
Verify that the test cases pass:
Running test 'fuchsia-pkg://fuchsia.com/greeter_test#meta/greeter_test.cm' [RUNNING] main [00114.271318][65078][65080][realm_builder_server] INFO: started [00114.383240][1179][1303][realm_builder:auto-10293192455784001876/greeting_service] INFO: Running GreetingService server [stdout - main] Running main() from ../../third_party/googletest/src/googletest/src/gtest_main.cc [==========] Running 3 tests from 1 test suite. [----------] Global test environment set-up. [----------] 3 tests from RealmBuilderTest [ RUN ] RealmBuilderTest.RoutesFromComponent [ OK ] RealmBuilderTest.RoutesFromComponent (245 ms) [ RUN ] RealmBuilderTest.RoutesFromLegacyComponent [ OK ] RealmBuilderTest.RoutesFromLegacyComponent (224 ms) [ RUN ] RealmBuilderTest.RoutesFromMockComponent [ OK ] RealmBuilderTest.RoutesFromMockComponent (67 ms) [----------] 3 tests from RealmBuilderTest (536 ms total) [----------] Global test environment tear-down [==========] 3 tests from 1 test suite ran. (541 ms total) [ PASSED ] 3 tests. [PASSED] main 1 out of 1 tests passed... fuchsia-pkg://fuchsia.com/greeter_test#meta/greeter_test.cm completed with result: PASSED