Replace ioutil.WriteFile with os.WriteFile since the former has been
deprecated since go1.16 and simply calls the latter.
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Currently, if you try to use a snap with an app named "test", os.Args will also
end in ".test", making numerous places in the codebase think that it is being
run in a test environment and behave differently. In the case of the reported
bug, the code panics from `snap run` as it seems to the mountinfo code that we
are not mocking something that we should always be mocking in unit tests.
The bug could still hypothetically happen if someone made a symlink from
somewhere with "go-build" in the path (but not as part of the app name in the
snap) and a .test suffix on the executable, but this is sufficiently specific
that it is highly unlikely we would ever actually run into that problem "in the
wild".
Fixes: https://bugs.launchpad.net/snapd/+bug/1886786
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
split ReadEfiVar into ReadVarBytes, ReadVarString,
support returning the actual attributes as well
strings seem to be typically UTF16 encoded, that needs
special handling
have a special ErrNoEFISystem to denote non-EFI systems
adapt mocking to all of this
This is only meant to be used from tests, but it must be exported for other pkgs
to be able to use it.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>