diff options
-rw-r--r-- | include/xorg/gtest/process.h | 44 | ||||
-rw-r--r-- | src/process.cpp | 2 |
2 files changed, 24 insertions, 22 deletions
diff --git a/include/xorg/gtest/process.h b/include/xorg/gtest/process.h index 9cd207e..4359f21 100644 --- a/include/xorg/gtest/process.h +++ b/include/xorg/gtest/process.h @@ -56,6 +56,29 @@ namespace testing { class Process { public: /** + * Helper function to adjust the environment of the current process. + * + * @param [in] name Name of the environment variable. + * @param [in] value Value of the environment variable. + * @param [in] overwrite Whether to overwrite the value of existing env + * variables. + * + * @throws std::runtime_error if adjusting the environment does not succeed. + */ + static void SetEnv(const std::string& name, const std::string& value, + bool overwrite); + + /** + * Helper function to query the environment of the current process. + * + * @param [in] name The name of the environment variable. + * @param [out] exists If not NULL, the variable will be set to true if the + * environment variable exists and to false otherwise. + * @returns The value of the environment variable, or an empty string. + */ + static std::string GetEnv(const std::string& name, bool* exists = NULL); + + /** * Creates a child-process that is in a terminated state. */ Process(); @@ -115,27 +138,6 @@ class Process { bool Kill(); /** - * Adjusts the environment of the child process. - * - * @param [in] name Name of the environment variable. - * @param [in] value Value of the environment variable. - * @param [in] overwrite Whether to overwrite the value of existing env variables. - * - * @throws std::runtime_error if adjusting the environment does not succeed. - */ - void SetEnv(const std::string& name, const std::string& value, bool overwrite); - - /** - * Queries the environment of the child process. - * - * @param [in] name The name of the environment variable. - * @param [out] exists If not NULL, the variable will be set to true if the - * environment variable exists and to false otherwise. - * @returns The value of the environment variable, or an empty string. - */ - std::string GetEnv(const std::string& name, bool* exists = NULL) const; - - /** * Accesses the pid of the child process. * * @returns The pid of the child process or -1. diff --git a/src/process.cpp b/src/process.cpp index 05a808a..bfe067d 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -115,7 +115,7 @@ void xorg::testing::Process::SetEnv(const std::string& name, } std::string xorg::testing::Process::GetEnv(const std::string& name, - bool* exists) const { + bool* exists) { const char* var = getenv(name.c_str()); if (exists != NULL) *exists = (var != NULL); |