[wlan] Create fake_bss! macro for mocking BssDescription values

The fake_bss! macro is introduced in this change to simplify the way
fake BssDescription types are created for tests. The first argument of
fake_bss! is always the security type desired, and the remaining arguments
override the default fields of the fake BssDescription. The security
type for the fake BssDescription will determine the default values for
the cap, rsne, and vendor_ies fields.

The fake_bss! macro goes a long way to reduce the amount of custom
"fake bss" functions implemented in various places. Before this change
it was common to encounter function calls like

  fake_vht_bss_description()

in test code. This call of course does very little to explain to the
reader what part of the fake BSS is particularly important to the
test. Now, the reader will encounter something like this instead.

  fake_bss!(Open, chan: fidl_common::WlanChan {
      primary: 123,
      cbw: fidl_common::Cbw::Cbw80P80,
      secondary80: 42,
  }),

The latter makes it much more obvious which fields of the fake BSS are
relevant to the test. Here are a couple more examples.

  protected_bss(b"foo".to_vec()) -> fake_bss!(Wpa2, ssid: b"wpa2".to_vec())

  bss(-10, -10, ProtectionCfg::Wpa1) -> fake_bss!(Wpa1, rssi_dbm: -10, rcpi_dbmh: -10)

Fixed: 62886
Test: fx test wlan-common-tests wlan-mlme-tests wlan-sme-tests wlanstack-tests
Change-Id: I197a54a6812194f444c115f78c6bf5b0e3ab4c32
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/443497
Commit-Queue: Charles Celerier <chcl@google.com>
Reviewed-by: Kiet Tran <kiettran@google.com>
Testability-Review: Kiet Tran <kiettran@google.com>
14 files changed
tree: 230bfc57889dabb71d06b153781c46c3f56c7b23
  1. boards/
  2. build/
  3. bundles/
  4. docs/
  5. examples/
  6. garnet/
  7. products/
  8. scripts/
  9. sdk/
  10. src/
  11. third_party/
  12. tools/
  13. zircon/
  14. .clang-format
  15. .clang-tidy
  16. .gitattributes
  17. .gitignore
  18. .gn
  19. .style.yapf
  20. AUTHORS
  21. BUILD.gn
  22. CODE_OF_CONDUCT.md
  23. CONTRIBUTING.md
  24. LICENSE
  25. OWNERS
  26. PATENTS
  27. README.md
  28. rustfmt.toml
README.md

Fuchsia

Pink + Purple == Fuchsia (a new operating system)

What is Fuchsia?

Fuchsia is a modular, capability-based operating system. Fuchsia runs on modern 64-bit Intel and ARM processors.

Fuchsia is an open source project with a code of conduct that we expect everyone who interacts with the project to respect.

Read more about Fuchsia's principles.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See fuchsia.dev.