diff --git a/container/src/root/common/utility.hh b/container/src/root/common/utility.hh index fc1a220..0b60814 100644 --- a/container/src/root/common/utility.hh +++ b/container/src/root/common/utility.hh @@ -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 diff --git a/container/src/root/test/unit/utility.hh b/container/src/root/test/unit/utility.hh index 976989f..5a310b8 100644 --- a/container/src/root/test/unit/utility.hh +++ b/container/src/root/test/unit/utility.hh @@ -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);