tree: f7ffabe1fcb36950ecea428908e921e710463fef [path history] [tgz]
  1. fidl/
  2. meta/
  3. test/
  4. BUILD.gn
  5. greeter.cc
  6. README.md
src/realm_builder/README.md

Realm Builder Example

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.

Source layout

  • 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.

Before you begin

  1. Start a FEMU instance:

    $ ./third_party/fuchsia-sdk/bin/femu.sh -N
    
  2. Start a local package repository instance:

    $ ./third_party/fuchsia-sdk/tools/x64/fserve --image qemu-x64
    

Build the sample

  1. Run the build script to compile and package the sample:

    $ ./scripts/build.sh
    
  2. Publish the FAR component package to your local package repository:

    $ ./third_party/fuchsia-sdk/tools/x64/fpublish out/x64/greeting_service.far
    
  3. Publish the FAR test package to your local package repository:

    $ ./third_party/fuchsia-sdk/tools/x64/fpublish out/x64/greeter_test.far
    

Run the integration tests

  1. 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
    
  2. 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