Dismantle the global log severity file

Goal & motivation

Logs are commonly used to diagnose and troubleshoot system state, whether in production or in tests.

A useful feature of logs in tests allows restricting log severity under test. This gives test authors the confidence that their test isn't encountering unexpected erroneous conditions, even though all expectations set by the test are being met. Experience has shown that this is a useful feature that detects subtle bugs and regressions.

By default, tests will fail if they log at severity level greater than WARNING, meaning logs at ERROR or above. To override this behavior, developers can set a higher threshold. For instance if ERRORs are expected then developers will set max_severity = "ERROR" in the test specification associated with the test.

When this feature was first introduced, all overrides were set in a single file. Since then it became possible to set the override specific to the test where the test itself is defined. The new approach is easier to maintain.

Technical background

Entry-level knowledge of editing BUILD.gn files is required.

How to help

Picking a task

Pick an entry from max_severity_fuchsia.json. For instance:

      {
           "max_severity": "FATAL"
           "url": "fuchsia-pkg://fuchsia.com/audio_core_unittests#meta/audio_core_unittests.cm"
      },

Doing a task

You'll be deleting this part, and setting a similar configuration on the build definition for the test above.

fuchsia_test_package("audio_core_unittests") {
  test_specs = {
      log_settings = {
        max_severity = "FATAL"
      }
  }
  ...
}

You may also refer to the guide.

Note that while most tests are defined with the fuchsia_test_package() template, some tests are defined with other wrapper templates. Often times the wrappers accept test_specs and forward them to the underlying fuchsia_test_package template.

Completing a task

Find reviewers by OWNERS and merge your change.

Examples

Sponsors

Reach out for questions or for status updates: