container: root: add getter for dfi's root path

Adds impl/test for getting absolute path to all `dfi`'s `root` code.
This commit is contained in:
2025-12-17 13:56:51 -08:00
parent 6f415bd847
commit a54c7f25a5
2 changed files with 18 additions and 0 deletions

View File

@@ -255,6 +255,16 @@ std::string get_env(const std::string& var)
return std::string{env};
}
//! \brief Get `dfi`'s root-related code directory
//! \details Operating system path to where all `dfi` root-related code resides
//! \return Operating system absolute path (with trailing slash)
//! \exception type::RuntimeError if unable to get environment
//! \since docker-finance 1.1.0
std::string get_root_path()
{
return get_env("DOCKER_FINANCE_CONTAINER_REPO") + "/src/root/";
}
//! \brief Execute a command in operating system shell
//! \param cmd Operating system shell command [args]
//! \return Return value of command

View File

@@ -327,6 +327,14 @@ TEST_F(CommonFree, get_env)
ASSERT_NO_THROW(common::get_env("DOCKER_FINANCE_VERSION"));
}
TEST_F(CommonFree, get_root_path)
{
ASSERT_NO_THROW(common::get_root_path());
ASSERT_EQ(
common::get_root_path(),
common::get_env("DOCKER_FINANCE_CONTAINER_REPO") + "/src/root/");
}
TEST_F(CommonFree, exec)
{
ASSERT_NE(common::exec("should-not-exist"), 0);