tree: f8394e07ac3981db554b0342629cc0fe2cc675a6 [path history] [tgz]
  1. cpp/
  2. fidl/
  3. go/
  4. rust/
  5. BUILD.gn
  6. README.md
garnet/tests/fidl-changes/README.md

FIDL Cross-Petal Change Tests

These are tests to validate source compatibility through various changes to FIDL libraries. They do not test binary compatibility. Tests for compiled languages are only meant to be built, not executed, since source compatibility issues show up at compile time.

Transitions

Soft transitioning a FIDL library involves an initial state (before), an intermediate state (during), and a final state (after). Depending on the bindings used and the kind of change made to the FIDL library, the transition is either FIDL-assisted or source-assisted.

FIDL-assisted

In a FIDL-assisted transition, you change source code while the FIDL library is held in a transitional state (e.g., using the Transitional attribute). For these transitions, we test four states:

Time1234
FIDLbeforeduringduringafter
Sourcebeforebeforeafterafter

Source-assisted

In a source-assisted transition, you change the FIDL library while source code held is in a transitional state (e.g., using default: in switch statements). This would lead to testing four states:

Time1234
FIDLbeforebeforeafterafter
Sourcebeforeduringduringafter

However, certain FIDL changes require a FIDL-assisted transition in some bindings and a source-assisted transition in others. Suppose we make a change in FIDL library L requiring a FIDL-assisted transition in bindings A and source-assisted in bindings B. We would take the following steps:

  1. Initially, L, A, and B are before.
  2. Change B to during.
  3. Change L to during.
  4. Change A to after.
  5. Change L to after.
  6. Change B to after.

All correct ways of interleaving the steps will have L and B both in the during state at some point. Therefore, although a FIDL during state is unnecessary for a pure source-assisted transition, we must include it in tests. Thus, we actually test 5 states for source-assisted transitions:

Time12345
FIDLbeforebeforeduringafterafter
Sourcebeforeduringduringduringafter

Libraries

Under fidl/ there are three libraries:

  • fidl.test.before, before the change has begun;
  • fidl.test.during, during the transition;
  • fidl.test.after, after the transition is complete.

Tests

C++

Under cpp/ there are four binary targets testing FIDL-assisted transitions:

  • cpp_before compiles cpp/before.cc against fidl.test.before
  • cpp_during_1 compiles cpp/before.cc against fidl.test.during
  • cpp_during_2 compiles cpp/after.cc against fidl.test.during
  • cpp_after compiles cpp/after.cc against fidl.test.after

There are currently no tests for C++ source-assisted transitions.

Go

Under go/ there is a single package testing FIDL-assisted transitions. The package has client code:

  • client_1_before.go tests client code against fidl.test.before.
  • client_2_before_during.go is generated by update-during.sh.
  • client_3_after_during.go is generated by update-during.sh.
  • client_4_after.go tests client code against fidl.test.after.

And server code:

  • server_1_before.go tests server code against fidl.test.before.
  • server_2_before_during.go is generated by update-during.sh.
  • server_3_after_during.go is generated by update-during.sh.
  • server_4_after.go tests server code against fidl.test.after.

There are currently no tests for Go source-assisted transitions.

Rust

Under rust/ there is a single library testing both FIDL-assisted transitions:

  • fidl_assisted/main.rs executes macros from the other two modules.
  • fidl_assisted/before.rs defines the macro before_impl.
  • fidl_assisted/after.rs defines the macro after_impl.

And source-assisted transitions:

  • source_assisted/main.rs executes macros from the other three modules.
  • source_assisted/before.rs defines the macro before_impl.
  • source_assisted/during.rs defines the macro during_impl.
  • source_assisted/after.rs defines the macro after_impl.

The macros allow for building the same code against different FIDL libraries without repetition.