canonical / canonical/secboot

Make use of internal/testenv where appropriate

Open
#375 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
23
Forks
29
Avg merge
2d 8h
Merged PRs (30d)
2

Description

PR #328 introduced a small package `internal/testenv` which is small enough to
be embedded in production code and exports a single function `IsTestBinary` in
order to prevent access to unit-test only features in production code. The package
requires explicit linker flags to make the function to return true, else it always
returns false.

There may be other places in secboot which would benefit from its use, eg,
`internal/bootscope` exports a function that should only be used in unit tests,
and currently requires a hack to enable it - it requires the unit test code to set
an exported variable which is named in a way to make it clear that it's not for
use in production code.

There are probably other places where it's use is appropriate, but I haven't done
a full audit of the code yet.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.