move calls to cstdlib::getenv to env::getEnv
Wrapped the cstdlib::getenv() call into env::getEnv
so that it can be tested by mocking the env namespace,
by just dropping in test_env.cpp which implements those
methods and tying them a singleton upon which we can set
expectations.
Note: regardless of the approach taken to mock this, wrapping
this method is a good fix.
Change-Id: I65d22da08fc3dd76e6860f728c54e6c847ed07de
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/targets.hpp b/targets.hpp
index fe256a3..02bdd4f 100644
--- a/targets.hpp
+++ b/targets.hpp
@@ -103,8 +103,8 @@
if (fs::exists(sysfsFullPath))
{
auto useTarget = true;
- auto tmEnv = getenv("TARGET_MODE");
- if (tmEnv)
+ auto tmEnv = env::getEnv("TARGET_MODE");
+ if (!tmEnv.empty())
{
std::string mode{tmEnv};
std::transform(mode.begin(), mode.end(), mode.begin(), toupper);