Update all tests & roll Bazel SDK.

Squash of commits fxrev.dev/668923, fxrev.dev/669647, and
fxrev.dev/669649.

Change-Id: Ic9cf230dfceb7c6caa43c24c0d9818651a07e215
Reviewed-on: https://fuchsia-review.googlesource.com/c/sdk-samples/getting-started/+/672644
Reviewed-by: Kyo Lee <kyol@google.com>
Reviewed-by: Renato Mangini Dias <mangini@google.com>
9 files changed
tree: d175f43e31efcdbaf809d310f5d3f3ac6007d328
  1. scripts/
  2. src/
  3. third_party/
  4. tools/
  5. .bazelrc
  6. .gitignore
  7. .gitmodules
  8. AUTHORS
  9. CONTRIBUTING.md
  10. LICENSE
  11. OWNERS
  12. PATENTS
  13. README.md
  14. update_dependencies.md
  15. WORKSPACE.bazel
README.md

Fuchsia samples using the Fuchsia SDK

This repository contains instructions and source code to build, package and run Fuchsia samples using only the Fuchsia SDK. To update the dependencies of this repository, follow the instructions in update_dependencies.md.

Requirements

  1. Install a Bazel version no older than the one defined in the .bazelversion file, by following the instructions at https://bazel.build/install. In some Linux distributions, sudo apt-get install bazel should be enough.

  2. Make sure this repository has the required submodules:

    git submodule update --recursive --init
    
  3. Ensure that there are Fuchsia SSH keys in your host machine. You will need them for running the Fuchsia emulator.

     [[ -f "${HOME}/.ssh/fuchsia_ed25519" ]] || ssh-keygen -P "" -t ed25519 -f "${HOME}/.ssh/fuchsia_ed25519" -C "${USER}@$(hostname -f) Shared SSH Key for Fuchsia"
    
     [[ -f "${HOME}/.ssh/fuchsia_authorized_keys" ]] || ssh-keygen -y -f "${HOME}/.ssh/fuchsia_ed25519" > "${HOME}/.ssh/fuchsia_authorized_keys"
    

Build, run and test the samples

Now the repository is ready to build the samples.

  1. Build the samples:

    bazel build --config=fuchsia_x64 src:samples_repository
    

    This command will build all the samples and make them available as packages on a local Fuchsia repository.

  2. Fetch an emulator image and start an emulator

    tools/ffx product-bundle get workstation.qemu-x64
    tools/ffx emu start --net tap workstation.qemu-x64 --headless
    

    Note: Use --net user when running on MacOS

    The product bundle comes with on-demand packages in a separate repository. Use the following command to register it with the emulator:

    tools/ffx target repository register -r workstation.qemu-x64 --alias fuchsia.com
    
  3. Register the package repositories

    tools/ffx repository add-from-pm -r fuchsiasamples.com bazel-bin/src/fuchsiasamples.com.repo
    tools/ffx target repository register -r fuchsiasamples.com
    
  4. (optional) watch the device log in a separate window

    tools/ffx log
    
  5. Run a hello world component

    tools/ffx component run fuchsia-pkg://fuchsiasamples.com/hello_world#meta/hello_world.cm --recreate
    

    Watch in the log that the message “Hello, World!” is printed. Modify the Hello world message in src/hello_world/hello_world.cc, repeat steps 1 and 3, and see that the log shows the new message.

  6. Run the echo sample

    tools/ffx component run fuchsia-pkg://fuchsiasamples.com/echo-example#meta/echo.cm --recreate
    

    Watch the message “Hello, Alice, Bob, Spot!” in the log. Modify the FAVORITE_ANIMAL environment variable in src/echo/meta/echo.cml, repeat steps 1 and 3 and see that the log shows the new message.

  7. Run unit tests for the hello world sample

    tools/ffx test run fuchsia-pkg://fuchsiasamples.com/hello_test#meta/hello_gtest.cm
    
  8. Run the routing sample

    tools/ffx component create /core/ffx-laboratory:echo_realm fuchsia-pkg://fuchsiasamples.com/components_routing_example#meta/echo_realm.cm
    tools/ffx component start /core/ffx-laboratory:echo_realm/echo_client
    

    Watch the message “Server response: Hello Fuchsia!” in the log:

    tools/ffx log --filter echo_client
    
  9. Run integration tests for the routing sample

    tools/ffx test run fuchsia-pkg://fuchsiasamples.com/echo_integration_test#meta/echo_integration_test.cm