fwtc: Create script to calculate a board's JSON

Currently, the ultimate fw-testing-config JSON is determined at runtime
based on logic that is duplicated in both FAFT and Tast. This has two
unfortunate effects:
1. Duplicated logic is hard to maintain, and can easily lead to
   inconsistent errors.
2. There is no easy way for a developer to see what the config values
   are for a given platform.

A first step toward solving both of those problems is to write a script
in fw-testing-configs that will calculate the final configs for a
platform.

Also re-runs consolidate.py, because https://crrev.com/c/2519483 did not
re-run the script for a late patch-set.

BUG=b:173118460
BUG=b:173118890
TEST=platform_json_unittest.py
TEST=platform_json.py fievel (has multiple inheritance)
TEST=platform_json.py octopus -m bobba360 (has model override)
TEST=platform_json.py octopus --condense-output

Change-Id: Id9927efe8f3730ad3e02a5986ad8c0b443f86512
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/fw-testing-configs/+/2534754
Tested-by: Greg Edelston <gredelston@google.com>
Reviewed-by: Andrew Luo <aluo@chromium.org>
Commit-Queue: Andrew Luo <aluo@chromium.org>
Auto-Submit: Greg Edelston <gredelston@google.com>
3 files changed
tree: 2e760f7f436cdabd34823c89428fc61d8e7bda2b
  1. .gitignore
  2. .style.yapf
  3. arkham.json
  4. asuka.json
  5. asurada.json
  6. atlas.json
  7. auron.json
  8. banjo.json
  9. banon.json
  10. betty.json
  11. bob.json
  12. brain.json
  13. buddy.json
  14. candy.json
  15. caroline.json
  16. cave.json
  17. celes.json
  18. chell.json
  19. cheza.json
  20. consolidate.py
  21. consolidate_unittest.py
  22. CONSOLIDATED.json
  23. coral.json
  24. cyan.json
  25. dedede.json
  26. DEFAULTS.json
  27. dragonegg.json
  28. drallion.json
  29. edgar.json
  30. elm.json
  31. endeavour.json
  32. enguarde.json
  33. eve.json
  34. expresso.json
  35. fievel.json
  36. fizz.json
  37. gale.json
  38. gandof.json
  39. glados.json
  40. gnawty.json
  41. gru.json
  42. grunt.json
  43. guado.json
  44. hana.json
  45. hatch.json
  46. heli.json
  47. jacuzzi.json
  48. jecht.json
  49. jetstream.json
  50. kalista.json
  51. kefka.json
  52. kevin.json
  53. kevin64.json
  54. kevin_tpm2.json
  55. kip.json
  56. kukui.json
  57. kunimitsu.json
  58. lars.json
  59. lulu.json
  60. mickey.json
  61. mistral.json
  62. nami.json
  63. nasher.json
  64. nautilus.json
  65. ninja.json
  66. nocturne.json
  67. oak.json
  68. octopus.json
  69. orco.json
  70. OWNERS
  71. paine.json
  72. pinky.json
  73. platform_json.py
  74. platform_json_unittest.py
  75. poppy.json
  76. PRESUBMIT.cfg
  77. PRESUBMIT.py
  78. puff.json
  79. pyro.json
  80. rambi.json
  81. rammus.json
  82. README.md
  83. reef.json
  84. reef_uni.json
  85. reks.json
  86. relm.json
  87. rikku.json
  88. samus.json
  89. sand.json
  90. sarien.json
  91. scarlet.json
  92. sentry.json
  93. setzer.json
  94. slippy.json
  95. snappy.json
  96. soraka.json
  97. storm.json
  98. strago.json
  99. strongbad.json
  100. sumo.json
  101. swanky.json
  102. terra.json
  103. tidus.json
  104. tiger.json
  105. trogdor.json
  106. ultima.json
  107. veyron.json
  108. volteer.json
  109. whirlwind.json
  110. winky.json
  111. wizpig.json
  112. yuna.json
  113. zork.json
README.md

CrOS fw-testing-configs: User’s Guide

go/cros-fw-testing-configs-guide

Background

End-to-end firmware testing in ChromeOS relies on board-specific configuration files. Previously, those files were stored in Autotest. Now, they have been moved into a separate repository, fw-testing-configs, so that other testing frameworks (e.g. Tast, SerialTest) can access them too.

The design document for the new repository is at go/cros-fw-testing-configs.

Working With Configs

File Locations & Names

All the config files are located at the top directory of the fw-testing-configs repository.

The fw-testing-configs repository currently has two checkouts in the ChromeOS manifest: one inside of Autotest, and one inside of tast-tests.

There is one config file for each platform, named as ${PLATFORM}.json: for example, octopus.json. There are also one special config file, DEFAULTS.json and CONSOLIDATED.json. DEFAULTS.json contains default values and documentation for each attribute. CONSOLIDATED.json is a generated file, containing the config data from all the other JSON files.

File Contents

Each config file should contain a single object whose fields override the values specified in DEFAULTS.json. Any fields which do not have a corresponding value in DEFAULTS.json will be ignored.

There are a few special fields to be aware of:

  • platform (required): A string which should exactly match the config file’s basename (minus the .json extension).
  • parent (optional): A string which can contain the name of a parent platform, whose fields will be inherited with lower precedence. See “Inheritance” below. Example: asuka.json
  • models (optional): An object which can contain the names of any models, whose fields will be inherited with higher precedence. See “Inheritance” below. Example: octopus.json

Inheritance

There is an inheritance model in these config files. In all cases, the most specific configuration is used:

[Model > ] Platform [ > Parent [...] ] > DEFAULTS

For each attribute that exists in DEFAULTS.json (besides the documentation attributes):

  • If that attribute is given a value in the platform’s models[${MODEL}], then that is the value that is used.
  • Otherwise, if that attribute is given a value in the ${PLATFORM}.json, then that is the value that is used.
  • Otherwise, if ${PLATFORM}.json specifies a parent configuration via the parent attribute, then that is the value that is used.
  • Parent configurations can specify parents as well, and the inheritance recurses until a config file does not have a parent attribute.
  • Finally, for any attribute which was not otherwise given a value, the value from DEFAULTS.json is used.

Workflows

Consolidate before uploading

CONSOLIDATED.json is a generated script containing the data from all other JSON files. This allows Tast tests to access the config data. Thus, it is important to keep CONSOLIDATED.json up-to-date.

When you make a change to fw-testing-configs JSON, before you upload, be sure to run ./consolidate.py (with no command-line args). This will update CONSOLIDATED.json. Amend your change to include the update CONSOLIDATED.json, and then re-upload.

A preupload hook will verify that your CONSOLIDATED.json is up-to-date.

Modifying Tests and Configs

fw-testing-configs is a separate repository from both Autotest and tast-tests. Thus, edits to fw-testing-configs require a separate CL from edits to Autotest and tast-tests. If you are accustomed to working with config files directly in Autotest, this is a slightly different workflow.

When you are editing config files, please be sure to run git commands from within the fw-testing-configs checkout. If you run git add . or repo upload --cbr . from within autotest/server/cros/faft/, then your changes to the config files will not be captured.

If you are modifying both test files and config files, then you will need at least two CL’s: one for the test change, and one for the fw-testing-configs change. Consider also whether your change will impact the other testing repositories (Autotest, Tast, SerialTest): you might need to run tests or make changes there, too.

When submitting multiple CL’s like that, please use the Cq-Depend syntax as appropriate. If you don‘t use Cq-Depend, you risk the name of a config attribute changing while tests are still looking for the old name, and then tests will break. The reverse is a risk, too. You might need both CL’s to depend on each other. Note that this while this precaution mitigates risk, it does not fully eliminate risk: only one of the CL’s might get uploaded to the lab machines running Autotest/Tast, or one CL may be reverted without the other.

Accessing Configs During Tests

In Autotest, configs are loaded during FirmwareTest.initialize. Config values can be accessed via self.faft_config.${ATTRIBUTE}, such as self.faft_config.chrome_ec.

In Tast, configs can be created via firmware.NewConfig. In order to conform with Go’s style, attribute names are modified to MixedCaps. Config values can be accessed via cfg[${ATTRIBUTE}], such as cfg[ChromeEC].